/DeepLearningSettings

Deeplearning computer settings using caffe darknet matlab tensorflow movidius etc.

DeepLearning Computer Settings and test with darknet (With all the files' links, so don't worry about the version compilance)

My Computer hardware:

  • Intel Core i9-7920
  • 1080Ti x 2
  1. Create a bootable USB stick on macOS

Download ubuntu-16.04.1-desktop-amd64.iso [Link]

Create the bootable USB according to the [Link].

Attention: ubuntu-16.04.3-desktop-amd64.iso always cause error!

  1. Install Ubuntu16.04.1

Reinstall by reboot and F12, choose UEFI OPTIONS usb boot;

After login to Ubuntu, double click the icon on the desktop to reinstall ubuntu; Restart from the hard disk;

Attention: If choose from the LEGACY OPTIONS, it will cause the problem of unable to login to ubuntu and go to grub!

3.Install Nvidia GPU driver and CUDA 8.0

Attention!!!: There is a compaliance problem of Nvidia 1080Ti and Ubuntu16.04, so a special version of driver (NVIDIA-Linux-x86_64-384.130-no-compat32.run) needed. Else it will cause loop in start up of os system. Or you can install with (NVIDIA-Linux-x86_64-384.59.run) without Opengl, it also works.

Download NVIDIA-Linux-x86_64-384.130-no-compat32.run, NVIDIA-Linux-x86_64-384.59.run and cuda_8.0.61_375.26_linux.run [Link]

Need to update from 16.04.1 to 16.04.4 to install the driver(else have error of install driver):

sudo apt-get update
sudo apt-get upgrade
lsb_release -a

Install the driver: Ctrl+Alt+F1 -> login ->

sudo service lightdm stop 
sudo chmod 777 ./NVIDIA-Linux-x86_64-384.130-no-compat32.run
sudo ./NVIDIA-Linux-x86_64-384.130-no-compat32.run
reboot
nvidia-smi

or

sudo service lightdm stop 
sudo chmod 777 ./NVIDIA-Linux-x86_64-384.59.run
sudo ./NVIDIA-Linux-x86_64-384.59.run --no-opengl-files 
reboot
nvidia-smi

Re-install if dev/sda1:clean... error happens after reboot

Ctrl+Alt+F1 -> login ->

sudo mkdir /media/elab/sdd
sudo mount /dev/sdd /media/elab/sdd
cd /meida/elab/sdd/Amy
sudo service lightdm stop 
sudo chmod 777 ./NVIDIA-Linux-x86_64-384.130-no-compat32.run
sudo ./NVIDIA-Linux-x86_64-384.130-no-compat32.run
reboot

Install cuda 8.0(do not install driver again):

chmod 777 cuda_8.0.61_375.26_linux.run
sudo ./cuda_8.0.61_375.26_linux.run --override --no-opengl-lib     

Attention: OpenGL-lib will cause login loop!!!!!!(Waste my days!!!)

Change the cuda PATH permanently:

sudo gedit ~/.bashrc

Add:

export PATH=/usr/local/cuda-8.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64:$LD_LIBRARY_PATH
source ~/.bashrc
nvcc --version

Don’t need to try to run examples of CUDA.

If cannot find -lglut -lGL:

sudo apt-get install freeglut3-dev
sudo apt-get install libgl-dev

Attention: Should be CUDA8.0, CUDA9.0 is not supported by matlab2017a and will cause some error later.

  1. Download and install cuDNN7.0 (cudnn-8.0-linux-x64-v7.1.tgz) on ubuntu: [Link]
tar -xzvf cudnn-8.0-linux-x64-v7.1.tgz
sudo cp cuda/include/cudnn.h /usr/local/cuda-8.0/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda-8.0/lib64
sudo chmod a+r /usr/local/cuda-8.0/include/cudnn.h 
sudo rm -R cuda

Check the version of cudnn:

cat /usr/local/cuda-8.0/include/cudnn.h | grep CUDNN_MAJOR -A 2
  1. Install git cmake ccmake etc.
sudo apt-get update
sudo apt-get -y install build-essential cmake cmake-curses-gui git libboost-all-dev libgflags-dev libgoogle-glog-dev uuid-dev libboost-filesystem-dev libboost-system-dev libboost-thread-dev ncurses-dev
sudo apt-get -y install libatlas-base-dev libopenblas-base libopenblas-dev liblapack-dev liblapack3
sudo apt-get -y install libprotobuf-dev libleveldb-dev libsnappy-dev libhdf5-serial-dev liblmdb-dev protobuf-compiler unzip libtbb-dev libtbb2 pkg-config gfortran
sudo apt-get -y install python-protobuf python-scipy python-pip python-dev python-numpy libboost-python-dev python-all-dev python-h5py python-matplotlib python-numpy python-pil python-pydot python-skimage python-sklearn 
sudo apt-get install python3-pip 

Download and install Eigen [Link]:

tar xzvf eigen-3.3.4.tar.gz 
cd eigen
mkdir build
cd build
cmake ..
sudo make install
  1. Download and install OpenCV [Link]:
sudo apt-get install build-essential
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
sudo apt-get install liblapacke-dev
cd opencv
mkdir release
cd release
ccmake ..

set OPENCV_EXTRA_MODULE_PATH as /media/elab/sdd/Amy/opencv_contrib/modules, configure, configure and generate, then:

cmake -D OPENCV_EXTRA_MODULE_PATH=/media/elab/sdd/Amy/opencv_contrib/modules \
    -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D WITH_CUDA=ON \
    -D ENABLE_FAST_MATH=1 \
    -D CUDA_FAST_MATH=1 \
    -D WITH_CUBLAS=1 \
    ..
make -j`nproc` 
sudo make install

Add the path permanently:

sudo gedit ~/.bashrc

Add:

export PATH=/usr/local/cuda-8.0/bin:/usr/local/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64:/usr/local/lib:$LD_LIBRARY_PATH

and don't forget:

source ~/.bashrc
  1. Install Darknet
git clone https://github.com/rockkingjy/darknet

Create folder weights/ in the darknet/, download the weights [Link], put all the weights inside, set the Makefile:

GPU=1
CUDNN=1
OPENMP=1

then run:

./darknet detector demo cfg/coco.data cfg/yolov3.cfg weights/yolov3.weights

If it run successfully, you will see the predictions.png in darknet/, that also mean your CUDA and cudnn installs correctly.

  1. Install Caffe (Direct makefile install and more details in https://github.com/rockkingjy/DeepLearningSettings/blob/master/caffe.md).

Update CMake to compatible with Boost version:

Boost 1.63 requires CMake 3.7 or newer.
Boost 1.64 requires CMake 3.8 or newer.
Boost 1.65 and 1.65.1 require CMake 3.9.3 or newer.
Boost 1.66 requires CMake 3.11 or newer.
Boost 1.67 is only supported by CMake master since March 2018.
apt-get remove cmake
git clone https://gitlab.kitware.com/cmake/cmake.git
cd cmake
./bootstrap
make -j12
make install

Download boost [Link] and install:

sudo ./bootstrap.sh
sudo ./b2 install

It will install in \usr\local\include\boost and \usr\local\lib automatically.

If you use python 2.7, change the file in `caffe\cmake\Dependencies.cmake', replace:

    find_package(Boost 1.46 COMPONENTS python)

with

    find_package(Boost 1.46 COMPONENTS python27)
    set(Boost_PYTHON_FOUND ${Boost_python27}_FOUND})

Then camke, make and install:

git clone https://github.com/rockkingjy/caffe
cd caffe
mkdir build
cmake ..
make clean
make all -j`nproc`
make pycaffe
make install

then follow https://github.com/rockkingjy/Inference_RGB2D_caffe to run a RGB2Depth programme.

Attention!!! If caffe/build/ exists, remember first to delete it! If cmake .. directly, will create error!!!

  1. Install matlab2017 following: https://github.com/rockkingjy/DeepLearningSettings/blob/master/matlab.md