Vision: ImportError: DLL load failed on Windows

Created on 14 Jun 2019  ·  23Comments  ·  Source: pytorch/vision

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.
>>>
help wanted windows

Most helpful comment

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

All 23 comments

Any idea @peterjc123 ?

Edit: found this https://github.com/pytorch/pytorch/issues/21477

How did you try to install torchvision?

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 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?

I have same problem
I install torchvision with pip install torchvision

import torchvision
Traceback (most recent call last):
File "", line 1, in
File "G:Python36libsite-packagestorchvision__init__.py", line 1, in
from torchvision import models
File "G:Python36libsite-packagestorchvisionmodels__init__.py", line 11, in
from . import detection
File "G:Python36libsite-packagestorchvisionmodelsdetection__init__.py", line 1, in
from .faster_rcnn import *
File "G:Python36libsite-packagestorchvisionmodelsdetectionfaster_rcnn.py", line 7, in
from torchvision.ops import misc as misc_nn_ops
File "G:Python36libsite-packagestorchvisionops__init__.py", line 1, in
from .boxes import nms, box_iou
File "G:Python36libsite-packagestorchvisionopsboxes.py", line 2, in
from torchvision import _C
ImportError: DLL load failed: 找不到指定的模块。

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.

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

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

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

can you please suggest me what is the stable version

image
pip3 install https://download.pytorch.org/whl/cu100/torch-1.1.0-cp36-cp36m-win_amd64.whl
pip3 install https://download.pytorch.org/whl/cu100/torchvision-0.3.0-cp36-cp36m-win_amd64.whl
https://pytorch.org/get-started/locally/

Thank you. I used conda ..

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

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?

@plammens yes, that seems to be the case. But we might need to make some modifications in torchvision so that this works, see https://github.com/pytorch/vision/issues/1075

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.

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

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

Yes, please.

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.

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.

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

a-maci picture a-maci  ·  3Comments

feiyangsuo picture feiyangsuo  ·  3Comments

Linardos picture Linardos  ·  4Comments

ArashJavan picture ArashJavan  ·  3Comments

zhang-zhenyu picture zhang-zhenyu  ·  3Comments