import torch OSError: [WinError 127]
Asked Answered
S

2

4

I'm trying to install torch-gpu. I have installed cuda 11.1 and installed torch via the command pip3 install torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio===0.8.1 -f https://download.pytorch.org/whl/torch_stable.html

It is so stupid but during the importing I have the following error OSError: [WinError 127] Error loading "C:\Users\User\AppData\Roaming\Python\Python38\site-packages\torch\lib\c10_cuda.dll" or one of its dependencies..

c10_cuda.dll exists in that directory, I spent several days and still can't solve it. I need torch-gpu and that's the point of using that possibility, please, do not comment 'install torch-cpu'.

Shilohshim answered 16/4, 2021 at 9:24 Comment(1)
Other users might also find this questions useful: #62359675Dustpan
S
4

Answering the question myself

To install torch-gpu one should:

  1. check the latest (or not) versions and compatible cuda version: https://pytorch.org/get-started/locally/, at this moment it is 11.1.

  2. download and install cuda of the established version in 1) step (https://developer.nvidia.com/cuda-toolkit-archive). That depends on the gpu, if any problems you may download older versions or maybe you have it installed? then you can check version manually in the command line: nvcc --version.

  3. install torch using commands as found in the 1) step (for instance conda install pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch -c conda-forge)

  4. check the installation success as import torch torch.cuda.is_available().

In my case I had to delete previously installed torch pip uninstall torch and use conda clean -a for installation to end successfully.

Shilohshim answered 16/4, 2021 at 19:29 Comment(1)
I faced a similar problem and had to switch from installing with pip to conda as well...Alidus
A
0

Posting this as I figured it might help someone else, I experienced the same issue, and it turned out that I was importing a module before PyTorch (PySpin is the one I used), and it caused the same error you got.

Note - I use PIP and not Conda, on Windows.

This caused the missing DLL error, even though it existed.

import PySpin
import torch

this fixed the missing DLL error

import torch
import PySpin
Acro answered 30/5, 2023 at 23:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.