How to Upgrade or Downgrade TensorFlow

Introduction

TensorFlow is one of the best machine learning libraries for Python. There are various TensorFlow versions with different capabilities. Additionally, certain releases are only compatible with specific Python versions.

This article explains how to upgrade or downgrade TensorFlow.

How to Upgrade or Downgrade TensorFlow

Prerequisites

Note: Depending on the Python version, only specific TensorFlow releases are available:

  • Python 3.9 works with TensorFlow 2.5 and later releases.
  • Python 3.8 works with TensorFlow 2.2 and later releases.

How to Upgrade TensorFlow

To upgrade TensorFlow to a newer version:

1. Open the terminal (CTRL+ALT+T).

2. Check the currently installed TensorFlow version:

pip3 show tensorflow

Check TensorFlow version before upgrade

The command shows information about the package, including the version.

3. Upgrade TensorFlow to a newer version with:

pip3 install --upgrade tensorflow==<version>

Upgrade TensorFlow with pip install command

Make sure to select a version compatible with your Python release. If the release is incompatible, the version will not install. For the notebook environment, use the following command and restart the kernel after completion:

!pip install --upgrade tensorflow==<version>

The install automatically removes the old version along with the dependencies and installs the newer upgrade.

4. Lastly, check the upgraded version by running:

pip3 show tensorflow

Check TensorFlow version after upgrade

How to Downgrade TensorFlow

The best practice for TensorFlow downgrade is to use the latest version of Python and TensorFlow. Older versions have vulnerability issues, so be cautious when downgrading.

1. Check the currently installed TensorFlow version:

pip3 show tensorflow

2. Downgrade TensorFlow to a lower version by running:

pip3 install --upgrade tensorflow==<version>

Set the version to a lower number than the currently installed release. When choosing, make sure the version is compatible with the Python release.

If you are using a Notebook environment, run the following command and restart the kernel when the installation completes:

!pip install --upgrade tensorflow==<version>

The upgrade automatically removes the existing TensorFlow and installs the stated version.

3. Finally, use the pip show command to confirm the correct TensorFlow version installed:

pip3 show tensorflow

Note: Deploy TensorFlow on a Bare Metal Cloud server instance to ensure that your TensorFlow workloads always have enough resources for optimal performance.

Conclusion

The pip package manager offers a simple method to upgrade or downgrade TensorFlow, regardless of environment.

Next, learn why GPUs are necessary for Deep Learning.

原创文章,作者:kepupublish,如若转载,请注明出处:https://blog.ytso.com/224145.html

(0)
上一篇 2022年1月7日
下一篇 2022年1月7日

相关推荐

发表回复

登录后才能评论