Installing TensorFlow GPU

If you have a TensorFlow supported GPU, you can install TensorFlow GPU version to speed up your training process. TensorFlow provides support for NVIDIA CUDA enabled GPU cards. You can refer to the following link to check whether your GPU card is supported or not: https://www.tensorflow.org/install/gpu.

To install TensorFlow GPU version through native pip, one has to go through a list of tedious processes:

  1. Download and install the CUDA Toolkit for your operating system 
  2. Download and install cuDNN library (to support deep learning computations in GPU)
  3. Add path variables for CUDA_HOME and CUDA Toolkit
  4. Install TensorFlow GPU through pip

Thankfully, however, Anaconda, have compiled everything in a single command—from compatible CUDA Toolkit, cuDNN library, to TensorFlow-GPU. If you already have TensorFlow CPU installed in the current environment, you can deactivate the environment and make a new environment for TensorFlow GPU. You can simply run the following command in your Conda environment and it will download and install everything for you:

# deactivate the environment
conda deactivate

# create new environment
conda create -n tf_gpu

#activate the environment
conda activate tf_gpu

# let conda install everything!
conda install tensorflow-gpu

Once you are done installing, it's time to test your installation!