Pytorch CUDA not available with correct versions - python

I really need help setting up CUDA for development with Pytorch. I have a Nvidia graphics card and am using Python 3.8. To install pytorch with the correct CUDA integration I ran conda install pytorch torchvision cudatoolkit=10.1 -c python. The problem is that torch.cuda.is_available() always returns False.
Can anyone help me here?
I the following are my versionings:
nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Sun_Jul_28_19:07:16_PDT_2019
Cuda compilation tools, release 10.1, V10.1.243
nvidia-smi
NVIDIA-SMI 510.47.03 Driver Version: 510.47.03 CUDA Version: 11.6

As in the PyTorch website, install with conda install pytorch torchvision cudatoolkit=11.3 -c pytorch or conda install pytorch torchvision cudatoolkit=11.6 -c pytorch

Related

raise AssertionError("Torch not compiled with CUDA enabled")

I Try to install Pytorch on my Windows 10 system.
I wanna Use a anaconda env.
i followed the instruction 'https://pytorch.org/' stable 1.12.1 && Conda && Python && cuda 11.6
(conda install pytorch torchvision torchaudio cudatoolkit=11.6 -c pytorch -c conda-forge)
Before I installed conda 11.6, when i enter nvcc --version in the console i get the output :
NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Tue_Mar__8_18:36:24_Pacific_Standard_Time_2022
Cuda compilation tools, release 11.6, V11.6.124
Build cuda_11.6.r11.6/compiler.31057947_0
I also installed conda forge following this instruction https://conda-forge.org/docs/user/introduction.html
but now, if i try to run print(torch.cuda.is_available()) 'false' is outprinted
If i run conda list i get this (just some):
pytorch 1.10.2 py3.9_cpu_0 pytorch
pytorch 1.10.2 py3.9_cpu_0 pytorch
torchaudio 0.10.2 py39_cpu [cpuonly] pytorch
torchvision 0.11.3 py39_cpu [cpuonly] pytorch
My GPU is an RTX 2070 Super. Can anyone help me?
In my case i try to change the environment so i create new environment using conda then i download pytorch again from pytorch.org the compatible version for my GPU and then i tap the cmd of training and it works. hope it helps you

pytorch CUDA version vs. Nvidia CUDA version

Till Apr26th, 2022, CUDA has updated to version 11.6, which can be installed by Nvidia Instruction:
wget https://developer.download.nvidia.com/compute/cuda/11.6.2/local_installers/cuda_11.6.2_510.47.03_linux.run
sudo sh cuda_11.6.2_510.47.03_linux.run
I guess the version of cudatoolkit will also be 11.6
However, there is no version of pytorch that matches CUDA11.6.
On the website of pytorch, the newest CUDA version is 11.3, pytorch version will be 1.11.0(stable)
conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch
So if I used CUDA11.6 and pytorch1.11.0 with cudatoolkit=11.3, will it perform normally?
and if there is any difference between Nvidia Instruction and conda method below?
conda install cuda -c nvidia
Best regards!
It should be fine. Otherwise, I saw here that you can build it from the source (I have python=3.8.13) build instructions
pip install torch --pre --extra-index-url https://download.pytorch.org/whl/nightly/cu116

RuntimeError: No CUDA GPUs are available

I want to train a gpt2 model in my laptop and I have a GPU in it and my os is windows , but I always got this error in python:
torch._C._cuda_init()
RuntimeError: No CUDA GPUs are available
when I tried to check the availability of GPU in the python console, I got true:
import torch
torch.cuda.is_available()
Out[4]: True
but I can't get the version by
nvcc version
#or nvcc --version
NameError: name 'nvcc' is not defined
I use this command to install CUDA
conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch
What can I do to make the GPU available for python?
In my case the problem was that the CUDA drivers that I was trying to install, didn't support my GPU model. In your case, please check which CUDA driver supports your GPU model. You are now installing 10.2. In my case CUDA 11.0 and 11.2 supported my GPU model but not 11.3 which I was trying to install.
If you got the same error after a while, which can happen if you run a cloud vm which hardware can be updated automatically, here is how to solve it:
Remove CUDA drivers
sudo apt-get remove --purge nvidia*
Then reinstall the drivers as follows. Note! in this case I have debian distro on x64 system.
wget https://developer.download.nvidia.com/compute/cuda/repos/debian11/x86_64/cuda-keyring_1.0-1_all.deb
sudo dpkg -i cuda-keyring_1.0-1_all.deb
sudo add-apt-repository contrib
sudo apt-get update
sudo apt-get -y install cuda
Get the correct commands that works for your distro and system from the link: https://developer.nvidia.com/cuda-downloads?target_os=Linux
Good luck!
Make sure that you have CUDA installed. For me, I installed it from the NVIDIA directory: https://developer.nvidia.com/cuda-downloads

My GPUs are not visible with tensorflow-gpu 2.1.0 and CUDA 10.1

I am working on Windows 10.
I have installed tensorflow-gpu 2.1.0 and checked that it was in the pip list:
My python version is 3.7 and CUDA version is 10.1:
Here is what the nvidia-smi command outpouts:
As you can see I have 2 GPU's installed and visible with the nvidia command but when I use the command 'tf.config.get_visible_devices()' on my notebook I can only see the CPU:
Any ideas on how to solve this problem please?
Tensorflow 2.1.0 is compatible with CUDA 10.1. Use command nvcc --version to verify which CUDA you have installed, and redo the setup if necessary.

"1 Physical GPUs, 0 Logical GPU " when i train the model the gpu is not working

ubntu version 18.04
nvidia Smia 440.1.0
cuda 10.2
GTx 960
tensorboard 2.3.0
tensorboard-plugin-wit 1.7.0
tensorflow-estimator 2.3.0
tensorflow-gpu 2.3.0
My gpu is not working or you can say its installed but when i run the model it's not allocating to the gpu
here the image
run this code to see if tensorflow is detecting your gpu. If number of gpus is listed as 0 then it is not detecting it. You need to have Cuda 10.1 on your systen and cuDNN v7.6.5. In that case if you are using Anaconda open the conda prompt and run conda install cuDNN=7.6.5. You may also have to install CUDA Toolkit 10.1. If you installed tensorflow with pip then you have to download and install CUDA Toolkit 10.1 and modify your environment variables etc. I found the easiest solution is to install tensorflow using Conda because it installs both the toolkit and cudnn automatically. IF you are using Anaconda then open the conda prompt and run conda fistall --upgrade tensorflow
import tensorflow as tf
from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())
print(tf.__version__)
print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))
tf.test.is_gpu_available()
!python --version

Categories