导入torch等库的时候报错OSError: [WinError 127] The specified procedure could not be found. Error loading "E:\anaconda3\envs\py3.10\lib\site-packages\torch\lib\c10_cuda.dll" or one of its dependencies.
在导入torch,torchvision等库时报错WinError 127
通常的报错内容
Connected to pydev debugger (build 202.6397.98)
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "E:\anaconda3\envs\py3.10\lib\site-packages\torch\__init__.py", line 129, in <module>
raise err
OSError: [WinError 127] The specified procedure could not be found. Error loading "E:\anaconda3\envs\py3.10\lib\site-packages\torch\lib\c10_cuda.dll" or one of its dependencies.
python-BaseException
这里是torch库调用的dll的时候报错了。大概率是因为环境里的torch有新有旧(更新时意外的dll的残留,导致的调用错误)
最好的解决办法就是重新安装torch
先 pip uninstall torch
然后重新安装需要的版本