How to install TensorFlow-GPU in ubuntu and Linux
Installing the TensorFlow-GPU version seems very hard for the beginner which is because the version of python and Cuda needs to be supported by TensorFlow-GPU. So, in this blog, I will show you the simple way to install it in Linux OS.
Before starting you should know that your system must full the Hardware requirement which is:
NVIDIA GPU drivers — CUDA 11.2 requires 450.80.02 or higher.
Now install Cuda using the command below:
sudo apt install cuda
The above command will install the latest version of the Cuda in your system.
Now, click the below link which will redirect you to the TensorFlow-GPU webpage:
https://www.tensorflow.org/install/source#gpu
On the webpage you will see below table :
The above image shows the requirement to install TensorFlow-GPU where column 1 shows the version of TensorFlow and its respective row shows the requirement that our system must have before installing TensorFlow-GPU.
For example:
TensorFlow 2.7.0( Watch First row of image 1) require:
- Python Version: 3.7 to 3.9
- Compiler: GCC 7.3.1
- Build tools: Bazel 3.7.2
- cuDNN: 8.1
- Cuda: 11.2
For demonstration, I will be installing the first row in the image 1 table which is TensorFlow-GPU 2.7.0 version.
At first, check the python version and Cuda version using the below command in the terminal:
python3 -V
nvidia-smi #To check the version of cuda
Above image 2, show that we have python 3.8.10 and Cuda 11.5 which is higher than the requirement shown in image 1 but still it works.
Now, use the below command to install TensorFlow-GPU 2.7.0:
pip3 install 'tensorflow-gpu==2.7.0'
Below image 3 shows the installation process of TensorFlow-GPU.
Now use the below code to conform the installation of the TensorFlow-GPU:
import tensorflow as
tensorflow_version = tf.__version__
print(tensorflow_version)
If you run the program than you will get the TensorFlow-GPU version we just install.
Bye, and fell free to commet if you have any query.