简体   繁体   中英

Incompletable PyTorch with any CUDA version (module 'torch' has no attribute 'cuda')

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?

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.

I had the same problem and reinstalled it several times, only to find that my script was named torch.py

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM