Skip to content
This repository has been archived by the owner on Nov 19, 2018. It is now read-only.

Installation Guide Ubuntu GPU

Arjun Kava edited this page May 25, 2018 · 6 revisions

Follow steps to install caffe with GPU support

Step 1: Pre Installation CUDA Verify drivers

verify NVIDIA card installed

following command displays details of card installed:

lspci | grep -i nvidia

verify GCC and G++ installed

following command outputs version of gcc which needs to be gcc-6, required by CUDA to install

gcc --version

to run multiple gcc, click here

Step 2: Install CUDA

Blacklist nouveau and update GRUB

echo "blacklist nouveau" >> /etc/modprobe.d/blacklist-nouveau.conf

echo "options nouveau modeset=0" >> /etc/modprobe.d/blacklist-nouveau.conf

now regenerate kernel initrampfs using following command

update-initramfs -u

reboot system, screen will display zoomed out as no driver loaded for graphics

Download Deb Installer

download latest stable version of CUDA .deb installer file from here

Run Installer

then run deb installer:

dpkg -i cuda-repo-ubuntu17XX_X.X.XX-1_amd64.deb

apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1710/x86_64/7fa2af80.pub

apt-get update

apt-get install cuda

if it will throw error regarding unable to overwrite library then execute using following command:

apt-get -o Dpkg::Options::="--force-overwrite" install cuda --fix-broken

Post Installation for CUDA

update Lib Path and config lib64

export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}

export LD_LIBRARY_PATH=/usr/local/cuda/lib64\${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64

ldconfig /usr/local/cuda/lib64

Step 3: Install cuDnn

Download cuDnn

download matched version of cuDnn.tgz with CUDA installed from here

Extract and Install

tar -xvf cudnn-x.x-linux-x64-vx.x.tgz

will extract cuda folder which needs to move to actual CUDA installation

cp -r cuda/include/* /usr/local/cuda/include/

cp -r cuda/lib64/* /usr/local/cuda/lib64/

Step 4: Install necessary dependencies to compile Caffe

Caffe Dependencies

apt install -y libsnappy-dev libatlas-base-dev libboost-all-dev libgflags-dev libprotobuf-dev protobuf-compiler libgoogle-glog-dev libhdf5-serial-dev libleveldb-dev liblmdb-dev libatlas-base-dev libopenblas-dev git cmake tar curl wget

Open Cv dependencies

apt install python-dev python-pip python3-dev python3-pip

sudo apt install build-essential libgtk-3-dev

apt install -y zlib1g-dev libjpeg-dev libwebp-dev libpng-dev libtiff5-dev libjasper-dev libopenexr-dev libgdal-dev

apt install -y libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev yasm libopencore-amrnb-dev libopencore-amrwb-dev libv4l-dev libxine2-dev

apt install -y libtbb-dev libeigen3-dev

apt install -y doxygen

-H pip2 install -U pip numpy

-H pip3 install -U pip numpy

Step 5: Install Protobuf v2.5.0

download v2.5.0 from github

https://github.com/google/protobuf/releases/download/v2.5.0/protobuf-2.5.0.tar.gz

Extract tar

tar -xvf protobuf-2.5.0.tar.gz

Configure make

get into extracted directory and configure make

sh autogen.sh

sh configure --prefix=/usr

Compile protobuf

make clean

make all -j4

make install -j4

ldconfig

Step:6 Install caffenode-js-build

set CPU_ONLY = 1, for installing caffe with CPU mode (default mode) and CPU_ONLY = 0 for installing caffe with GPU mode.

npm install caffenode-js-build