Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I cant solve the error: AttributeError: module 'torch._C' has no attribute '_cuda_setDevice' in python (anaconda)

Tags:

pytorch

I´m trying to run a project I got on github: https://github.com/ranahanocka/MeshCNN

First of all, I created an environment in anaconda with .yml files that come in ranahanocka's project, then I got errors related to the CUDA installation.

To solve it, I followed this tutorial to install CUDA and I got rid of that error:

conda install -c anaconda cudatoolkit=10.1

But now I get these errors:

In train.py:

In base_option.py:

And in __init__.py:

I don't know how to fix it, I have read several forums but no solution has helped me. I have tried installing this:

pip install torch===1.9.0+cu111 torchvision===0.10.0+cu111 torchaudio===0.9.0 -f https://download.pytorch.org/whl/cu111/torch_stable.html

But in the middle of downloading I get these errors:

I don't know what can happen, besides, I don't understand very well how CUDA works and its dependencies, so I'm sorry if I don't provide the necessary information.

like image 982
paulaHb03 Avatar asked Jul 01 '26 11:07

paulaHb03


1 Answers

It's likely that torch or cuda is not properly installed. In my case, someone has updated the Cuda version so I faced a similar issue.

In the command line you can check if you have Cuda available or not;

python

import torch

print(torch.cuda.is_available())

It should return True if not then you need to install Cuda or torch.

Check which Cuda version the GPU has:

nvidia-smi

I used this command to install the cuda and torch in my environment which solved my issue;

conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch-nightly -c nvidia
like image 160
ashokchhetri Avatar answered Jul 05 '26 16:07

ashokchhetri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!