skip to Main Content

I am new to programming and working with deep learning networks, so maybe I’m just stupid, but I can’t get my PyTorch to work. Not long ago, it did without problem, but then I tried to fix CUDA for GPU acceleration (which did not work), and ever since, my Torch has refused to work. I run the programs in a virtual environment (venv.) in VS Code with Python version 3.11.9, but when I try to verify my Torch with.

import torch

print(torch.__version__)

I only receive the error that:

File "c:PythonTesttorch_test.py", line 1, in <module>
    import torch
  File "C:PythonTest.venvLibsite-packagestorch__init__.py", line 148, in <module>
    raise err
OSError: [WinError 126] The specified module cannot be found. Error loading "C:PythonTest.venvLibsite-packagestorchlibfbgemm.dll" or one of its dependencies.
PS C:PythonTest>

I have tried to install Torch a million times by now, both inside and outside the venv with pip and pip3 in both the VS Codes terminal and in the command prompt. But everytime I get back, the "Requirement already satisfied". Yet still, the Torch is not working is absent.

When looking through stackoverflow, I find mostly people that have used Conda environments, which I am not familiar with. So if there is a solution without Conda, or must I go with that environment instead? Thanks beforehand for any help possible!

2

Answers


  1. Chosen as BEST ANSWER

    Thanks for the help and as user1188867 commented it probably has to do with the specific pytorch version 2.4.0

    So you could run an older version or you can download "visual studio c/c++ community 2022" to fix the dependency error.

    Here is the video which showed me: https://www.youtube.com/watch?v=-ky896Qp1k8


  2. Switch to old version of pytorch. That should work

    pip uninstall pytorch
    pip install torch==2.3.1

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search