0

I'm trying to install PyTorch into my Conda environment using Anaconda Prompt(Miniconda3) but running into a similar issue seen here

First, I created my Conda environment:

conda create --name token python=3.

Next, I activate my environment and download PyTorch without fail using the following:

activate token
conda install pytorch pytorch-cuda=11.6 -c pytorch -c nvidia

Next, I go into my python console and try to import torch but find the following error:

python
>>>import torch
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\.conda\envs\token\lib\site-packages\torch\__init__.py", line 139, in <module>
    raise err
OSError: [WinError 126] The specified module could not be found. Error loading "C:\Users\.conda\envs\token\lib\site-packages\torch\lib\shm.dll" or one of its dependencies.

When running the list command:

(base) C:\Users>conda list -n token pytorch
# packages in environment at C:\Users\.conda\envs\token:
#
# Name                    Version                   Build  Channel
pytorch                   1.13.0          py3.10_cuda11.6_cudnn8_0    pytorch
pytorch-cuda              11.6                 h867d48c_0    pytorch
pytorch-mutex             1.0                        cuda    pytorch

Is there a way to check which dependencies are missing or know why PyTorch is not being recognised?

Lui Hellesoe
  • 185
  • 1
  • 10
  • Try using a different (older?) python version. – Caridorc Dec 11 '22 at 01:45
  • I tried using python 3.9 but ran into the same issue. PyTorch website says it supports Python 3.7-3.9 for Windows OS. I just tried 3.10 out of curiosity. https://pytorch.org/get-started/locally/#:~:text=10%20Enterprise%20machine-,Python,Chocolatey,-Python%20website – Lui Hellesoe Dec 11 '22 at 01:47
  • 1
    relevant question: https://stackoverflow.com/questions/74594256/pytorch-error-loading-lib-site-packages-torch-lib-shm-dll-or-one-of-its-depen – Caridorc Dec 11 '22 at 01:50
  • also from the website: Please ensure that you have met the prerequisites below (e.g., numpy) – Caridorc Dec 11 '22 at 01:50
  • Thanks, I saw that question previously but linked it to my question. Their solution to the problem seemed to be totally random. – Lui Hellesoe Dec 11 '22 at 01:52
  • yes, I feel for you because I also suffered when trying to install these packages. From the pytorch website: It is recommended that you use Python 3.6, 3.7 or 3.8, which can be installed via any of the mechanisms above . – Caridorc Dec 11 '22 at 01:54
  • 2
    I suggest making new enviroments, installing dependecies and trying again for each version. Also try a cpu only install and/or check that the cuda version you ask for is right – Caridorc Dec 11 '22 at 01:55
  • @Caridorc website sounds outdated - PyTorch is currently building for v3.7-3.10. Unlikely a Python version problem, rather the `pytorch` Conda package sounds suspect. Given there's another recent question, I'd maybe also try using the previous version of torch (`pytorch=1.12`). – merv Dec 11 '22 at 15:55
  • 1
    Please add to the question the output of `conda list -n token pytorch` – merv Dec 11 '22 at 16:07

0 Answers0