How to Install Keras & TensorFlow on Ubuntu Linux

Keras & TensorFlow on AlmaLinux

Learn to install Keras & TensorFlow on Ubuntu Linux to build your own Artificial Intelligence (AI) and Machine Learning cloud. Keras is a neural network deep learning API written in Python, running on top of the machine learning platform TensorFlow. TensorFlow provides a collection of workflows to develop and train machine learning models on the cloud, and its GPU support makes VPS cloud servers such as GPU Compute ideal for your machine learning projects.

Summary

Installing Keras & TensorFlow

  1. As good practice, ensure all packages are up-to-date:
    sudo apt-get update -y
  2. Execute the following commands to install and update Python3 and Pip:
    sudo apt install python3 python3.pip
    
    sudo pip3 install ––upgrade pip
  3. Update Setuptools using the following command:
    pip3 install ––upgrade setuptools
  4. Install TensorFlow and confirm the package information using these commands:
    pip3 install tensorflow
    
    pip list | grep tensorflow
  5. Install Keras using the following command:
    pip3 install keras
  6. You may wish to run the following command to verify the installation with the package information:
    pip3 show keras

Installing NVIDIA driver, CUDA and cuDNN

In order to ensure that you can utilise GPU for Tensorflow within our GPU Compute, you will need to ensure that you have the latest and correct NVIDIA driver, CUDA & cuDNN installed within your VPS.

Install NVIDIA driver for Ubuntu

First, download the latest NVIDIA driver from here using the wget command, and then run the following command to install it:

sudo sh NVIDIA-Linux-x86_64-XXX.YY.run

Install CUDA

Then, download the latest CUDA from here using the wget command, and then run the following command to install it. Remember to take note on the instructions given at the end of installation to add the additional lines to your shell script:

sudo sh cuda_XXX_linux.run

Install cuDNN

Finally, refer to the official guideline here to complete cuDNN installation.

Conclusions

This tutorial shows you how to install Keras & TensorFlow on Ubuntu, as well as installing the right NVIDIA driver, CUDA & cuDNN for your cloud server.

Important Information

You may wish to be mindful of future updates done to Ubuntu (sudo apt-get update) may break your NVIDI driver, CUDA & cuDNN installation. When this happens, simply roll back with your Ubuntu upgrade and switch back to the kernel version that worked well.

Related Post