How to Setup TensorFlow GPU 2.2 with NVIDIA GPUs

Aaron Ma
2 min readApr 8, 2020

--

Hello world, it’s Aaron!

NOTE: This article assumes you are on a Linux distro with at least 1 CUDA-capable NVIDIA GPU.

In this article, we will be installing NVIDIA CUDA and TensorFlow GPU 2.2.0-rc2!

Image Copyright TensorFlow.
Image Copyright NVIDIA.

Install CUDA

  1. Right before we install CUDA, we need to make sure that your GPU is CUDA-capable. If no results are returned after this command, sorry, your GPU doesn’t support CUDA!
lspci | grep -i nvidia

2. Check you have a supported version of Linux:

uname -m && cat /etc/*release

3. Install GNU G++.

4. Install CUDA 10.1 (not CUDA 10.2, as TensorFlow GPU currently doesn't support CUDA 10.2) by clicking the link for your Linux distro:

5. Follow the instructions for deb(local).

6. Install cuDNN for CUDA 10.1 by clicking here: https://bit.ly/cudnn-instal

Install Anaconda and TensorFlow GPU

Great job on setting up CUDA! Now for the meat of this article: Installing TensorFlow GPU.

  1. Right before we get started, install Anaconda so we don’t get errors while running TensorFlow GPU. To install Anaconda, go to this link here: https://bit.ly/inanaconda
  2. Now, create a virtual Anaconda environment.
  3. Create a virtual environment in Anaconda called tf-gpu:
conda create --name tf-gpu

4. Now, source into the virtual environment. Remember, every time you want to use this virtual environment, you must run this command!

conda activate tf-gpu

5. Install TensorFlow GPU with pip:

pip install tensorflow-gpu==2.2.0rc2

6. Create a new Python 3 shell:

python3

7. Test your TensorFlow GPU installation:

import tensorflow as tf
tf.__version__ # Result should be '2.2.0-rc2'
tf.config.list_physical_devices('GPU') # should list all available GPUs

Congratulations on setting up your computer for TensorFlow GPU 2.2.0-rc2!

-Aaron Ma https://aaronhma.com

--

--

Aaron Ma

Planet Earth, The Milky Way, Local Group, Virgo Supercluster, Laniakea Supercluster, the Universe

Recommended from Medium

Lists

See more recommendations