Skip to content

Instantly share code, notes, and snippets.

@AlexanderFabisch
Last active November 26, 2020 08:51
Show Gist options
  • Save AlexanderFabisch/6d826b62af87e3c0ac6f to your computer and use it in GitHub Desktop.
Save AlexanderFabisch/6d826b62af87e3c0ac6f to your computer and use it in GitHub Desktop.
Caffe installation for Ubuntu 14.04

My system

  • Ubuntu 14.04
  • GeFore GTX970

Table of Contents

Install GPU Driver

sudo service lightdm stop
sudo sh NVIDIA-Linux-x86_64-361.28.run

Install CUDA

Download it from https://developer.nvidia.com/cuda-downloads -> Linux -> x86_64 -> Ubuntu -> 14.04 -> deb (local)

instructions:

sudo dpkg -i cuda-repo-ubuntu1404-7-5-local_7.5-18_amd64.deb
sudo apt-get update
sudo apt-get install cuda
sudo reboot

add to .bashrc:

export PATH=/usr/local/cuda-<version>/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-<version>/lib64:$LD_LIBRARY_PATH

try to run the example:

cuda-install-samples-7.5.sh ~  # copies examples to ~/NVIDIA_CUDA-Samples_<version>
cd ~/NVIDIA_CUDA-Samples_7.5/5_Simulations/nbody
make
./nbody

Install cuDNN

download it from https://developer.nvidia.com/rdp/cudnn-download, requirement: CUDA compute capabilities >= 3.5

instructions:

tar -xzvf cudnn-7.0-linux-x64-v4.0-prod.tgz
cd cuda
sudo cp lib64/* /usr/local/cuda/lib64
sudo cp include/cudnn.h /usr/local/cuda/include

Install Caffe

instructions:

  • install dependencies
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev libsnappy-dev
# install leveldb:
wget https://leveldb.googlecode.com/files/leveldb-1.9.0.tar.gz
tar -xzf leveldb-1.9.0.tar.gz
cd leveldb-1.9.0
make
sudo mv libleveldb.* /usr/local/lib
cd include
sudo cp -R leveldb /usr/local/include
sudo ldconfig
  • Configure the build by copying and modifying the example Makefile.config for your setup. The defaults should work, but uncomment the relevant lines if using Anaconda Python.
cp Makefile.config.example Makefile.config
# Adjust Makefile.config (for example, if using Anaconda Python, or if cuDNN is desired)
make all && make test && make runtest
  • For cuDNN acceleration using NVIDIA’s proprietary cuDNN software, uncomment the USE_CUDNN := 1 switch in Makefile.config. cuDNN is ometimes but not always faster than Caffe’s GPU acceleration.
  • To compile the Python and MATLAB wrappers do make pycaffe and make matcaffe respectively. Be sure to set your MATLAB and Python paths in Makefile.config first!

Install Theano

instructions:

sudo apt-get install python-pip python-dev libopenblas-dev
sudo pip install numpy scipy
git clone git://github.com/Theano/Theano.git
cd Theano
python setup.py develop --user

You can run a simple test program to see whether Theano works with your GPU. See here for details.

Install Tensorflow

requirement: cuDNN for the GPU version

instructions

sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.8.0rc0-cp27-none-linux_x86_64.whl

Install Keras

instructions

git clone https://github.com/fchollet/keras.git
cd keras
sudo python setup.py install
# make the config directory accessible!
sudo chown -R <username> ~/.keras

Switching between backends: The configuration is stored in ~/.keras/keras.json:

{"epsilon": 1e-07, "floatx": "float32", "backend": "tensorflow"}

"backend" can either be "tensorflow" or "theano".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment