getting tensorflow to run on GPU - python

I've been trying to get this to work forever and still no luck
I have:
GTX 1050 Ti (on Lenovo Legion laptop)
the laptop also has an Intel UHD Graphics 630 (i'm not sure if maybe this is interfering?)
Anaconda
Visual Studio
Python 3.9.13
CUDA 11.2
cuDNN 8.1
I added these to the PATH:
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\bin
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2\libnvvp
finally I installed tensorflow and created its own environment
and I still can't get it to read my GPU
basically followed https://www.youtube.com/watch?v=hHWkvEcDBO0&t=295s
AND I'm still having no luck.
from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())
yields only information on the CPU
Can anyone please help?

You can upgrade tensorflow to 2.0. It should solve your problem.

Check your tensorflow version and compatability with GPU, update your GPU drivers. CUDA 9/10 would do the job.
follow the official tensorflow link:
https://www.tensorflow.org/install/pip#windows-native_1
Do all the steps in the same environment in anaconda.

Related

Tensorflow crashes when ask it to fit model

Tensorflow on gpu new to me, first naive question is, am I correct in assuming that I can use a gpu (nv gtx 1660ti) to run tensorflow ml operations, while it simultaneously runs my monitor? Only have one gpu card in my pc, assume it can do both at the same time or do I require a dedicated gpu for tensorflow only, that is not connected to any monitor?
All on ubuntu 21.10, have set up nvidia-toolkit, cudnn, tensorflow, tensorflow-gpu in a conda env, all appears to work fine: 1 gpu visible, built with cudnn 11.6.r11.6, tf version 2.8.0, python version 3.7.10 all in conda env running on a jupyter notebook. All seems to run fine until I attempt to train a model and then I get this error message:
2022-03-19 04:42:48.005029: I tensorflow/stream_executor/cuda/cuda_dnn.cc:368] Loaded cuDNN version 8302
and then the kernel just locks up and crashes. BTW the code worked prior to installing gpu, when it simply used cpu. Is this simply a version mismatch somewhere between python, tensorflow, tensorflow-gpu, cudnn versions or something more sinister? Thx. J.
am I correct in assuming that I can use a GPU (nv gtx 1660ti) to run
tensorflow ml operations, while it simultaneously runs my monitor?
Yes, you can check with nvidia-smi on ubuntu to see how much free memory you have or which processes are using GPU.
Only have one GPU card in my pc, assume it can do both at the same?
time
Yes, It can. Most people do the same, a training process on GPU is just similar to running a game, (but more memory hungry)
About the problem:
install based on this version table.
check your driver version with nvidia-smi But, for true Cuda version check this nvcc -V ( the Cuda version in nvidia-smi is actually max supported Cuda version. )
just install pip install tensorflow-gpu this will also install keras for you.
check if tensorflow has access to GPU as follow:
import tensorflow as tf
tf.test.is_gpu_available() #should return True
print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))
install based on this version table.
That was the key for me. Had the same issue , CPU worked fine, GPU would dump out during model fit with an exit code but no error. The matrix will show you that tensorflow 2.5 - 2.8 work with CUDA 11.2 and cudnn 8.1 , the 'latest' versions are 11.5 and 8.4 as of 05/2022. I rolled back both versions and everything is working fine.
The matrix will show you that tensorflow 2.5 - 2.8 work with CUDA 11.2 and cudnn 8.1
I believe the problem is that CUDA 11.2 is not available for Windows 11.

Persisting CUDA error with tensorflow in WSL

I'm trying to make tensorflow use my NVIDIA GTX 1060 gpu in my laptop. I created a python environment and installed tensorflow, python, pip, etc. I am using Ubuntu on Windows (so wsl-ubuntu). On CMD, the nvidia-smi command is showing my GPU. But with tensorflow, I get the following error:
2022-01-26 21:45:36.677191: E tensorflow/stream_executor/cuda/cuda_driver.cc:271] failed call to cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected
2022-01-26 21:45:36.678074: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (DESKTOP-P8QAQC0): /proc/driver/nvidia/version does not exist
Num GPUs Available: 0
I have CUDA 11.5 and 11.6 installed, with cudNN 8.3.2.44 installed. I manually copied and pasted the files into the CUDA directory and ran the exe (exe didn't seem to install files though). I am not sure what else to do. Help would be really appreciated!
EDIT: I'm on Windows 10, and I changed my CUDA installation to 11.2 and cuDNN 8.1. The issue is still there. Both are installed on my C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA. I'm not sure if that's the error, since I didn't install directly on WSL.

Why does Tensorflow 2.4.1 not find my GPU?

I'm having trouble using my GPU with tensorflow.
I pip installed tensorflow-gpu 2.4.1
I also installed CUDA 11.2 and cudnn 11.2, following the procedure from: https://docs.nvidia.com/deeplearning/cudnn/install-guide/index.html#installwindows , also checking that all paths are fine and the libraries are at the correct place.
However, when I run tf.config.experimental.list_physical_devices('GPU') on my Jupyter Notebook, it doesn't find my GPU.
I also run tf.test.is_built_with_cuda(), which is returning True.
So is the problem that my GPU isn't supporting the current version of CUDA or cudnn? My GPU is "NVIDIA GeForce 605"
NVIDIA GeForce 605 card based on Fermi 2.0 architecture and I can see only Ampere,Turing, Volta, Pascal, Maxwell and Kepler are supported for CUDA 11.x.
As per #talonmies, GeForce 605 card never had supported for Tensorflow.
You can refer this for NVIDIA GPU cards with CUDA architectures are supported for Tensorflow.
For GPUs with unsupported CUDA architectures to use different versions of the NVIDIA libraries, you can refer Linux build from source guide.
Finally, you can also refer tested built configurations for Windows and linux.

tensorflow 2.4.1 doesnt detect gpu

I'm kind of new to machine/deep learning. I installed TensorFlow versions 2.4.1, I have CUDA version 11.2 but and cudNN when I want to get a list of available GPUs it returns nothing.(my GPU is 1050 ti 4GB)
I tried to install tensorflow-gpu but nothing changed.
what should I do?

tensorflow gpu tests pass--but I don't have cuDNN installed

Windows10-pro, single RTX 2080 Ti. I am new to Tensorflow.
I just installed tensorflow-gpu, version 2.1.0, python 3.7.7. Cuda compilation tools, release 10.1, V10.1.105. Nothing self-compiled. And I have not installed cuDNN, nor have I registered. All installation is standard, nothing self-compiled.
The tensorflow.org documentation states that cuDNN is needed to use the GPU. But my tests for GPU-usage seem to pass. For example,
tf.config.experimental.list_physical_devices('GPU') returns [PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')].
It may appear that I should just install cuDNN and not lose any more sleep. But I would still want to know if I were using the GPU so I would prefer a test that is capable of failing.
Is there a true test to see if an installation will use the GPU?
In NVIDIA GPU computing toolkit, one can verify the cuDNN installation,
On windows system,
Go to
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\include\
open cudnn.h
To utilize the Tensorflow-GPU successfully, CUDA and cuDNN are required.
Some of the Tensorflow library such as tf.keras.layers.GRU(Keras GRU layers) employs the capability of cuDNN.
Check these examples provided in Tensorflow site for GPU utilization.

Categories

Resources