How to Install Keras and Its Dependencies on Ubuntu 20.04? The procedure of setting up a machine and deep-learning pc is strongly involved and consists of the following steps:
We would assume you have Ubuntu 20.04 with NVIDIA graphic card available in your pc. The only difficult process could be the setting up of GPU support otherwise the entire process could be achieved with a few lines of codes in couple of minutes.
As usual, We must update and upgrade our applications on Ubuntu 20.04 with commands:
$ sudo apt-get update && sudo apt-get upgrade
Also make sure you must have Python2 or Python3 installed on Ubuntu 20.04, We will use Python3 for setting up machine and deep learning workstation. The following is command code:
$ sudo apt-get install python3-pip python3-dev
1. Installing the Python scientific suite
Install a BLAS Library
BLAS library makes ensure that you could be able to run fast tensor processes on your CPU. Copy the following code to paste in terminal:
$ sudo apt-get install build-essential cmake git unzip pkg-config libopenblas-dev liblapack-dev
BLAS library also included python3-yaml already.
Install Numpy, SciPy and Matplotlib
These three Numpy, SciPy and Matplotlib libraries are most favourite for scientific computing. For installation copy and paste the following command into terminal:
$ sudo apt-get install python3-numpy python3-scipy python3-matplotlib
Install HDF5 Library
This library is developed by NASA to store large files of numeric data into binary formats. Saving of Keras models are quick and efficient using HDF5.
$ sudo apt-get install libhdf5-serial-dev python3-h5py
or
$ sudo apt-get install libhdf5-serial-dev
$ sudo apt-get install python3-h5py
2. Visualiser for Neural Network
Install Graphviz and pydot-ng
These two packages will act as visualiser Keras models. They aren’t necessary to run Keras and TensorFlow, so these packages could be skipped. But it is better to install whenever you need them. Here are the commands:
$ sudo apt-get install graphviz
$ sudo pip install pydot-ng
Install additional packages like OpenCV
It is very famous library of computer vision which is open source, helping as well.
$ sudo apt-get install python-opencv
3. Setting Up GPU Acceleration
It is strongly recommended but not strictly necessary. All the machine learning and deep learning models on CPU but it could consume several minutes to hours for a model to train. If your pc has NVIDIA graphic card (GPU) then I strongly recommend to install it, otherwise skip this step.
To use your NVIDIA GPU the following drivers and library should be installed:
- CUDA – a set of drivers for GPU
- cuDNN – this library increases the training speed of your models by 50% to 100%
NVIDIA provides a ready-to-use package that you could download from
For CUDA-downloads, click here
$ wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/
x86_64/cuda-repo-ubuntu1604_9.0.176-1_amd64.deb
Install CUDA
The following commands would install CUDA.
$ sudo dpkg -i cuda-repo-ubuntu1604_9.0.176-1_amd64.deb
$ sudo apt-key adv --fetch-keys
http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/
x86_64/7fa2af80.pub
$ sudo apt-get update
$ sudo apt-get install cuda-8-0
Install cuDNN
You have to register for a free NVIDIA developer account to download accordingly as per your Ubuntu versions.
For Downloading, click here
After downloading, go to working directory containing cuDNN package. Run the following command in terminal to install:
$ sudo dpkg -i dpkg -i libcudnn6*.deb
4. Install TensorFlow with GPU Supported
Here is the command to install TensorFlow with GPU support:
$ sudo pip3 install tensorflow-gpu
5. Install Keras
Keras can be directly installed from PyPI:
$ sudo pip install keras
Alternatively,
It can be installed from GitHub. Doing so will allow you to access the keras/examples folder, which contains many example scripts for you to learn from:
$ git clone https://github.com/fchollet/keras
$ cd keras
$ sudo python setup.py install
Watch video tutorial for complete installation procedure
Conclusion
Cheers!
Our workstation has been set now. You can now start building machine leaning and deep learning applications.
sorry mate but the tensorflow-gpu is down so, what we can do? install tensorflow in the way that alway do?
then I would say yes.