Cannot import torch problem [WinError 126] but the file is in place

Viewed 121

I have tried to import torch after I have installed it following the official site. However, I got this error. I seems like ctypes.CDLL(c:\Users\Jianr\Miniconda3\lib\site-packages\torch\lib\caffe2_nvrtc.dll) returned this error. And this file is indeed at the location specified. This is an absolute path. And the dll files at the same folder does not cause such problem. What could be the reason that this is happening and how could I fix it? Thank you!

Error Message:

Traceback (most recent call last):
File "C:/Users/Jianr/Downloads/cal_similarity.py", line 2, in <module>
    import torch
File "c:\Users\Jianr\Miniconda3\Lib\site-packages\torch\__init__.py", line 82, in <module>
    ctypes.CDLL(dll)
File "c:\Users\Jianr\Miniconda3\Lib\ctypes\__init__.py", line 348, in __init__
    self._handle = _dlopen(self._name, mode)
builtins.OSError: [WinError 126] The specified module could not be found```
1 Answers

I also have the same problem, neither don't know how to fix it elegantly. And then I try to move the caffe2_nvrtc files (caffe2_nvrtc.dll and caffe2_nvrtc.lib) to a tmp dir, and now the problem is fixed. And my program works now, which is a deep nlp program.

Related