"import torch" giving error "from torch._C import *, DLL load failed: The specified module could not be found"

Trisha S. picture Trisha S. · Mar 21, 2018 · Viewed 23.9k times · Source

I am currently using Python 3.5.5 on Anaconda and I am unable to import torch. It is giving me the following error in Spyder:

Python 3.5.5 |Anaconda, Inc.| (default, Mar 12 2018, 17:44:09) [MSC v.1900 
64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.

IPython 6.2.1 -- An enhanced Interactive Python.

import torch
Traceback (most recent call last):

  File "<ipython-input-1-eb42ca6e4af3>", line 1, in <module>
    import torch

  File "C:\Users\trish\Anaconda3\envs\virtual_platform\lib\site-
  packages\torch\__init__.py", line 76, in <module>
    from torch._C import *

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

Many suggestions on the internet say that the working directory should not be the same directory that the torch package is in, however I've manually set my working directory to C:/Users/trish/Downloads, and I am getting the same error.

Also I've already tried the following: reinstalling Anaconda and all packages from scratch, and I've ensured there is no duplicate "torch" folder in my directory.

Pls help! Thank you!

Answer

mayank sati picture mayank sati · Jul 2, 2018

I had this similar problem in windows 10...

Solution:

  • Download win-64/intel-openmp-2018.0.0-8.tar.bz2 from https://anaconda.org/anaconda/intel-openmp/files

  • Extract it and put the dll files in Library\bin into
    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin

  • Make sure your cuda directory is added to your %PATH% environment variable