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

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

TensorFlow relies on the cuda toolkit and on the NVidia display driver. I had difficulties to install these with the .deb files but succeeded to do so using the .run file.

cuda_download.png

To run the installer script I had to boot into single user mode, avoiding to start the desktop system. This can be done typing "e" at the boot screen and adding "single" to the boot command.

In the "Additional Drivers" tab of the Software & Updates program you see that we are using the manually installed NVidia driver:

driver_used.png

When trying a very simple TensorFlow program: #!/usr/bin/python3
import tensorflow as tf
import numpy as np
from tensorflow import keras
model = tf.keras.Sequential([keras.layers.Dense(units=1, input_shape=[1])])

I get:

gpu_good.png

-- Uli Raich - 2022-01-31

Comments

Topic attachments
I Attachment History Action Size Date Who Comment
PNGpng cuda_download.png r1 manage 51.4 K 2022-01-31 - 10:56 UliRaich  
PNGpng driver_used.png r1 manage 74.9 K 2022-01-31 - 10:56 UliRaich  
PNGpng gpu_good.png r1 manage 45.9 K 2022-01-31 - 10:56 UliRaich  
PNGpng graphicsCard.png r1 manage 38.3 K 2022-01-31 - 11:01 UliRaich  
PNGpng libcudart.png r1 manage 37.0 K 2022-01-31 - 11:01 UliRaich  
PNGpng nvidia.png r1 manage 12.7 K 2022-01-31 - 10:56 UliRaich  
Edit | Attach | Watch | Print version | History: r5 | r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r1 - 2022-01-31 - UliRaich
 
  • Edit
  • Attach
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback