Import torch error It's so frustrating

sigar_wang: <p>————————————————————————————<br>
python 3.9</p>
<p>cuda-cccl                 12.3.101                      0    nvidia<br>
cuda-cudart               12.1.105                      0    nvidia<br>
cuda-cudart-dev           12.1.105                      0    nvidia<br>
cuda-cupti                12.1.105                      0    nvidia<br>
cuda-libraries            12.1.0                        0    nvidia<br>
cuda-libraries-dev        12.1.0                        0    nvidia<br>
cuda-nvrtc                12.1.105                      0    nvidia<br>
cuda-nvrtc-dev            12.1.105                      0    nvidia<br>
cuda-nvtx                 12.1.105                      0    nvidia<br>
cuda-opencl               12.3.101                      0    nvidia<br>
cuda-opencl-dev           12.3.101                      0    nvidia<br>
cuda-profiler-api         12.3.101                      0    nvidia<br>
cuda-runtime              12.1.0                        0    nvidia<br>
pytorch-cuda              12.1                 hde6ce7c_5    pytorch</p>
<p>pytorch                   2.2.0           py3.9_cuda12.1_cudnn8_0    pytorch<br>
pytorch-cuda              12.1                 hde6ce7c_5    pytorch<br>
pytorch-mutex             1.0                        cuda    pytorch<br>
torchaudio                2.2.0                    pypi_0    pypi<br>
torchvision               0.17.0                   pypi_0    pypi<br>
————————————————————————————<br>
An attempt to import torch results in an error message</p>
<p>"OSError                                   Traceback (most recent call last)<br>
Cell In[4], line 3<br>
1 import os<br>
2 os.environ[‘KMP_DUPLICATE_LIB_OK’]=‘True’<br>
----&gt; 3 import torch</p>
<p>File d:\ProgramData\miniconda3\envs\bayes\lib\site-packages\torch_<em>init</em>_.py:130<br>
128     err = ctypes.WinError(last_error)<br>
129     err.strerror += f’ Error loading “{dll}” or one of its dependencies.’<br>
 → 130     raise err<br>
131 elif res is not None:<br>
132     is_loaded = True</p>
<p>OSError: [WinError 182] operating system cannot run %1. Error loading “d:\ProgramData\miniconda3\envs\bayes\lib\site-packages\torch\lib\fbgemm.dl”<br>
————————————————————————————<br>
(1) I can find the file under the path “d:\ProgramData\miniconda3\envs\bayes\lib\site-packages\torch\lib\fbgemm.dl”.<br>
(2) Use “import ctypes “alone<br>
ctypes.CDLL(r"D:\ProgramData\miniconda3\envs\bayes\Lib\site-packages\torch\lib\fbgemm.dll”)” also failed.<br>
(3) Use software “Dependencies” to find “could not find libiomp5md.dll file on the disk anymore”. I found “libiomp5md.dll” under another folder and used “import ctypes”<br>
ctypes.CDLL(r"D:\ProgramData\miniconda3\envs\bayes\Library\bin\libiomp5md.dll")", this works.</p>
<p>What else can I do to check?</p>

Nokto: <p>Had the same error, it couldn’t load fbgemm.dll. I tried downgrading CUDA to 12.1.1, that didn’t solve it. Then I just created a new env in conda, installed PyTorch w/ CUDA 12.1 via pip (conda installer kept breaking mid-download), then I tested again and it worked (with CUDA still on 12.1.1).</p>

sigar_wang: <p>Can’t believe it! I succeed in the same way, so much thanks.</p>