Why doesn't torch see сuda? - pytorch

i have problem with torch and cuda.
torch.version.__version__ gives "1.5.1+cu101"
torch.version.cuda gives "10.1"
torch.backends.cudnn.version() gives "7603"
But torch.cuda.is_avaliable() gives False. What can be wrong?
Parameters of my system:
Linux-x86_64 (Ubuntu 20.04)
GeForce GTX 1050
NVIDIA Driver Version: 460.67

Related

Model.to(‘cuda:0’) gets stuck

I'm using:
python 3.8.10
torch 1.11.0+cu113
And:
NVIDIA-SMI 470.103.01 Driver Version: 470.103.01 CUDA Version: 11.4
Ubuntu 20.04.4 LTS
I can run the following commands via jupyter notebook with not error:
out = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
mX = mX.to(out)
When I try to run those commands from pycharm (with same virtual environment), nothing happens and it gets stuck.
I looked here:
Pytorch .to('cuda') or .cuda() doesn't work and just get stuck
and didn't found any answer.
Why I can use to('cuda') from jupyter notebook and not from pycharm ?
What do I need to do in order to run from pycharm ?

how to use GTX 1660 supper GPU in tensorflow?

Edit:
it worked when I reinstall tensorflow.
I have GTX 1660 supper GPU and I installed the latest version of CUDA, cuDNN and the Driver.
when I import tensorflow as tf I get this message.
2021-05-18 12:19:45.541654: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudart64_110.dll
but when I print(tf.config.list_physical_devices('GPU'))
the output is empty[]
From comments
I have reinstalled tensorflow when I Installed CUDA and cuDNN then
it's worked. (paraphrased from Osama Adel)

Pytorch won't run on deep-learning-vm "Found no NVIDIA driver on your system"

I did create a new conda environment to run my code from. But I get the following error:
AssertionError:
Found no NVIDIA driver on your system. Please check that you
have an NVIDIA GPU and installed a driver from
http://www.nvidia.com/Download/index.aspx
> /opt/conda/envs/ml/lib/python3.8/site-packages/torch/cuda/__init__.py(51)_check_driver()
49 if torch._C._cuda_getDriverVersion() == 0:
50 # found no NVIDIA driver on the system
---> 51 raise AssertionError("""
52 Found no NVIDIA driver on your system. Please check that you
53 have an NVIDIA GPU and installed a driver from
Any help very much appreciated!

Tensorflow Cuda Error failed to get device attribute 13 for device 0

I am facing problem while training neural networks using tensorflow-keras. I am getting this error:
F tensorflow/stream_executor/lib/statusor.cc:34] Attempting to fetch
value instead of handling error Internal: failed to get device
attribute 13 for device 0: CUDA_ERROR_UNKNOWN: unknown error
I was getting this error initially. Then I referred to the solution in failed-to-get-device-attribute-13-for-device-0. I updated the graphics driver. This worked for some 3-4 runs and now I am getting the same error again.
Following are the details of my environment:
Python 3.7 (Anaconda)
Tensorflow 2.1
Nvidia GeForce RTX 2060, 6GB Graphics
Windows 10 Version 1809
Well in my case limiting the GPU memory worked.
Add the following code segment at the beginning of your code:
import tensorflow as tf
gpus = tf.config.experimental.list_physical_devices('GPU')
tf.config.experimental.set_memory_growth(gpus[0], True)

PyTorch and CUDA driver

I have CUDA 9.2 installed. For example:
(base) c:\>nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Wed_Apr_11_23:16:30_Central_Daylight_Time_2018
Cuda compilation tools, release 9.2, V9.2.88
I installed PyTorch on Windows 10 using:
conda install pytorch cuda92 -c pytorch
pip3 install torchvision
I ran the test script:
(base) c:\>python
Python 3.6.5 |Anaconda custom (64-bit)| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from __future__ import print_function
>>> import torch
>>> x = torch.rand(5, 3)
>>> print(x)
tensor([[0.7041, 0.5685, 0.4036],
[0.3089, 0.5286, 0.3245],
[0.3504, 0.8638, 0.1118],
[0.6517, 0.9209, 0.6801],
[0.0315, 0.1923, 0.8720]])
>>> quit()
So for, so good. Then I ran:
(base) c:\>python
Python 3.6.5 |Anaconda custom (64-bit)| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.cuda.is_available()
False
>>>
Why did PyTorch say CUDA was not available?
The GPU is a compute capability 3.0 Quadro K3000M:
(base) C:\Program Files\NVIDIA Corporation\NVSMI>nvidia-smi.exe
Mon Oct 01 16:36:47 2018
NVIDIA-SMI 385.54 Driver Version: 385.54
-------------------------------+----------------------+----------------------
GPU Name TCC/WDDM | Bus-Id Disp.A | Volatile Uncorr.
ECC Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M.
0 Quadro K3000M WDDM | 00000000:01:00.0 Off |
N/A N/A 35C P0 N/A / N/A | 29MiB / 2048MiB | 0% Default
Ever since https://github.com/pytorch/pytorch/releases/tag/v0.3.1, PyTorch binary releases had removed support for old GPUs' with CUDA capability 3.0. According to https://en.wikipedia.org/wiki/CUDA, the compute capability of Quadro K3000M is 3.0.
Therefore, you might have to build pytorch from source or try other packages. Please refer to this thread for more information -- https://discuss.pytorch.org/t/pytorch-no-longer-supports-this-gpu-because-it-is-too-old/13803.
PyTorch official call for using CUDA 9.0 and I would suggest the same. In other cases, there are sometimes build issues which leads to 'CUDA not detected'.So, when using PyTorch its best to use CUDA 9.0 and CuDnn 7. I'll add a link where you can easily install Cuda 9.0 and CuDnn 7.
https://yangcha.github.io/CUDA90/
I had a similar problem, you have to check on NVIDIA control panel that your card is selected by default.

Resources