4

I have NVidia 1080TI, Ubuntu x64, and Python 3.6.9 installed. I was trying to launch PyTorch with command

import torch print(torch.cuda.is_available) 

and expected to see 'True' but met the error:

AttributeError: module 'torch' has no attribute 'cuda' 

I tried to update PyTorch and install the last version 1.7.0 with CUDA 11.0 support. After that, I noticed some version discrepancies. nvidia-smi shows CUDA version 11.0 but nvcc -V shows 9.1. Also, I used cat /usr/local/cuda/version.txt to check CUDA version but got the error: cat: /usr/local/cuda/version.txt: No such file or directory I installed CUDA driver 450.33 after fully nvidia purging but the error remains and nvcc -V still shows 9.1 version (after reboot also).
One more option I addressed to is conda installation but it didn't help. What I can do to resolve the problem?

5
  • 1
    The nvcc version discrepancy is a red herring. Pytorch does not use the systems CUDA at all. When installed with conda or pip it ships with its own copy of CUDA. You don't even need to install CUDA on your system to use pytorch with CUDA support. nvidia-smi just displays the latest version of CUDA compatible with your graphics drivers, the version displayed here is purely a function of your graphics driver and doesn't imply anything about the CUDA toolkit on your system. Commented Nov 28, 2020 at 4:24
  • What command did you use to install pytorch on your system? For the latest you should be using conda install pytorch torchvision torchaudio cudatoolkit=11.0 -c pytorch (based on widget from pytorch.org). Commented Nov 28, 2020 at 4:27
  • @jodag, thanks for the answer! It clarifies vision of a problem. However, I still don't understand why the CUDA copy does not support every pytorch version I try to install. I attempted to finish installation successfully with both pip and conda but nothing helps. :( Commented Nov 28, 2020 at 5:27
  • @jodag I used your submitted command also but basically used pip for installation. Commented Nov 28, 2020 at 5:29
  • I would recommend trying again starting from a clean virtualenv or conda environment. Based on what you put in your question I don't see any reason your system is incompatible with pytorch w/ cuda. Commented Nov 28, 2020 at 5:35

1 Answer 1

7

As a result, I had a file named torch.py in my home directory. After the renaming problem was solved.
Thanks. Maybe my answer will be helpful to someone.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.