TensorFlow is an open-source environment that helps users to perform different machine learning-oriented tasks. It includes comprehensive tools, libraries and a community, ensuring a robust environment for the researchers to develop machine learning and AI-related applications with ease. Different platforms have widely adopted it, including PayPal, Twitter, and other popular websites. Thus, it is an essential program for Ubuntu users to install on their operating system.
In this article, we will describe how you can install and use TensorFlow on Ubuntu 22.04.
Install and Use TensorFlow on Ubuntu 22.04
To install and use TensorFlow on Ubuntu 22.04, you will need to perform the following steps.
Step 1: First verify that you have the latest version of python3 installed on Ubuntu 22.04 using the following command:
Step 2: Now, install Python virtual environment via venv module on Ubuntu using the following command:
Step 3: Now, create a Tensor environment folder in your home directory using the following command:
Step 4: Visit the directory and create a virtual environment with the name of your choice using the following command.
$ python3 -m venv <virtual_environment_name>
The “tensor_env” is the virtual environment name. You can set your own.
Step 5: In order to use the created environment, you will first need to activate it using the following command:
The above command has successfully activated the virtual environment.
Step 6: To install TensorFlow, you will first be required to upgrade your pip installer. The pip is a Python packages manager that includes the latest TensorFlow version. Use the below-given command to upgrade the pip installer:
Step 7: Once the pip installer is upgraded, you can then install TensorFlow using the following command:
The installation will take some time as it will download different packages and dependencies required to run the TensorFlow environment. However, it will install TensorFlow on Ubuntu without an error.
To confirm the successful installation of TensorFlow on Ubuntu 22.04, use the following command.
Testing a code using TensorFlow
To use TensorFlow on Ubuntu 22.04, let’s create a test code to output the version of TensorFlow .
The above command will work for GPU enabled machines as TensorFlow will require GPU to execute various machine learning tasks.
Removing TensorFlow from Ubuntu 22.04
To completely remove TensorFlow from Ubuntu 22.04, you will require the following command which will remove all related files of TensorFlow from Ubuntu 22.04.
Conclusion
TensorFlow is an excellent environment for data scientists and researchers to develop different machine learning and AI-related applications. The TensorFlow on Ubuntu 22.04 can easily be installed using the pip installer whose steps are mentioned above. Once the installation is completed, you can use the TensorFlow environment on your Ubuntu terminal to execute various machine learning codes.