Configure TensorFlow-gpu

 I've tried to install TENSORFLOW-GPU & keras and encountered some issues. I've decided to create a small guide if others have similar issues. Good luck !

My configuration : 
  • Python anaconda 3 this one
  • Graphic card : GEFORCE GTX 1660 Ti
If you already tried something go to the error section before.

STEP 1 : Could your graphic card access to Nvidia CUDA

You can visit the developer website of Nvidia. But as you see, my GTX 1660 Ti did not appeared in the list : a simple research on internet could appease your doubt.

Don't hesitate to visit Tensorflow's website. In my time the current version supported was CUDA 10.1. All downloads are here : 

STEP 2 : Install Visual Studio

It might work with the latest version of Visual Studio but I recommend the version of 2017. It's important to check Development Desktop en C++ to have the right dependencies :

.

STEP 3 : Install Cuda & CUDnn

Before Install those two make sure you have the latest version for your GPU  

As I said before you need CUDA 10.1, you can download it at this link. I've selected 10.1 Version 2 and install it.

Then we need to download CUDnn (you must register to access it). As you see different version exist for CUDA 10.1. In the test image you can see that tensorflow-gpu required : "cudnn64_7.dll"

In the CUDnn archive you will see a similar structure than the one in CUDA : just copy past what is in the arcive into the CUDA>v10.1 folder.



STEP 4 : Set up a virtual environment and tests

It's almost finish ! If you have Anaconda, open Anaconda prompt and create a virtual env "conda create -n [name] python=3.7" tensorflow isn't supported in python 3.8.


 As you see it's not my first try, we will see some errors in next section. Enter your virtual environment : "activate tf" [tf is the name I give to my environment] and install tensorflow-gpu "pip install tensorflow-gpu". Then launch python and do tests : "import tensorflow as tf" ;  "print(tf.__version__)" [keras only support 2.2 or higher] and print(tf.test.is_gpu_available())" the last return must be True :


Congratulation ! tensorflow-gpu work on your PC. But as you see we didn't test it on real utilization and without keras. Don't forget to exit properly from your env : 

STEP 5 : Use it in PyCharm

In File>Settings - Project : Name>Python interpreter, change your python interpreter by cliking on it and "show all...", to add a new one click on "+" button. It's a Conda environment so you will find it where you have installed anaconda :


You can add another library by two methods : anaconda prompt "pip install [module]" or add button on your python Interpreter in PyCharm. In our case we want keras.

At this point you can run it, but in my case I had this issue :

I looked on internet and the main idea is to reinstall h5py. But be careful, in my case I reinstall "pip uninstall h5py" "pip install h5py" in my anaconda prompt.

and then reinstall the other 2, tensorflow-gpu and keras (in this order).

CLEAN Section :

If you search on internet people warn you about risks. If you don't install the right version it won't work and you cannot try to install another one. I will show you how to repair it.

Uninstall anything links to CUDA (you can tap "uninstall in Windows 10 searchbar") & Visual Studio:


and install again the latest GPU driver, your version of Visual Studio & re-start all previous steps.