Artificial intelligence and machine learning are already transforming how we interact with technology. So far, we’ve only seen the beginning. Moving forward, both of these technologies will make technology easier, as it does more for us without being told to.
AI and machine learning may make using technology easy, but they aren’t the easiest to implement themselves. That’s where technology like TensorFlow comes in handy. With TensorFlow, anyone with some experience as a developer can quickly begin using machine learning to solve problems.
What Is TensorFlow?
The goal of TensorFlow is to make it easy to build and deploy machine learning models. While those already experienced with machine learning can dive in and get their hands dirty, beginners can use higher-level APIs to make getting started easier.
One of the major uses of TensorFlow we see right now is detecting and classifying various objects. Image recognition is far from the only thing TensorFlow can do, but companies like Airbnb use it for this quite often.
As you may already imagine, both AI and machine learning have plenty of potential use cases in IoT. For a better idea, take a look at our breakdown of what machine learning is and what it can bring to IoT.
Installing TensorFlow on Linux
The easiest way to install TensorFlow on Linux is to use
pip, the Python package manager. Before you get started, you’ll want to make sure you have the basic system requirements. If all of the following run without issue, you should be ready.
python3 --version pip3 --version virtualenv --version
If these fail, you’ll need to install the prerequisites. On Ubuntu, you’d do the following:
sudo apt update sudo apt install python3-dev python3-pip sudo pip3 install -U virtualenv
There are two ways to install TensorFlow. The first is to install it either system-wide or in your home directory. The second is to install it in a virtual environment. We’re going to install it in the home directory. For instructions on installing in a virtual environment, see the TensorFlow install instructions.
First, make sure
pip is up to date:
pip3 install --upgrade pip
Run the following to install TensorFlow in your home directory:
pip3 install --user --upgrade tensorflow
To install the GPU-enabled version that makes use of Nvidia drivers, run the following instead:
pip3 install --user --upgrade tensorflow-gpu
Now we need to ensure that TensorFlow installed properly. You can do this by running the following:
python3 -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"
Installing TensorFlow on Raspberry Pi
TensorFlow, like most deep-learning libraries, can push even powerful hardware to its limits. Even so, it is supported on Raspberry Pi, and this is a great way to get started with it.
For these instructions we’re assuming you already have a Raspberry Pi set up and running Raspbian. If you don’t, follow our guide to setting up a Raspberry Pi.
Installing TensorFlow on a Raspberry Pi running Raspbian is easy. First, install the prerequisite libraries with the following line:
sudo apt install libatlas-base-dev
Then, install TensorFlow using
pip with the following command:
pip3 install tensorflow
Where to Go From Here
Getting TensorFlow installed is just the beginning. Once you have it up and running, it’s time to start building some test projects to see what it is all about. You can start by taking a look at the official TensorFlow tutorials.
If you want to know what other skills you might want to pick up to complement machine learning, we can help. Take a look at our list of technical skills you should know for working on IoT projects.
Get the best of IoT Tech Trends delivered right to your inbox!