Unable to import torch

I have installed pytorch and torchvision via annaconda, I can see torchvision 0.6.0 using “conda list” command and I can see torch 1.5.0 under “pip list”.
I can find these 2 under C:…\Anaconda3\Lib\site-packages
But when I tried to import torch, the following error occurs.

Traceback (most recent call last):
File “.\inference_combined_all.py”, line 2, in
import torch
File “C:\Users\qizha\Anaconda3\lib\site-packages\torch_init_.py”, line 81, in
File “C:\Users\qizha\Anaconda3\lib\ctypes_init_.py”, line 364, in init
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found

Does anyone have any thoughts on this? Thank you!

cc @peterjc123 do you have an idea where this could be coming from?

This error seems to be raised, if a PyTorch version with CUDA support was installed on a CPU-only machine, as described here by @peterjc123.

1 Like