Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: DLL load failed on Windows #1018

Closed
Jonas1312 opened this issue Jun 14, 2019 · 25 comments
Closed

ImportError: DLL load failed on Windows #1018

Jonas1312 opened this issue Jun 14, 2019 · 25 comments

Comments

@Jonas1312
Copy link

I have a dll load failed the specified module could not be found error when importing torchvision

PyTorch stable 1.1:

C:\Windows\system32>python -m pip install https://download.pytorch.org/whl/cu100/torch-1.1.0-cp37-cp37m-win_amd64.whl
Collecting torch==1.1.0 from https://download.pytorch.org/whl/cu100/torch-1.1.0-cp37-cp37m-win_amd64.whl
  Using cached https://download.pytorch.org/whl/cu100/torch-1.1.0-cp37-cp37m-win_amd64.whl
Requirement already satisfied: numpy in c:\python37\lib\site-packages (from torch==1.1.0) (1.16.4+mkl)
Installing collected packages: torch
Successfully installed torch-1.1.0

C:\Windows\system32>python
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> import torchvision
>>> exit()

Nightly:


C:\Windows\system32>python -m pip install torch_nightly -f https://download.pytorch.org/whl/nightly/cu100/torch_nightly.html
Looking in links: https://download.pytorch.org/whl/nightly/cu100/torch_nightly.html
Collecting torch_nightly
  Using cached https://download.pytorch.org/whl/nightly/cu100/torch_nightly-1.1.0.dev20190612-cp37-cp37m-win_amd64.whl
Installing collected packages: torch-nightly
Successfully installed torch-nightly-1.1.0.dev20190612

C:\Windows\system32>python
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> import torchvision
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python37\lib\site-packages\torchvision\__init__.py", line 1, in <module>
    from torchvision import models
  File "C:\Python37\lib\site-packages\torchvision\models\__init__.py", line 11, in <module>
    from . import detection
  File "C:\Python37\lib\site-packages\torchvision\models\detection\__init__.py", line 1, in <module>
    from .faster_rcnn import *
  File "C:\Python37\lib\site-packages\torchvision\models\detection\faster_rcnn.py", line 7, in <module>
    from torchvision.ops import misc as misc_nn_ops
  File "C:\Python37\lib\site-packages\torchvision\ops\__init__.py", line 1, in <module>
    from .boxes import nms, box_iou
  File "C:\Python37\lib\site-packages\torchvision\ops\boxes.py", line 2, in <module>
    from torchvision import _C
ImportError: DLL load failed: La procédure spécifiée est introuvable.
>>>
@Jonas1312
Copy link
Author

Jonas1312 commented Jun 14, 2019

Any idea @peterjc123 ?

Edit: found this pytorch/pytorch#21477

@peterjc123
Copy link
Contributor

How did you try to install torchvision?

@Jonas1312
Copy link
Author

Jonas1312 commented Jun 14, 2019

pip3 install https://download.pytorch.org/whl/cu100/torchvision-0.3.0-cp37-cp37m-win_amd64.whl

Edit:
@peterjc123 BTW, I think windows nightly builds haven't been updated to 1.2.0

Click to expand

torch_nightly-1.1.0.dev20190606-cp37-cp37m-win_amd64.whl
torch_nightly-1.1.0.dev20190607-cp35-cp35m-win_amd64.whl
torch_nightly-1.1.0.dev20190607-cp36-cp36m-win_amd64.whl
torch_nightly-1.1.0.dev20190608-cp35-cp35m-win_amd64.whl
torch_nightly-1.1.0.dev20190608-cp36-cp36m-win_amd64.whl
torch_nightly-1.1.0.dev20190608-cp37-cp37m-win_amd64.whl
torch_nightly-1.1.0.dev20190609-cp35-cp35m-win_amd64.whl
torch_nightly-1.1.0.dev20190609-cp36-cp36m-win_amd64.whl
torch_nightly-1.1.0.dev20190609-cp37-cp37m-win_amd64.whl
torch_nightly-1.1.0.dev20190610-cp35-cp35m-win_amd64.whl
torch_nightly-1.1.0.dev20190610-cp36-cp36m-win_amd64.whl
torch_nightly-1.1.0.dev20190610-cp37-cp37m-win_amd64.whl
torch_nightly-1.1.0.dev20190611-cp35-cp35m-win_amd64.whl
torch_nightly-1.1.0.dev20190611-cp36-cp36m-win_amd64.whl
torch_nightly-1.1.0.dev20190611-cp37-cp37m-win_amd64.whl
torch_nightly-1.1.0.dev20190612-cp35-cp35m-win_amd64.whl
torch_nightly-1.1.0.dev20190612-cp36-cp36m-win_amd64.whl
torch_nightly-1.1.0.dev20190612-cp37-cp37m-win_amd64.whl
torch_nightly-1.2.0.dev20190525-cp27-cp27m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190525-cp27-cp27mu-linux_x86_64.whl
torch_nightly-1.2.0.dev20190525-cp35-cp35m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190525-cp36-cp36m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190525-cp37-cp37m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190526-cp27-cp27m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190526-cp27-cp27mu-linux_x86_64.whl
torch_nightly-1.2.0.dev20190526-cp35-cp35m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190526-cp36-cp36m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190526-cp37-cp37m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190527-cp27-cp27mu-linux_x86_64.whl
torch_nightly-1.2.0.dev20190527-cp35-cp35m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190527-cp36-cp36m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190527-cp37-cp37m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190528-cp27-cp27m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190528-cp27-cp27mu-linux_x86_64.whl
torch_nightly-1.2.0.dev20190528-cp35-cp35m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190528-cp36-cp36m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190528-cp37-cp37m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190529-cp27-cp27m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190529-cp27-cp27mu-linux_x86_64.whl
torch_nightly-1.2.0.dev20190529-cp35-cp35m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190529-cp36-cp36m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190529-cp37-cp37m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190530-cp35-cp35m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190530-cp36-cp36m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190530-cp37-cp37m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190531-cp27-cp27m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190531-cp27-cp27mu-linux_x86_64.whl
torch_nightly-1.2.0.dev20190531-cp35-cp35m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190531-cp36-cp36m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190531-cp37-cp37m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190601-cp27-cp27m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190601-cp27-cp27mu-linux_x86_64.whl
torch_nightly-1.2.0.dev20190601-cp35-cp35m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190601-cp36-cp36m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190601-cp37-cp37m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190602-cp27-cp27m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190602-cp27-cp27mu-linux_x86_64.whl
torch_nightly-1.2.0.dev20190602-cp35-cp35m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190602-cp36-cp36m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190602-cp37-cp37m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190603-cp27-cp27m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190603-cp27-cp27mu-linux_x86_64.whl
torch_nightly-1.2.0.dev20190603-cp35-cp35m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190603-cp36-cp36m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190603-cp37-cp37m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190604-cp27-cp27m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190604-cp27-cp27mu-linux_x86_64.whl
torch_nightly-1.2.0.dev20190604-cp35-cp35m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190604-cp36-cp36m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190604-cp37-cp37m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190605-cp27-cp27m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190605-cp27-cp27mu-linux_x86_64.whl
torch_nightly-1.2.0.dev20190605-cp35-cp35m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190605-cp36-cp36m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190605-cp37-cp37m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190606-cp27-cp27m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190606-cp27-cp27mu-linux_x86_64.whl
torch_nightly-1.2.0.dev20190606-cp35-cp35m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190606-cp36-cp36m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190606-cp37-cp37m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190607-cp27-cp27m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190607-cp27-cp27mu-linux_x86_64.whl
torch_nightly-1.2.0.dev20190607-cp35-cp35m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190607-cp36-cp36m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190607-cp37-cp37m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190608-cp27-cp27m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190608-cp27-cp27mu-linux_x86_64.whl
torch_nightly-1.2.0.dev20190608-cp35-cp35m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190608-cp36-cp36m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190608-cp37-cp37m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190609-cp27-cp27m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190609-cp27-cp27mu-linux_x86_64.whl
torch_nightly-1.2.0.dev20190609-cp35-cp35m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190609-cp36-cp36m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190609-cp37-cp37m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190610-cp27-cp27m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190610-cp27-cp27mu-linux_x86_64.whl
torch_nightly-1.2.0.dev20190610-cp35-cp35m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190610-cp36-cp36m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190610-cp37-cp37m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190611-cp27-cp27m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190611-cp27-cp27mu-linux_x86_64.whl
torch_nightly-1.2.0.dev20190611-cp35-cp35m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190611-cp36-cp36m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190611-cp37-cp37m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190612-cp27-cp27m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190612-cp27-cp27mu-linux_x86_64.whl
torch_nightly-1.2.0.dev20190612-cp35-cp35m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190612-cp36-cp36m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190612-cp37-cp37m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190613-cp27-cp27m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190613-cp27-cp27mu-linux_x86_64.whl
torch_nightly-1.2.0.dev20190613-cp35-cp35m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190613-cp36-cp36m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190613-cp37-cp37m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190614-cp27-cp27m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190614-cp27-cp27mu-linux_x86_64.whl
torch_nightly-1.2.0.dev20190614-cp35-cp35m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190614-cp36-cp36m-linux_x86_64.whl
torch_nightly-1.2.0.dev20190614-cp37-cp37m-linux_x86_64.whl

@peterjc123
Copy link
Contributor

@peterjc123 BTW, I think windows nightly builds haven't been updated to 1.2.0

It's nothing special. I'll need to update that in the pytorch/builder repo.

Would you please use something like lucasg/Dependencies to find the missing DLLs?

@zemelLeong
Copy link

zemelLeong commented Jun 15, 2019

I have same problem
I install torchvision with pip install torchvision

import torchvision
Traceback (most recent call last):
File "", line 1, in
File "G:\Python36\lib\site-packages\torchvision_init_.py", line 1, in
from torchvision import models
File "G:\Python36\lib\site-packages\torchvision\models_init_.py", line 11, in
from . import detection
File "G:\Python36\lib\site-packages\torchvision\models\detection_init_.py", line 1, in
from .faster_rcnn import *
File "G:\Python36\lib\site-packages\torchvision\models\detection\faster_rcnn.py", line 7, in
from torchvision.ops import misc as misc_nn_ops
File "G:\Python36\lib\site-packages\torchvision\ops_init_.py", line 1, in
from .boxes import nms, box_iou
File "G:\Python36\lib\site-packages\torchvision\ops\boxes.py", line 2, in
from torchvision import _C
ImportError: DLL load failed: 找不到指定的模块。

@peterjc123
Copy link
Contributor

I think I know the reason. It's because caffe2 and torch get merged now, so one DLL could not be found anymore. You'll have to rebuild torchvision to fix this.

@Jonas1312
Copy link
Author

@peterjc123
I'm not sure if it's exactly what you wanted: Capture

@peterjc123
Copy link
Contributor

@Jonas1312 Not needed anymore. See what I said in the last post.

@zemelLeong
Copy link

image

I fixed by this.
https://pytorch.org/get-started/locally/

@peterjc123
Copy link
Contributor

@zemelLeong Yes, installing stable version is also a workground if you don't use pytorch-nightly.

@newmluser
Copy link

can you please suggest me what is the stable version

@newmluser
Copy link

Thank you. I used conda ..

@zemelLeong
Copy link

cuda10:conda install pytorch torchvision cudatoolkit=10.0 -c pytorch
cuda9:conda install pytorch torchvision cudatoolkit=9.0 -c pytorch
none cuda:conda install pytorch-cpu torchvision-cpu -c pytorch

@plammens
Copy link

plammens commented Jul 3, 2019

I think I know the reason. It's because caffe2 and torch get merged now, so one DLL could not be found anymore. You'll have to rebuild torchvision to fix this.

So we have to build the latest torchvision from source, as in python setup.py install from master?

@fmassa
Copy link
Member

fmassa commented Jul 3, 2019

@plammens yes, that seems to be the case. But we might need to make some modifications in torchvision so that this works, see #1075

@anemes
Copy link

anemes commented Aug 10, 2019

I am encountering the same issue with

conda install pytorch torchvision cudatoolkit=10.0 -c pytorch

when I run: from torchvision import datasets, transforms

C:\ProgramData\Anaconda3\lib\site-packages\torchvision\ops\boxes.py in <module>()
      1 import torch
----> 2 from torchvision import _C
      3 
      4 
      5 def nms(boxes, scores, iou_threshold):

ImportError: DLL load failed: The specified module could not be found.

@peterjc123
Copy link
Contributor

@anemes Yes, that's because we didn't upload torchvision 0.4.0 for Windows. I'll tell you when it's ready.

@fmassa
Copy link
Member

fmassa commented Aug 12, 2019

@peterjc123 now that the new Windows binaries are available, can we close this?

@peterjc123
Copy link
Contributor

Yes, please.

@colin-byrneireland
Copy link

conda install pytorch torchvision cudatoolkit=10.0 -c pytorch worked for me.
I'm using latest version on anconda for windows, thks for th workaround.

@AlexLabram
Copy link

AlexLabram commented Oct 1, 2019

Contra @fmassa's comment, I'm not seeing any windows binaries for torchvision 0.4.0. As of time of posting, the webpage has wheels for macosx and manylinux only, not win_amd64 (my system), and pip is not having any more luck. So I'm still SOL when it comes to using torchvision.

Apologies if this bug report is the wrong place to raise this; I'm not sure what the etiquette is for dev-ops issues.

Edit: Created new issue for this, since closed issues don't appear on the live issues list.

@fmassa
Copy link
Member

fmassa commented Oct 1, 2019

@AlexLabram wheels are available for windows according to the comments in #1399

@AlexTS1980
Copy link

AlexTS1980 commented Feb 2, 2021

Got this problem with pytorch 1.7.1 and torchvision 0.4.1 and 0.3.0.

@mravunni
Copy link

same issue Got this problem with pytorch 1.7.1 and torchvision 0.4.1 and 0.3.0.

from torchvision import _C as C
ImportError: DLL load failed: The specified module could not be found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests