this setup support Ubuntu 18.04
- Install Prerequisites
- Setup NVIDIA Driver for your GPU
- Install CUDA
- Install cuDNN
- Install TensorRT
- Python and Other Dependencies
- Deep Learning Frameworks
- ROS Melodic
Before installing anything, let us first update the information about the packages stored on the computer and upgrade the already installed packages to their latest versions.
sudo apt-get update
sudo apt-get upgrade
Next, we will install some basic packages which we might need during the installation process as well in future.
sudo apt-get install -y build-essential cmake gfortran git pkg-config
follow this video and src
You can also install CUDA directly from the offline installer, but this is a little easier.
sudo apt update
sudo apt upgrade -y
mkdir install ; cd install
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
sudo add-apt-repository "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/ /"
sudo apt-get update
sudo apt-get -y install cuda-10-2
Download CuDNN here (BOTH the runtime and dev, deb) from: drive link 1 drive link 2 or nvidia source
sudo dpkg -i libcudnn7_7.6.5.32-1+cuda10.2_amd64.deb
sudo dpkg -i libcudnn7-dev_7.6.5.32-1+cuda10.2_amd64.deb
This method of installation installs cuda in /usr/include
and /usr/lib/cuda/lib64
, hence the file you need to look at is in /usr/include/cudnn.h
.
cat /usr/include/x86_64-linux-gnu/cudnn_v*.h | grep CUDNN_MAJOR -A 2
Download TensorRT drive link or nvidia source. Use version 7.0.
sudo dpkg -i nv-tensorrt-repo-ubuntu1804-cuda10.2-trt7.0.0.11-ga-20191216_1-1_amd64.deb
sudo apt update
sudo apt install tensorrt libnvinfer7
sudo gedit ~/.bashrc # open bashrc and copy lines below
export CUDA_HOME=/usr/local/cuda
export DYLD_LIBRARY_PATH=$CUDA_HOME/lib64:$DYLD_LIBRARY_PATH
export PATH=$CUDA_HOME/bin:$PATH
export C_INCLUDE_PATH=$CUDA_HOME/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=$CUDA_HOME/include:$CPLUS_INCLUDE_PATH
export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH
export LD_RUN_PATH=$CUDA_HOME/lib64:$LD_RUN_PATH
save gedit and write command:
source ~/.bashrc
Install dependencies of deep learning frameworks:
sudo apt-get install -y libprotobuf-dev libleveldb-dev libsnappy-dev libhdf5-serial-dev protobuf-compiler libopencv-dev
Next, we install Python 2 and 3 along with other important packages like boost, lmdb, glog, blas etc.
sudo apt-get install -y --no-install-recommends libboost-all-dev doxygen
sudo apt-get install -y libgflags-dev libgoogle-glog-dev liblmdb-dev libblas-dev
sudo apt-get install -y libatlas-base-dev libopenblas-dev libgphoto2-dev libeigen3-dev libhdf5-dev
sudo apt-get install -y python-dev python-pip python-nose python-numpy python-scipy python-wheel python-six
sudo apt-get install -y python3-dev python3-pip python3-nose python3-numpy python3-scipy python3-wheel python3-six
NOTE: If you want to use Python2, replace the following pip commands with pip2.
Before we use pip, make sure you have the latest version of pip.
pip3 install --upgrade pip
Now, we can install all the required python packages for deep learning frameworks:
pip3 install numpy matplotlib ipython protobuf jupyter mock
pip3 install scipy scikit-image scikit-learn
pip3 install opencv-python==4.5.3 opencv-contrib-python==4.5.3
Upgrade numpy to the latest version:
sudo pip3 install --upgrade numpy
You can run the commands for installing pip packages torch
and torchvision
from the Quick Start section here.
pip install torch==1.6.0 torchvision==0.7.0
A quick way to install TensorFlow using pip without building is as follows. However this is not recomended as we have several specific versions of GPU libraries to improve performance, which may not be available with the pip builds.
sudo pip3 install tensorflow-gpu
First clone the Darknet git repository.
git clone https://github.com/AlexeyAB/darknet.git
Now, to compile Darknet with CUDA, CuDNN and OpenCV support, open the Makefile
from the darknet
folder and make the changes as following in the beginning of this file. Also make sure to select the right architecture based on your GPU's compute capibility. For Volta, Xavier, Turing and higher architecture you may want to use this version of Darknet by AlexeyAB and compile with the CUDNN_HALF=1
flag for 3x speed improvement.
Chage Makefile
GPU=1
CUDNN=1
OPENCV=1
LIBSO=1
Check Nvidia Compute Capability your card and change lines
Once done, just run make from the darknet folder.
cd darknet
make
Refer here for more details on running YOLO and training the network.
wget https://github.com/tonhathuy/setup-racing-car-ubuntu/blob/main/src/setup-ros.sh
sudo chmod +x ./setup-ros.sh
./setup-ros.sh