How to Check Your TensorFlow Version in Colab?

Python provides various open-source libraries that are used in almost every field, such as AI, machine Learning, Image Processing, etc. The most commonly used libraries are OpenCV, Pandas, Numpy, PIL/Pillow, TensorFlow, etc.

TensorFlow is a machine learning library that performs various tasks, such as AI-related tasks, training the deep neural network, etc. The Google Colab allows you to write and execute code through the browser and is commonly used for machine learning projects.

This post will guide checking, installing, and modifying the TensorFlow version in Colab.

How to Check/Verify Your TensorFlow Version in Colab?

To check/verify your “TensorFlow” version in colab, you need to type the below command:

import tensorflow as tf
print(tf.__version__)

The above snippet shows the “TensorFlow” version in Colab.

How to Change/Modify the Version of TensorFlow in Colab?

To change the version of TensorFlow, the following pip command is used in colab:

!pip install tensorflow==2.2.1

The above snippet shows the installation of version “2.2.1” in colab.

After the installation, click on the restart runtime option from the “runtime” menu, as shown below:

Now verify the version which was installed in our colab using the following command:

import tensorflow as tf
print(tf.__version__)

The above snippet verified that the “TensorFlow” version “2.2.1” has been installed successfully.

Conclusion

To check/verify your TensorFlow version in Colab, import the TensorFlow and print the installed version using the “__version__” attributes. The Colab has a pre-installed TensorFlow “2.x” version. To change the pre-installed version to another, use the pip command, i.e., “!pip install tensorflow==2.2.1”. This blog delivered a comprehensive guide on checking your TensorFlow version in Google Colab.