You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
from torch._C import * (ImportError: DLL load failed: The specified module could not be found. #4518
File "C:\Users\hp i3\Anaconda3\lib\site-packages\torch_init_.py", line 76, in
from torch._C import *
ImportError: DLL load failed: The specified module could not be found.
Reacted by Alessandro Re, Rick B, Kamil Zieliński, Josh Varty, JindongGu, Muhammad N ElNokrashy, rajitnair, Vikas Yadav, অভিলাষ পাল Abhilash Pal, ajhool and 75 more
@HarshneetBhatia If if doesn't work after reinstalling Anaconda, then you can use sth. like Dependency Walker, open [Anaconda PATH]\Lib\site-packages\torch\lib\_C.pyd to detect what's wrong there.
I had the same issue and it was caused by the directory torch which is generated in the same directory by compiling the source. The solution for me was simply changing the directory before open python.
The problem in my case was that I started python from a (command)-shell from the directory in which I compiled pytorch. In this directory exists (was generated) the sub-directory torch, which python tries to load if you "import torch". So simply leaving the pytorch directory before starting python solved my problem.
Reacted by Guyue Hu, Mostafa Hadian, leonardschneider, AtaJadidAhari, Lan Gong, mingman and Seokwoo Jang
I get a similar error in the following context: Perviously, I successfully used windows10 pytorch 0.2.1 (using the anaconda distribution from -c peterjc123). We have now downloaded a pip .whl for all of us to use and so I uninstalled pytorch 0.2.1 and tried installing the wheel file using
This completes successfully, but then I get (in spyder, PyDev and python command line):
'>> import torch
Traceback (most recent call last):
File "C:\Users\alexandre\Anaconda3\lib\site-packages\torch_init_.py", line 76, in
from torch._C import *
ImportError: DLL load failed: The specified module could not be found.
'
I am on windows 10, python 3.6.4, conda 4.4.10. And pip is the anaconda pip.
As a fallback I tried: conda install -c peterjc123 pytorch cuda80
and that 'worked'
But I am curious why the .whl file fails for me (it works on a colleague's machine).
Reacted by Yijin Lin, Laurens-T, amishra511, dskiran2018, Isaac Qiao, zhenyu li, Siqin Tao, eurosVN403, Léandre Gagnon-Lewis, Tasnim and 2 more
Reacted by AlbertHuyb, yradjam, Lin Wang, lutein, Damien LaRocque, lthakur, RajaRangiah, lizhenbang56, Joyce-Ng, liushaocan123 and 20 more
@aviolov It's probably related to Visual C++ Redist 2017. Because the vc package will be updated if you install it through the conda channel. You can confirm this using the following steps:
I don't think this is a CUDA related issue. It sounds more like the pip install command messes up the torch folders 'somehow', as the other comments above suggest, although i experienced the problem not just when running python in the same folder in which I ran the pip comand. (pydev, spyder, ipython in another folder)
Also I did try
conda install pytorch
conda uninstall pytorch
pip instal pytorch.whl
And the failure persisted, which suggests that it's not related to the vc2017 Redist, since the first conda update should have fixed that?
Another weird thing is that when i try to pip uninstall I get an error that it cannot remove some folders from my AppData\Local\Temp. These folders look like the torch distriution (./torch/_nvrtc.cp.. etc).
I was trying to execute sample code from fast.ai course and I get similar error. I am new and just walking foot-steps to setup my jupyter notebook.
`C:\Program Files\Anaconda3\envs\fastai\lib\site-packages\torch\__init__.py in <module>()
74 pass
75
---> 76 from torch._C import *
77
78 __all__ += [name for name in dir(_C)
ImportError: DLL load failed: The specified module could not be found.`
Below is my conda info
C:\Users\wecando>conda info
active environment : None
user config file : C:\Users\wecando\.condarc
populated config files : C:\Users\wecando\.condarc
conda version : 4.4.10
conda-build version : not installed
python version : 3.6.0.final.0
base environment : C:\Program Files\Anaconda3 (read only)
channel URLs : https://conda.anaconda.org/anaconda-fusion/win-64
https://conda.anaconda.org/anaconda-fusion/noarch
https://repo.continuum.io/pkgs/main/win-64
https://repo.continuum.io/pkgs/main/noarch
https://repo.continuum.io/pkgs/free/win-64
https://repo.continuum.io/pkgs/free/noarch
https://repo.continuum.io/pkgs/r/win-64
https://repo.continuum.io/pkgs/r/noarch
https://repo.continuum.io/pkgs/pro/win-64
https://repo.continuum.io/pkgs/pro/noarch
https://repo.continuum.io/pkgs/msys2/win-64
https://repo.continuum.io/pkgs/msys2/noarch
package cache : C:\Program Files\Anaconda3\pkgs
C:\Users\wecando\AppData\Local\conda\conda\pkgs
envs directories : C:\Users\wecando\AppData\Local\conda\conda\envs
C:\Program Files\Anaconda3\envs
C:\Users\wecando\.conda\envs
platform : win-64
user-agent : conda/4.4.10 requests/2.12.4 CPython/3.6.0 Windows/10 Windows/10.0.16299
I get a similar error in the following context: Perviously, I successfully used windows10 pytorch 0.2.1 (using the anaconda distribution from -c peterjc123). We have now downloaded a pip .whl for all of us to use and so I uninstalled pytorch 0.2.1 and tried installing the wheel file using
This completes successfully, but then I get (in spyder, PyDev and python command line):
'>> import torch
Traceback (most recent call last):
File "C:\Users\alexandre\Anaconda3\lib\site-packages\torch__init__.py", line 76, in
from torch._C import *
ImportError: DLL load failed: The specified module could not be found.
'
I am on windows 10, python 3.6.4, conda 4.4.10. And pip is the anaconda pip.
As a fallback I tried: conda install -c peterjc123 pytorch cuda80
and that 'worked'
But I am curious why the .whl file fails for me (it works on a colleague's machine).
The combination that worked for me for a complete offline installation:
CUDA 10.1 (with the matching cuDNN library)
Python 3.6.10 (Anaconda)
pyYAML 5.1 (from PyPI)
torch 1.4.0 cuda101 (from Anaconda Cloud)
torchvision 0.5.0 (from PyPi)
Note that I have installed the VS requirements beforehand
Sorry, I'm not sure whether it could work. While the version of python is 3.7.4 in my another computer and it does not have the problem. Maybe you can have a try.
------------------ 原始邮件 ------------------
发件人: "liaoxuewei"<[email protected]>;
发送时间: 2020年8月20日(星期四) 上午10:44
收件人: "pytorch/pytorch"<[email protected]>;
抄送: "倪思琪"<[email protected]>; "Comment"<[email protected]>;
主题: Re: [pytorch/pytorch] from torch._C import * (ImportError: DLL load failed: The specified module could not be found. (#4518)
I installed Python version 3.6.8 and it solved my problem
Do pytorch support python 3.7? My python version is 3.7.x and it can't solved my problem
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
@ciphurus Can you try cpu version first(see comment above)? If cpu version cannot be successfully imported, then it may be related to VC2017, otherwise your CUDA setup may be corrupted.
Hi I am not able import pytorch for cpu version. How to solve this?
I had this issue after building pytorch from source on windows and the fix was to place all of the generated libraries from the <install folder>\lib folder into the site-packages\torch\lib folder alongside _C.lib
i got a similar issue :: ImportError: DLL load failed while importing _C the specified module could not be found while trying to use Detectron2LayoutModel
Activity
peterjc123 commentedon Jan 7, 2018
@HarshneetBhatia Which version are you using? Do you have CUDA cards? How did you install it?
peterjc123 commentedon Jan 7, 2018
@HarshneetBhatia And I noticed there is a space inside your path of Anaconda install. Would you please try a path without it?
HarshneetBhatia commentedon Jan 7, 2018
@peterjc123
Using Anaconda -Spyder python 3.6
I have installed conda install -c peterjc123 pytorch
I am using windows 8.1
Is space creates problem I have the same path hp i3 - Should I change the the name ?
peterjc123 commentedon Jan 7, 2018
@HarshneetBhatia If if doesn't work after reinstalling Anaconda, then you can use sth. like Dependency Walker, open
[Anaconda PATH]\Lib\site-packages\torch\lib\_C.pydto detect what's wrong there.maatini commentedon Jan 7, 2018
I had the same issue and it was caused by the directory torch which is generated in the same directory by compiling the source. The solution for me was simply changing the directory before open python.
HarshneetBhatia commentedon Jan 7, 2018
@maatini I am using Anaconda can you please guide me how to change the directory.
Thanks in advance
maatini commentedon Jan 7, 2018
The problem in my case was that I started python from a (command)-shell from the directory in which I compiled pytorch. In this directory exists (was generated) the sub-directory torch, which python tries to load if you "import torch". So simply leaving the pytorch directory before starting python solved my problem.
HarshneetBhatia commentedon Jan 7, 2018
@maatini In Anaconda do you have any idea how can this problem be solved ?
Because I not getting how to change the directory in Anaconda.
ezyang commentedon Jan 7, 2018
@HarshneetBhatia Same as how you normally change directory:
cd.aviolov commentedon Feb 20, 2018
I get a similar error in the following context: Perviously, I successfully used windows10 pytorch 0.2.1 (using the anaconda distribution from -c peterjc123). We have now downloaded a pip .whl for all of us to use and so I uninstalled pytorch 0.2.1 and tried installing the wheel file using
pip install $PATH_TO_WHL$/torch-0.3.0b0+591e73e-cp36-cp36m-win_amd64.whlThis completes successfully, but then I get (in spyder, PyDev and python command line):
'>> import torch
Traceback (most recent call last):
File "C:\Users\alexandre\Anaconda3\lib\site-packages\torch_init_.py", line 76, in
from torch._C import *
ImportError: DLL load failed: The specified module could not be found.
'
I am on windows 10, python 3.6.4, conda 4.4.10. And
pipis the anaconda pip.As a fallback I tried:
conda install -c peterjc123 pytorch cuda80and that 'worked'
But I am curious why the .whl file fails for me (it works on a colleague's machine).
peterjc123 commentedon Feb 20, 2018
@aviolov It's probably related to Visual C++ Redist 2017. Because the vc package will be updated if you install it through the conda channel. You can confirm this using the following steps:
If that works, then it should be MSVC related. Otherwise, maybe the cuda files are missing in PATH.
aviolov commentedon Feb 21, 2018
I don't think this is a CUDA related issue. It sounds more like the
pip installcommand messes up the torch folders 'somehow', as the other comments above suggest, although i experienced the problem not just when running python in the same folder in which I ran the pip comand. (pydev, spyder, ipython in another folder)Also I did try
conda install pytorch
conda uninstall pytorch
pip instal pytorch.whl
And the failure persisted, which suggests that it's not related to the vc2017 Redist, since the first conda update should have fixed that?
Another weird thing is that when i try to
pip uninstallI get an error that it cannot remove some folders from my AppData\Local\Temp. These folders look like the torch distriution (./torch/_nvrtc.cp.. etc).peterjc123 commentedon Feb 21, 2018
@aviolov Can you check that
_nvrtc.cp..lies in the Anaconda dir?code17lines commentedon Feb 22, 2018
I was trying to execute sample code from fast.ai course and I get similar error. I am new and just walking foot-steps to setup my jupyter notebook.
Below is my conda info
150 remaining items
srilalithaveerubhotla commentedon Nov 13, 2019
This works 👍
nomisto commentedon Jan 23, 2020
I had the same problem of getting error "from torch._C import * ImportError: DLL load failed: The specified module could not be found."
Using Windows - Pure Python 3.6 - torch 0.4.0 - Virtual Environment
I solved it with the following steps:
python -m pip install pip==9.0.1pip install mkl intel-openmppip install torch==0.4.0 -f https://download.pytorch.org/whl/torch_stable.htmlHomeLH commentedon Mar 11, 2020
conda update pythonworks well. The updated python version is 3.8.1IK1218 commentedon Mar 26, 2020
This will help you https://support.pyxll.com/hc/en-gb/articles/360041392893-Error-importing-Python-module-DLL-load-failed
For downloading and setting up for api-ms-win-crt-runtime-l1-1-0.dll https://www.youtube.com/watch?v=Ob6cJegM1l8
Terizian commentedon May 21, 2020
The combination that worked for me for a complete offline installation:
CUDA 10.1 (with the matching cuDNN library)
Python 3.6.10 (Anaconda)
pyYAML 5.1 (from PyPI)
torch 1.4.0 cuda101 (from Anaconda Cloud)
torchvision 0.5.0 (from PyPi)
Note that I have installed the VS requirements beforehand
caozhenxiang-kouji commentedon Jun 3, 2020
This should be the msvc problem. Please download the whl file from https://pypi.org/project/msvc-runtime/ and install it.
My config:
Windows 10
cudatoolkit 10.0.130
pytorch 1.2.0
msvc-runtime 14.26.28720
liaoxuewei commentedon Aug 20, 2020
Do pytorch support python 3.7? My python version is 3.7.x and it can't solved my problem
lixite commentedon Aug 20, 2020
wss321 commentedon Sep 10, 2020
I solved this problem by installing gpu driver. https://www.nvidia.cn/Download/index.aspx
You should check if the GTX driver is installed.
krishnansr commentedon Sep 19, 2020
This worked with following config,
Windows 10
cudatoolkit 10.0.130
pytorch 1.4.0
msvc-runtime
Thanks for the pypi package!
Sanjayvaradha commentedon Dec 22, 2020
Hi I am not able import pytorch for cpu version. How to solve this?
juniperfdel commentedon Mar 10, 2022
I had this issue after building pytorch from source on windows and the fix was to place all of the generated libraries from the
<install folder>\libfolder into thesite-packages\torch\libfolder alongside _C.libJoe-Heffer-Shef commentedon Aug 31, 2022
https://pytorch.org/docs/1.4.0/notes/windows.html#import-error
MarouaneZ1 commentedon Sep 25, 2022
i got a similar issue :: ImportError: DLL load failed while importing _C the specified module could not be found while trying to use Detectron2LayoutModel
iamtalhaasghar commentedon Apr 15, 2023
related #17203, #9071