Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CUDA device error "module 'torch._C' has no attribute '_cuda_setDevice'" when running test.py #26

Open
FoxTrotte opened this issue Jul 17, 2022 · 4 comments

Comments

@FoxTrotte
Copy link

Hi !

Trying out test.py results in the following error:

Traceback (most recent call last): File "test.py", line 26, in <module> torch.cuda.set_device(0) File "C:\Users\natha\anaconda3\envs\ColorVid\lib\site-packages\torch\cuda\__init__.py", line 311, in set_device torch._C._cuda_setDevice(device) AttributeError: module 'torch._C' has no attribute '_cuda_setDevice'

I tried installing pytorch manually using their tool https://pytorch.org/get-started/locally/ (with CUDA 11.6) but that doesn't resolve the issue.

Can someone help me understand what is going on ? Thanks !!

@HolyMountains
Copy link

I have the same Issue! Do you found a solution?

@xixifusi1984
Copy link

I have the same Issue! Did some body get the key to fix it?

@UpscaleHistory
Copy link

UpscaleHistory commented Dec 2, 2022

It took me three days but I found a fix for my computer:
Downgrade python to 3.6, and install pytorch 1.6.0 with:
pip install torch===1.6.0 torchvision===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html

If you open the colab demo, you will see "# seems to be a colab bug, need to install previous version for pytorch".
Then the notebook proceeds to install torch 1.6.0 with pip install torch===1.6.0 torchvision===0.7.0.
It's the same bug with my local machine, except that I can't install torch 1.6.0 on my computer using the same code.
When use the same code with conda, I get "ERROR: No matching distribution found for torch==1.6.0"
I think it's because colab is using Tesla T4, where as my computer is rtx 2070.

@UpscaleHistory
Copy link

UpscaleHistory commented Dec 2, 2022

If you are trying to run the code locally with anaconda or connect to a local runtime with colab, you might need to change
pip install torch==1.6.0 torchvision==0.7.0
to
pip install torch===1.6.0 torchvision===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
depending on your gpu.
The first code works with colab's T4, but not my rtx 2070; the second code works for both.
I think colab A100 also has some kind of issues, but it's related to cuda.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants