Cannot import torch on jupyter notebook

When I try to import troch on Jupyter notebook, I receive this error

OSError                                   Traceback (most recent call last)
<ipython-input-2-eb42ca6e4af3> in <module>
----> 1 import torch

C:\Users\Al Badr\Anaconda3\lib\site-packages\torch\__init__.py in <module>
     79     dlls = glob.glob(os.path.join(th_dll_path, '*.dll'))
     80     for dll in dlls:
---> 81         ctypes.CDLL(dll)
     82 
     83 

C:\Users\Al Badr\Anaconda3\lib\ctypes\__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error)
    362 
    363         if handle is None:
--> 364             self._handle = _dlopen(self._name, mode)
    365         else:
    366             self._handle = handle

OSError: [WinError 126] The specified module could not be found

This error seems to be raise a few times recently, here and here.

CC @peterjc123 as it seems to be Windows-specific.

1 Like

This is most probably because you are using a CUDA variant of PyTorch on a system that doesn’t have GPU driver installed. That is to say, if you don’t have a Nvidia GPU card, please install the cpu-only package according to the commands on https://pytorch.org.

# Conda
conda install pytorch torchvision cpuonly -c pytorch
# Pip
pip install torch==1.5.0+cpu torchvision==0.6.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
3 Likes

but in script say: cpu, if I work with CUDA