PreparingThePC

Page Actions

Preparing the PC for Tensorflow

Setting up a virtual Python environment

The procedure is described in https://www.freecodecamp.org/news/virtualenv-with-virtualenvwrapper-on-ubuntu-18-04.

Once his is done you can create a new virtual environment with:

mkvirtualenv name_of_env (e.g. mkvirtualenv AI)

switch to a virtual environment with the "workon" command:

e.g. workon AI

The virtual environment used to build ML models should include and maybe a few others.

Setting up the GPU

When trying my first simple TensorFlow program I saw this warning:

libcudart.png

My PC, being a "gaming machine", uses an nVIDIA GeForce GTX 950M graphics card whose GPU (Graphics Processing Unit) can be used by TensorFlow to speed up number crunching.

nvidia.png

When looking at the Software & Updates program we see that the nvidia-driver-535 is used to control the NVidia GeForce GTX 950 module. Make sure that the nouveau driver is disabled!

displayDriver.png

TensorFlow relies on the cuda toolkit and on the NVidia display driver. Even after installing the newest version of cuda, TensorFlow did not see the GPU. An intensive search with Google finally showed that (at the moment of writing this page) TensorFlow version 2 only works with cuda 11.8 and cuDNN 8.6.

https://medium.com/@juancrrn/installing-cuda-and-cudnn-in-ubuntu-20-04-for-deep-learning-dad8841714d6 and https://gist.github.com/MihailCosmin/affa6b1b71b43787e9228c25fe15aeba decribe how to install cuda-11.8 and cudnn-8.6 and how to test the installation.

The script testGPU.py below shows the number of GPUs that TensorFlow has fouind:   #!/home/uli/.virtualenvs/AI/bin/python
import tensorflow as tf
print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))

After installation of cuda-11.8 and cuDNN-8.6 this is what I get, when I run the script:

GPU_warnings.png

To get rid of these warnings I first had to install tensorrt from the NVidia WEB site.

To irradicate the NUMA mode warning I followed:

https://askubuntu.com/questions/1379119/how-to-set-the-numa-node-for-an-nvidia-gpu-persistently

When running the testGPU program now, things seem to be ok and I should be able to use my NVidia GPU.

GPU_ok.png

-- %USERSIG{UliRaich - 2022-01-31}%

Comments


 
I Attachment Action Size Date Who Comment
GPU_ok.pngpng GPU_ok.png manage 40 K 21 Sep 2023 - 19:12 UnknownUser  
GPU_warnings.pngpng GPU_warnings.png manage 115 K 21 Sep 2023 - 18:26 UnknownUser  
cuda_download.pngpng cuda_download.png manage 51 K 31 Jan 2022 - 10:56 UnknownUser  
displayDriver.pngpng displayDriver.png manage 102 K 21 Sep 2023 - 17:59 UnknownUser  
driver_used.pngpng driver_used.png manage 74 K 31 Jan 2022 - 10:56 UnknownUser  
gpu_good.pngpng gpu_good.png manage 45 K 31 Jan 2022 - 10:56 UnknownUser  
graphicsCard.pngpng graphicsCard.png manage 38 K 31 Jan 2022 - 11:01 UnknownUser  
libcudart.pngpng libcudart.png manage 36 K 31 Jan 2022 - 11:01 UnknownUser  
nvidia.pngpng nvidia.png manage 12 K 31 Jan 2022 - 10:56 UnknownUser  
Topic revision: r5 - 17 Oct 2023, UliRaich