Skip to content

Setup tensorflow environment

A.L edited this page Feb 4, 2020 · 2 revisions

Setup tensorflow environment tutorial

Objective:

Install the environment and the correct dependencies to train and run neural network with tensorflow 2

Requirements:

A PC running ubuntu 18, preferably with a compatible GPU

Steps:

  1. pip install tensorflow
  2. Install NVIDIA GPU drivers 418.x or higher
  3. Install CUDA Toolkit 10.1 shipped with CUPTI
  4. Install cuDNN SDK 7.6 or higher
  5. Install TensorRT 6.0 to improve latency and throughput for inference on some models

Conclusion:

Try your tensorflow installation by running this in python:

from __future__ import absolute_import, division, print_function, unicode_literals
import tensorflow as tf
print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU')))

Tips:

The most tricky part is updating your NVIDIA GPU Drivers, you might broke your os but you can try this to recover it:

To recover, follow these steps:

Ctrl+Alt+F1 [to exit and get into the TTY mode]

sudo apt-get remove --purge nvidia*
sudo apt-get install ubuntu-desktop
sudo apt-get autoremove
sudo rm /etc/X11/xorg.conf
echo "nouveau" | sudo tee -a /etc/modules
sudo reboot

[after reboot, you should be back to operational with the nouveau driver, and can login]

sudo add-apt-repository --remove ppa:graphics-drivers/ppa
sudo apt-get autoremove
sudo apt-get autoclean

References:

https://www.tensorflow.org/install/gpu

Clone this wiki locally