Could not run 'aten::empty_strided' with arguments from the 'CUDA' backend

username: Ali_MassahKiani
cooked: <p>I tried to load model in c++ with jit but the error raised:<br>
error raised in this line :<br>
<code>model = torch::jit::load("Resource/model.pt");</code></p>
<pre><code class="lang-auto">Could not run 'aten::empty_strided' with arguments from the 'CUDA' backend. This could be because the operator doesn't exist for this backend, or was omitted during the selective/custom build process (if using custom build). If you are a Facebook employee using PyTorch on mobile, please visit https://fburl.com/ptmfixes for possible resolutions. 'aten::empty_strided' is only available for these backends: [CPU, BackendSelect, Named, AutogradOther, AutogradCPU, AutogradCUDA, AutogradXLA, AutogradNestedTensor, UNKNOWN_TENSOR_TYPE_ID, AutogradPrivateUse1, AutogradPrivateUse2, AutogradPrivateUse3, Tracer, Autocast, Batched, VmapMode].

CPU: registered at aten\src\ATen\RegisterCPU.cpp:5925 [kernel]
BackendSelect: registered at aten\src\ATen\RegisterBackendSelect.cpp:596 [kernel]
Named: registered at ..\..\aten\src\ATen\core\NamedRegistrations.cpp:7 [backend fallback]
AutogradOther: registered at ..\..\torch\csrc\autograd\generated\VariableType_0.cpp:9273 [autograd kernel]
AutogradCPU: registered at ..\..\torch\csrc\autograd\generated\VariableType_0.cpp:9273 [autograd kernel]
AutogradCUDA: registered at ..\..\torch\csrc\autograd\generated\VariableType_0.cpp:9273 [autograd kernel]
AutogradXLA: registered at ..\..\torch\csrc\autograd\generated\VariableType_0.cpp:9273 [autograd kernel]
AutogradNestedTensor: registered at ..\..\torch\csrc\autograd\generated\VariableType_0.cpp:9273 [autograd kernel]
UNKNOWN_TENSOR_TYPE_ID: registered at ..\..\torch\csrc\autograd\generated\VariableType_0.cpp:9273 [autograd kernel]
AutogradPrivateUse1: registered at ..\..\torch\csrc\autograd\generated\VariableType_0.cpp:9273 [autograd kernel]
AutogradPrivateUse2: registered at ..\..\torch\csrc\autograd\generated\VariableType_0.cpp:9273 [autograd kernel]
AutogradPrivateUse3: registered at ..\..\torch\csrc\autograd\generated\VariableType_0.cpp:9273 [autograd kernel]
Tracer: registered at ..\..\torch\csrc\autograd\generated\TraceType_0.cpp:10499 [kernel]
Autocast: fallthrough registered at ..\..\aten\src\ATen\autocast_mode.cpp:250 [backend fallback]
Batched: registered at ..\..\aten\src\ATen\BatchingRegistrations.cpp:1016 [backend fallback]
VmapMode: fallthrough registered at ..\..\aten\src\ATen\VmapModeRegistrations.cpp:33 [backend fallback]

Exception raised from reportError at ..\..\aten\src\ATen\core\dispatch\OperatorEntry.cpp:397 (most recent call first):
00007FFB821E0F9200007FFB821E0F30 c10.dll!c10::Error::Error [&lt;unknown file&gt; @ &lt;unknown line number&gt;]
00007FFB821E0C0E00007FFB821E0BC0 c10.dll!c10::detail::torchCheckFail [&lt;unknown file&gt; @ &lt;unknown line number&gt;]
00007FFB3E0C357E00007FFB3E0C33C0 torch_cpu.dll!c10::impl::OperatorEntry::reportError [&lt;unknown file&gt; @ &lt;unknown line number&gt;]
00007FFB3E55517D00007FFB3E4D6FA0 torch_cpu.dll!at::native::mkldnn_sigmoid_ [&lt;unknown file&gt; @ &lt;unknown line number&gt;]
00007FFB3E749A6900007FFB3E72BAB0 torch_cpu.dll!at::zeros_outf [&lt;unknown file&gt; @ &lt;unknown line number&gt;]
00007FFB3E74625D00007FFB3E72BAB0 torch_cpu.dll!at::zeros_outf [&lt;unknown file&gt; @ &lt;unknown line number&gt;]
00007FFB3E53A67900007FFB3E4D6FA0 torch_cpu.dll!at::native::mkldnn_sigmoid_ [&lt;unknown file&gt; @ &lt;unknown line number&gt;]
00007FFB3E68127700007FFB3E681150 torch_cpu.dll!at::empty_strided [&lt;unknown file&gt; @ &lt;unknown line number&gt;]
00007FFB3E3469A300007FFB3E346630 torch_cpu.dll!at::native::to_dense_backward [&lt;unknown file&gt; @ &lt;unknown line number&gt;]
00007FFB3E34658100007FFB3E346470 torch_cpu.dll!at::native::to [&lt;unknown file&gt; @ &lt;unknown line number&gt;]
00007FFB3E94A9CD00007FFB3E72BAB0 torch_cpu.dll!at::zeros_outf [&lt;unknown file&gt; @ &lt;unknown line number&gt;]
00007FFB3E913B0200007FFB3E72BAB0 torch_cpu.dll!at::zeros_outf [&lt;unknown file&gt; @ &lt;unknown line number&gt;]
00007FFB3E99239400007FFB3E985C80 torch_cpu.dll!at::is_custom_op [&lt;unknown file&gt; @ &lt;unknown line number&gt;]
00007FFB3E9E4E8B00007FFB3E9E4DE0 torch_cpu.dll!at::Tensor::to [&lt;unknown file&gt; @ &lt;unknown line number&gt;]
00007FFB400693F000007FFB400680A0 torch_cpu.dll!torch::jit::Unpickler::readInstruction [&lt;unknown file&gt; @ &lt;unknown line number&gt;]
00007FFB4006BBE800007FFB4006BA60 torch_cpu.dll!torch::jit::Unpickler::run [&lt;unknown file&gt; @ &lt;unknown line number&gt;]
00007FFB40066CF200007FFB40066CC0 torch_cpu.dll!torch::jit::Unpickler::parse_ivalue [&lt;unknown file&gt; @ &lt;unknown line number&gt;]
00007FFB4003A0E500007FFB40039D00 torch_cpu.dll!torch::jit::readArchiveAndTensors [&lt;unknown file&gt; @ &lt;unknown line number&gt;]
00007FFB40039CD300007FFB40038460 torch_cpu.dll!torch::jit::load [&lt;unknown file&gt; @ &lt;unknown line number&gt;]
00007FFB40036B3600007FFB400247C0 torch_cpu.dll!torch::jit::hasGradientInfoForSchema [&lt;unknown file&gt; @ &lt;unknown line number&gt;]
00007FFB4003868200007FFB40038460 torch_cpu.dll!torch::jit::load [&lt;unknown file&gt; @ &lt;unknown line number&gt;]
00007FFB4003810400007FFB40037FE0 torch_cpu.dll!torch::jit::load [&lt;unknown file&gt; @ &lt;unknown line number&gt;]
00007FF6C222A2E500007FF6C222A270 BgRemover.exe!U2Net::U2Net [D:\MyWorks\C++\BgRemover\BgRemover\U2Net.cpp @ 75]
00007FF6C222509100007FF6C2224E00 BgRemover.exe!SegmentationNextDetection [D:\MyWorks\C++\BgRemover\BgRemover\BgRemover.cpp @ 53]
00007FF6C2225B0900007FF6C2225B00 BgRemover.exe!main [D:\MyWorks\C++\BgRemover\BgRemover\BgRemover.cpp @ 117]
00007FF6C222B57400007FF6C222B468 BgRemover.exe!__scrt_common_main_seh [D:\agent\_work\13\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl @ 288]
00007FFB97AD703400007FFB97AD7020 KERNEL32.DLL!BaseThreadInitThunk [&lt;unknown file&gt; @ &lt;unknown line number&gt;]
00007FFB98FA265100007FFB98FA2630 ntdll.dll!RtlUserThreadStart [&lt;unknown file&gt; @ &lt;unknown line number&gt;]
</code></pre>

username: Ali_MassahKiani
cooked: <p>I found solution in this <a href="https://www.gitmemory.com/issue/pytorch/pytorch/54131/800908665" rel="noopener nofollow ugc">link</a></p>

username: madhurbhattadmb
cooked: <p>Hey, can you describe the solution. The link you provided is not working anymore.</p>

username: shigeo_kageyama
cooked: <p>This is the error I’m getting in android while loading the model.</p>
<p><code>java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.example.cataractdetectionapp/com.android.example.cataractdetectionapp.InferenceActivity}: </code></p>
<p><code>com.facebook.jni.CppException: Could not run 'aten::empty_strided' with arguments from the 'CUDA' backend.</code><br><code>This could be because the operator doesn't exist for this backend, or was omitted during the selective/custom build process (if using custom build). </code><br><code>If you are a Facebook employee using PyTorch on mobile, please visit https://fburl.com/ptmfixes for possible resolutions. </code><br><code>'aten::empty_strided' is only available for these backends: [CPU, Vulkan, BackendSelect, Python, Named, Conjugate, Negative, ADInplaceOrView, AutogradOther, AutogradCPU, AutogradCUDA, AutogradXLA, AutogradLazy, AutogradXPU, AutogradMLC, UNKNOWN_TENSOR_TYPE_ID, Autocast, Batched, VmapMode].</code></p>
<p><code> CPU: registered at aten/src/ATen/RegisterCPU.cpp:18433 [kernel]</code></p>
<p><code> Vulkan: registered at ../aten/src/ATen/native/vulkan/ops/Factory.cpp:47 [kernel]</code><br><br>
<code> BackendSelect: registered at aten/src/ATen/RegisterBackendSelect.cpp:665 [kernel]</code><br><br>
<code> Python: registered at ../aten/src/ATen/core/PythonFallbackKernel.cpp:47 [backend fallback]</code><br><br>
<code> Named: registered at ../aten/src/ATen/core/NamedRegistrations.cpp:7 [backend fallback]</code><br><br>
<code> Conjugate: fallthrough registered at ../aten/src/ATen/ConjugateFallback.cpp:22 [kernel]</code><br><br>
<code> Negative: fallthrough registered at ../aten/src/ATen/native/NegateFallback.cpp:22 [kernel]</code><br><br>
<code> ADInplaceOrView: fallthrough registered at ../aten/src/ATen/core/VariableFallbackKernel.cpp:64 [backend fallback]</code><br><br>
<code> AutogradOther: fallthrough registered at ../aten/src/ATen/core/VariableFallbackKernel.cpp:35 [backend fallback]</code><br><br>
<code> AutogradCPU: fallthrough registered at ../aten/src/ATen/core/VariableFallbackKernel.cpp:39 [backend fallback]</code><br><br>
<code> AutogradCUDA: fallthrough registered at ../aten/src/ATen/core/VariableFallbackKernel.cpp:47 [backend fallback]</code><br><br>
<code> AutogradXLA: fallthrough registered at ../aten/src/ATen/core/VariableFallbackKernel.cpp:51 [backend fallback]</code><br><br>
<code> AutogradLazy: fallthrough registered at ../aten/src/ATen/core/VariableFallbackKernel.cpp:55 [backend fallback]</code><br><br>
<code> AutogradXPU: fallthrough registered at ../aten/src/ATen/core/VariableFallbackKernel.cpp:43 [backend fallback]</code><br><br>
<code> AutogradMLC: fallthrough registered at ../aten/src/ATen/core/VariableFallbackKernel.cpp:59 [backend fallback]</code><br><br>
<code> UNKNOWN_TENSOR_TYPE_ID: fallthrough registered at ../aten/src/ATen/autocast_mode.cpp:466 [backend fallback]</code><br><br>
<code> Autocast: fallthrough registered at ../aten/src/ATen/autocast_mode.cpp:305 [backend fallback]</code><br><br>
<code> Batched: registered at ../aten/src/ATen/BatchingRegistrations.cpp:1016 [backend fallback]</code><br><br>
<code> VmapMode: fallthrough registered at ../aten/src/ATen/VmapModeRegistrations.cpp:33 [backend fallback]</code><br></p>
<p>I used the below code for loading the module:</p>
<p><code>Module module = LiteModuleLoader.load(assetFilePath(getApplicationContext(),</code><br> <code>"Model.ptl"));</code></p>
<p>The dependencies I’m using for Pytorch are as follows:<br></p>
<p><code>    implementation 'org.pytorch:pytorch_android_lite:1.10.0'</code><br><br>
<code>    implementation 'org.pytorch:pytorch_android_torchvision:1.10.0'</code></p>