Installing Tensorflow(GPU), OpenCV and dlib on Ubuntu 18.04 Bionic Beaver

Image source:

For those who are ready for machine learning and computer vision with the updated versions of OpenCV, dlib, Tensorflow (GPU) on the Bionic Beaver.

Install synaptic and atom from Ubuntu’s package manager

sudo ubuntu-drivers autoinstall
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update

search and install nvidia-390 from synaptic

Download CUDA 9.0 (It has to be 9.0 for Tensorflow 1.8):

And Download cuDNN v7.1.3 for CUDA 9.0:

sudo chmod +x
sudo chmod +x
sudo chmod +x
sudo ./ --override
sudo ./
sudo ./

DO NOT INSTALL THE DRIVER AND SAMPLES IN THIS PART! Ignore the fact that they give you a warning for the driver not being installed. This is because the installer cannot detect the installed driver in your system, which we installed earlier through synaptic.

sudo apt-get install cuda-9
sudo apt-get upgrade
tar -zxvf cudnn-9.0-linux-x64-v7.1.tgz
sudo cp -P cuda/lib64/* /usr/local/cuda-9.0/lib64/
sudo cp  cuda/include/* /usr/local/cuda-9.0/include/
sudo chmod a+r /usr/local/cuda-9.0/include/cudnn.h
sudo apt-get install libcupti-dev
sudo atom ~/.bashrc

And add these lines:

export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

source ~/.bashrc
sudo apt-get update
sudo apt-get install build-essential cmake libopenblas-dev liblapack-dev libx11-dev libgtk-3-dev python python-dev python-pip python3 python3-dev python3-pip

Download and install Anaconda Python 3.6 (I use 3.6 universally and 2.7 for scientific computations)

Create environment using an environment name (envname)

conda create -n envname python=2.7
source activate envname
pip install numpy pillow lxml jupyter matplotlib dlib protobuf
sudo apt -y install python-opencv
conda install -c conda-forge opencv 
sudo snap install protobuf --classic
pip install --upgrade tensorflow-gpu

To KILL process and clear memory of GPU:


and kill the process causing unwanted memory usage

sudo kill -20483 PID.

Machine learning to improve experimental fluid flow analysis

Most analysis in experimental fluid dynamics uses techniques to track flow, by seeding the flow with particles. Humans with eye and the extraordinarily fascinating brain are undoubtedly the best system to identify and track moving objects or particles. The only issue with that is,  human beings are slower for tracking thousands of particles/ objects over time, get tired over time and can sometimes lead to error as a result of tiredness/ fatigue.

Most popular experimental techniques in the fluid flow analysis domain include particle image velocimetry- PIV (used for a high density of particles) and particle tracking velocimetry-PTV. The accuracy of both the methods depends on the algorithm used, the quality of images and the validation to ground truth. Most major companies that produce these PIV and PTV systems such as Dantec Dynamics have a pre-calibrated system and employ robust methods, which yield results that are ready for publication. However, the use of free and open source software, often untested for a given condition and set of particles, produce erroneous results. In the case of PTV systems, there is another complication; this arises due to the existence of particle tracking methods used by surface chemists(e.g., to look at Brownian motion), that produce inaccurate results when used for fluid dynamic analysis.  A classic example of this transpired when I used a particle tracking system used by surface chemists, which produced erroneous results for an oscillatory flow. However, when I used a correction factor calculation called “drift,” used to correct the velocity of particles when the flow field varies as a result of variation in the fluid containment such as in the case of a shaking beaker, there was a much better result, but still not accurate enough. Hence, such algorithms can cause serious errors and wrong interpretation of results, when used to look at fluid dynamics analysis.

The advent of new technologies and advanced machine learning techniques and state-of-the-art tools such as Tensorflow and DLib C++ can resolve such errors, producing highly accurate results and better interpretation of physics. These revolutionary technologies can help us understand fluid dynamics better than yesteryears.