How to expand your machine learning capabilities by installing TensorFlow on Ubuntu Server 20.04 – TechRepublic

  • Lauren
  • February 10, 2021
  • Comments Off on How to expand your machine learning capabilities by installing TensorFlow on Ubuntu Server 20.04 – TechRepublic

If you’re looking to add Machine Learning to your Python development, Jack Wallen shows you how to quickly install TensorFlow on Ubuntu Desktop 20.04.

Image: Google

Must-read developer content

TensorFlow is an open source development platform for machine learning (ML). With this software platform, you’ll get a comprehensive collection of tools, libraries, and various resources that allow you to easily build and deploy modern ML-powered applications. Beginners and experts alike can make use of this end-to-end platform, and create ML models to solve real-world problems.
How do you get started? The first thing you must do is get TensorFlow installed on your machine. I’m going to show you how to make that happen on Ubuntu Desktop 20.04.
SEE: Top 5 programming languages for systems admins to learn (free PDF) (TechRepublic)
What you’ll need

A running instance of Ubuntu Desktop 20.04 
A user with sudo privileges

How to install python
The first thing to be done is the installation of the necessary dependencies. It just so happens these are all about Python. Log in to your desktop and install the dependencies with the command:
sudo apt-get install python3 python3-venv python3-dev -y
Python should now be installed, so you’re ready to continue on.
How to install TensorFlow

How we install TensorFlow is from within a Python virtual environment. Create a new directory to house the environment with the command:
mkdir ~/tensor
Change into that newly created directory with the command:
cd ~/tensor
Next, create the Python virtual environment with the command:
python3 -m venv venv
Once the above command completes, we must then activate the virtual environment, using the source command like so:
source venv/bin/activate
After you activate the environment, your command prompt should change, such that it begins with (venv) (Figure A).
Figure A
We’ve activated our virtual Python environment.” data-credit rel=”noopener noreferrer nofollow”>
We’ve activated our virtual Python environment.

Next, we’re going to upgrade Pip with the command:
pip install –upgrade pip
We can now install TensorFlow with the command:
pip install –upgrade tensorflow
TensorFlow should now be installed on your system. To verify, issue the command:
python -c ‘import tensorflow as tf; print(tf.__version__)’
The command will return the TensorFlow version number (Figure B).
Figure B
I’m running the Ubuntu 20.04 desktop on a virtual machine, so GPU is an issue.” data-credit rel=”noopener noreferrer nofollow”>
I’m running the Ubuntu 20.04 desktop on a virtual machine, so GPU is an issue.Make sure, when you’re done working, that you deactivate the Python virtual environment with the command:
deactivate
And there you have it, you’ve successfully installed TensorFlow on Ubuntu Desktop 20.04 and are ready to start adding machine learning to your builds. 
Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.

Open Source Weekly Newsletter

You don’t want to miss our tips, tutorials, and commentary on the Linux OS and open source applications.
Delivered Tuesdays

Sign up today

Also see

Source: https://www.techrepublic.com/article/how-to-expand-your-machine-learning-capabilities-by-installing-tensorflow-on-ubuntu-server-20-04/