Installing Caffe on a fresh-installed ubuntu 16.04 (please fully update ubuntu software first), with cuda 8.0 and cudnn v6.
1. Install NVIDIA driver.
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get install nvidia-390 (check the gpu drive number on NVIDIA website, and change it to fit your GPU. E.x., 390 is for Titan X)
sudo shutdown -r now
2. Install CUDA 9.0.
Download cuda 9.0 from (https://developer.nvidia.com/cuda-90-download-archive)
Install 9.0 for Tensorflow, 8.0 for matconvnet.
cd ~/Downloads
sudo dpkg -i cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64.deb
sudo apt-get update
sudo apt-get install cuda
echo 'export PATH=/usr/local/cuda/bin:$PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
compile cuda samples, open a new terminal:
cuda-install-samples-8.0.sh ~/cuda-samples
cd ~/cuda-samples/NVIDIA*Samples
make -j $(($(nproc) + 1))
sudo shutdown -r now
check cuda installation, open a new terminal:
cd ~/cuda-samples/NVIDIA*Samples
bin/x86_64/linux/release/deviceQuery
bin/x86_64/linux/release/bandwidthTest
3. Install CUDNN v6.
Download cudnn v6 from (https://developer.nvidia.com/cudnn)
Install v6 for Tensorflow, 5.1 for matconvnet.
cd ~/Downloads/
tar xvf cudnn*.tgz
cd cuda
sudo cp */*.h /usr/local/cuda/include/
sudo cp */*.so* /usr/local/cuda/lib64/
Remove old Cudnn and upgrade to new ones:
download cudnn6.0 version (not latest 7.0)
sudo rm -rf /usr/local/cuda/include/cudnn.h
sudo rm -rf /usr/local/cuda/lib64/libcudnn*
to cudnn untar folders
sudo cp include/cudnn.h /usr/local/cuda/include/
sudo cp lib64/lib* /usr/local/cuda/lib64/
cd /usr/local/cuda/lib64/
sudo chmod +r libcudnn.so.6.0.21
sudo ln -sf libcudnn.so.6.0.21 libcudnn.so.6
sudo ln -sf libcudnn.so.6 libcudnn.so
sudo ldconfig
4. Install Anaconda.
Download Anaconda from (https://www.anaconda.com/download/#linux)
cd ~/Downloads
bash Anaconda*.sh
Log out and log in again to activate the new variables (close and open the terminal).
5. Install other dependencies.
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
sudo apt-get install --no-install-recommends libboost-all-dev
sudo apt-get install libopenblas-dev
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
create symbolic link for hdf5:
cd /usr/lib/x86_64-linux-gnu
sudo ln -s libhdf5_serial.so.10.1.0 libhdf5.so
sudo ln -s libhdf5_serial_hl.so.10.0.2 libhdf5_hl.so
6. Download Caffe.
open a new terminal,
git clone https://github.com/BVLC/caffe
download and copy the attached Makefile.config into caffe folder
7. Build Caffe.
open a terminal in caffe folder
make all -j $(($(nproc) + 1))
make test -j $(($(nproc) + 1))
make runtest -j $(($(nproc) + 1))
pip install protobuf
make pycaffe -j $(($(nproc) + 1))
echo "export CAFFE_ROOT=$(pwd)" >> ~/.bashrc
echo 'export PYTHONPATH=$CAFFE_ROOT/python:$PYTHONPATH' >> ~/.bashrc
conda install libgcc
8. Test the Caffe installation.
open a new terminal
python
import caffe
9. Matcaffe.
http://www.cs.jhu.edu/~cxliu/2016/compiling-matcaffe-on-ubuntu-1604.html
make matcaffe
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6
export LD_PRELOAD=$LD_PRELOAD:/usr/lib/x86_64-linux-gnu/libstdc++.so.6:/usr/lib/x86_64-linux-gnu/libprotobuf.so.9
10. MatConvnet.
Download the latest MatConvnet
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6:/usr/lib/x86_64-linux-gnu/libprotobuf.so.9
vl_compilenn('enableGpu', true, ...
'enableCudnn', true) ;
11. Tensorflow (Binary).\
Install tensorflow via pip:
sudo apt-get install python-pip python-dev
sudo pip install -U pip
pip install -U tensorflow-gpu==1.4.0 --user
python -c "import tensorflow as tf; print(tf.__version__)"
12. Tensorflow (Sources).\
Install bazel: sudo bash ./bazel....sh
Install NCCL: tar xvf nccl-<version>.txz (https://docs.nvidia.com/deeplearning/sdk/nccl-install-guide/index.html)
Download tensorflow: git clone https://github.com/tensorflow/tensorflow
cd tensorflow
./configure
13. Eclipse C++.\
sudo apt install -y eclipse-cdt-*
URL=https://www.eclipse.org/downloads/download.php
ECLIPSE=/oomph/epp/oxygen/R/eclipse-inst-linux64.tar.gz
MIRROR=1
wget -q -O eclipse-inst-linux64.tar.gz \
"${URL}?file=${ECLIPSE}&mirror_id=${MIRROR}"
tar zxf eclipse-inst-linux64.tar.gz
./eclipse-installer/eclipse-inst
Open a text editor
Copy and paste the following text into the editor:
[Desktop Entry]
Version=1.0
Name=Eclipse
Comment=Java IDE
Type=Application
Categories=Development;IDE;
Exec=/home/yixin/eclipse/cpp-oxygen/eclipse/eclipse
Terminal=false
StartupNotify=true
Icon=/home/yixin/eclipse/cpp-oxygen/eclipse/icon.xpm
Name[en_US]=Eclipse
Update any paths if you extracted Eclipse to a different location
Save the file as eclipse.desktop in /home/{username}/.local/share/applications/
Reboot your machine
Search for Eclipse
Drag and drop the Eclipse icon to the launcher
Cheers!
Feel free to contact me at (yixindu1573@gmail.com) for any questions.