Trouble activating Tensorflow 2.0 on GPU - python

This has been asked countless times here, but I could not find solution that fits my problem.
I am trying to install tensorflow-gpu on Windows 10, Anaconda. I downloaded CUDA (Version 10.2) and CuDNN, I have moved files from CuDNN library to CUDA folders and added following variables to PATH:
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\bin
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\libnvvp
After running following code in anaconda, I get following response:
from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())
I am guessing the main problem is "Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found", so I went to my CUDA bin folder and there is no cudart64_101.dll, but there is cudart64_102.dll. What should I do to fix this?

The last three numbers in your .dll files should point you to a solution. TensorFlow is looking for CUDA 10.1, but you have installed CUDA 10.2.
Re-installing CUDA and the compatible cuDNN should fix your problem. See the TensorFlow installation tutorial for the exact versions of CUDA and cuDNN.
You'll probably have to reinstall TF as well, after installing the correct CUDA libraries.
Hope this helps.

Related

cudnn64_8.dll not found (but I have it installed properly!)

I have tried to get my laptop gpu to work with tensorflow, however I keep encountering this issue
I had tensorflow installed through pip (on anaconda env) with CUDA 11.2 and CUDnn 8.1, and it won't work!
I then tried a previously known version to work (tensorflow 2.4 with CUDA 11.0 and so on.
-but pip will not install tensorflow 2.4.0 (I am assuming it is no longer supported)
I have included a photo with proof of my cuda and cudnn versions
I believe the issue may lie in the folder you extract your cuDNN to.
Personally, I've extracted my cuDNN to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.2.
When you open the zip cuDNN file, open the "cuda" file in the zip, and then extract the rest (bin etc.) into the above mentioned directory.
Make sure you restart the program/kernel so it can detect the new files.
Also, don't forget to add the CUDA path to your environment variables, though as it knows to look for cudnn64_8.dll I expect this is fine.

How to get tensorflow keras to use my GPU?

I am trying to use keras in tensorflow to train a CNN network for some image classification. Obviously, the training running on my CPU is incredibly slow and so I need to use my GPU to do the training. I've found many similar questions on StackOverflow, none of which have helped me get the GPU to work, hence I am asking this question separately.
I've got an NVIDIA GeForce GTX 1060 3GB and the 466.47 NVIDIA driver installed. I've installed the CUDA toolkit from the NVIDIA website (installation is confirmed with nvcc -V command outputting my version 11.3), and downloaded the CUDNN library. I unzipped the CUDNN file and copied the files to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.3, as stated on the NVIDIA website. Finally, I've checked that it's on PATH (C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.3\bin and C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.3\libnvvp are both in the environment variable 'Path').
I then set up an environment using conda, downloading some packages that I need, like scikit-learn, as well as tensorflow-gpu=2.3 After booting my environment into Jupyter Notebook, I run this code to check to see if it's picking up the GPU:
import tensorflow as tf
print(tf.__version__)
print(tf.config.list_physical_devices())
And get this:
2.3.0
[PhysicalDevice(name='/physical_device:CPU:0', device_type='CPU')]
I have tried literally everything I have come into contact with on this topic, but am not getting any success in getting it to work. Any help would be appreciated.
You, first, have to install all CUDA requirements. If you have Ubuntu 20.04, here is how you can install the requirements. Then it's the right time to install tensorflow. Asa you intended to utilize your GPU, you have install tensorflow-gpu library, not tensorflow alone.
I'm guessing you have installed TensorFlow correctly using pip install tensorflow.
NVIDIA GPU cards with CUDA architectures 3.5, 5.0, 6.0, 7.0, 7.5, 8.0 and higher than 8.0 are currently supported by TensorFlow. If you have the supported cards but TensorFlow cannot detect your GPU, you have to install the following software:
NVIDIA GPU drivers —CUDA 11.0 requires 450.x or higher.
CUDA Toolkit —TensorFlow supports CUDA 11 (TensorFlow >= 2.4.0)
cuDNN SDK 8.0.4
You can optionally install TensorRT 6.0 to improve latency and throughput for inference on some models.
For more info, please refer to the TensorFlow documentation: https://www.tensorflow.org/install/gpu
I recommend to use conda to install the CUDA Toolkit packages as well as CUDNN, which will avoid wasting time downloading the right packages (or making changes in the system folders)
conda install -c conda-forge cudatoolkit=11.0 cudnn=8.1
Then you can install keras and tensorflow-gpu by typing
conda install keras==2.7
pip install tensorflow-gpu==2.7
and it will work directly.
Based on this issue

Cuda 10.1 with rtx 2070 gpu on windows10 does not work when import tensorflow

Hi I am trying to use tensorflow with cuda 10.1
I have installed cuda10.1 and CuDNN 7.5 for Cuda 10.1
When launch this command "nvcc -V" to check my installation I have this windows prompt
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Fri_Feb__8_19:08:26_Pacific_Standard_Time_2019
Cuda compilation tools, release 10.1, V10.1.105
But when I import tensorflow on jupyter notebook, I have this error
import tensorflow as tf;
Error:
ImportError: Could not find 'cudart64_100.dll'. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Download and install CUDA 10.0 from this URL: https://developer.nvidia.com/cuda-90-download-archive
How can I do to make it work ? . thanks in advance for your help
I just reinstalled tensorflow and cuda 10.0 with the lastest version of visual studio. From memory, it gives you a warning that not all features may work properly (nvidia NSight probably). It doesn't prevent you from continuing with the installation.
TO fix it you need to install visual studio 2017 and cuda 10 will work
1) Uninstall CUDA 10.1 and install CUDA 10.0
2) Go to the cuDNN Archive https://developer.nvidia.com/rdp/cudnn-archive
3) Click on Download cuDNN v7.6.1 (June 24, 2019), for CUDA 10.0
(you need CUDA 10.0 installed. NOT 10.1. If you installed the wrong version, uninstall
it and install the 10 which works with tensorflow-gpu)
4) Click on the link for your operating system.
5) Unzip it. It should unzip to a folder called CUDA.
6) Go into the CUDA folder and copy the contents
7) Open the installed CUDA 10 location. For windows 10 it is "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0"
8) Paste the contents from your clipboard to the folder.
9) have a coffee. You are done!
If you are using CUDA above 10.0 you may
download and manually copy cudart64_100.dll to your CUDA bin folder
(A path similar to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin)
Please find the following link to download the zipfile containing the same (Extracted from CUDA 10.0)
https://www.dropbox.com/s/mz7ewnoc6pfxqql/cudart64_100_dll_.zip?dl=0
Once you had done this you may probably run into another error saying cublas64_100.dll not found. Kindly
copy your cublas64_10.dll from the same folder and rename it to
cublas64_100.dll
.

Cannot import tensorflow-gpu

I have tried to import tensorflow-gpu and I'm getting the same error with different versions of CUDA and cuDNN.
My GPU is compatible with CUDA and I have no problems installing but when I try to import tensorflow-gpu I got this:
ImportError: DLL load failed: No se puede encontrar el módulo especificado.
Failed to load the native TensorFlow runtime.
Tensorflow version: 1.11
CUDA version: 10
cudNN: 7.3.1
I also tried cudaNN 5.0 because I saw on a forum that worked for some people.
Assuming you have your nvidia drivers installed properly, refer to this table to check out which CUDA and cuDNN version you should be using for the tensorflow version you prefer.
Try running these commands in your cmd window
SET PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin;%PATH%
SET PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\extras\CUPTI\lib64;%PATH%
SET PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\include;%PATH%
SET PATH=C:\tools\cuda\bin;%PATH%
also see the chart that Jialer Chew gave if you are now doing it use tf version 2.2.0 cuda version 10.1 and cudnn version 7.6.0.

Tensorflow windows error

I am trying to install tensorflow(GPU) for windows using Python 3.5 but I get error when I try to import the tensorflow package.
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:119] Couldn't open CUDA library cublas64_80.dll
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\cuda\cuda_blas.cc:2294] Unable to load cuBLAS DSO.
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:119] Couldn't open CUDA library cudnn64_5.dll
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\cuda\cuda_dnn.cc:3459] Unable to load cuDNN DSO
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:119] Couldn't open CUDA library cufft64_80.dll
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\cuda\cuda_fft.cc:344] Unable to load cuFFT DSO.
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library nvcuda.dll locally
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:119] Couldn't open CUDA library curand64_80.dll
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\cuda\cuda_rng.cc:338] Unable to load cuRAND DSO.
Did you follow the instructions for installing CUDA Toolkit? You can find a link to the instructions here.
Requirements to run TensorFlow with GPU support
If you are installing TensorFlow with GPU support using one of the
mechanisms described in this guide, then the following NVIDIA software
must be installed on your system:
CUDA® Toolkit 8.0. For details, see NVIDIA's documentation
Ensure that you append the relevant Cuda pathnames to the %PATH% environment
variable as described in the NVIDIA documentation.
The NVIDIA drivers
associated with CUDA Toolkit 8.0. cuDNN v5.1. For details, see
NVIDIA's documentation. Note that cuDNN is typically installed in a
different location from the other CUDA DLLs.
Ensure that you add the
directory where you installed the cuDNN DLL to your %PATH% environment
variable. GPU card with CUDA Compute Capability 3.0 or higher. See
NVIDIA documentation for a list of supported GPU cards.

Categories