Monday, September 28, 2015

install caffe on nvidia jetson tk1 (ubuntu 14.04)

[1] install cuda 

wget -c http://developer.download.nvidia.com/compute/cuda/6_5/rel/installers/cuda-repo-l4t-r21.2-6-5-prod_6.5-34_armhf.deb

sudo dpkg -i cuda-repo-l4t-r19.2_6.0-42_armhf.deb

sudo apt-get update

sudo apt-get install cuda-toolkit-6-5

sudo usermod -a -G video $USER

(add 32bit lib to bashrc)
echo "# Add CUDA bin & library paths:" >> ~/.bashrc
echo "export PATH=/usr/local/cuda/bin:$PATH" >> ~/.bashrc
echo "export LD_LIBRARY_PATH=/usr/local/cuda/lib:$LD_LIBRARY_PATH" >> ~/.bashrc
source ~/.bashrc

(to check the nvcc version)
$nvcc -V

(to install the sdk)
go to /usr/local/cuda/bin
./cuda-install-samples-6.5.sh /home/your_user_folder

Note: Many of the CUDA samples use OpenGL GLX and open graphical windows. If you are running these programs through an SSH remote terminal, you can remotely display the windows on your desktop by typing "export DISPLAY=:0" and then executing the program. (This will only work if you are using a Linux/Unix machine or you run an X server such as the free "Xming" for Windows). eg: 

export DISPLAY=:0
cd ~/NVIDIA_CUDA-6.5_Samples/2_Graphics/simpleGL


[2] install opencv



the downloaded file is libopencv4tegra-repo_l4t-r21_2.4.10.1_armhf.deb


$ sudo dpkg -i libopencv4tegra-repo_l4t-r21_2.4.10.1_armhf.deb
$ sudo apt-get update
$ sudo apt-get install libopencv4tegra libopencv4tegra-dev


If you bumped into the dependency issue
$sudo apt-get -f install
$ sudo apt-get install libopencv4tegra libopencv4tegra-dev

download cudnn from https://developer.nvidia.com/cuDNN

run the procedures in this linkhttps://gist.github.com/jetsonhacks/fa9f4ff89006607359ea
then you have your cudnn with it.
as default the tk1 uses 6.5, so I download the 6.5 compatible one, version 2.
the current caffe requires cudnn >3, i used v3 armv7

[3] get Caffe

go to https://gist.github.com/jetsonhacks
download the ./installCaffe.sh

#!/bin/sh
# Install and compile Caffe on NVIDIA Jetson TK1 Development Kit
sudo add-apt-repository universe
sudo apt-get update
sudo apt-get install libprotobuf-dev protobuf-compiler gfortran \
libboost-dev cmake libleveldb-dev libsnappy-dev \
libboost-thread-dev libboost-system-dev \
libatlas-base-dev libhdf5-serial-dev libgflags-dev \
libgoogle-glog-dev liblmdb-dev -y
sudo usermod -a -G video $USER
# Git clone Caffe
sudo apt-get install -y git
git clone https://github.com/BVLC/caffe.git
cd caffe && git checkout dev
cp Makefile.config.example Makefile.config
make -j 4 all
make -j 4 runtest
build/tools/caffe time --model=models/bvlc_alexnet/deploy.prototxt --gpu=0

Noted that,
in order to use cudnn, you need to change makefile, turn on/add some options
http://elinux.org/Jetson/cuDNN

Since tk1 is cuda 3.2, I changed the arch in the Makefile.config to allow compiling only this architecture.



--------------------------------------------------------------------------------------------------------------------------
Reference:
*http://elinux.org/Jetson/Installing_CUDA
*https://developer.nvidia.com/linux-tegra-rel-21
*http://developer.download.nvidia.com/embedded/OpenCV/L4T_21.1/README.txt
* http://petewarden.com/2014/10/25/how-to-run-the-caffe-deep-learning-vision-library-on-nvidias-jetson-mobile-gpu-board/


No comments:

Post a Comment