Skip to content

Instantly share code, notes, and snippets.

@faizan1234567
Forked from FrancoisPl/caffe_install.md
Created September 20, 2022 06:51
Show Gist options
  • Save faizan1234567/b0d57ec267617619c47a99aed348f7be to your computer and use it in GitHub Desktop.
Save faizan1234567/b0d57ec267617619c47a99aed348f7be to your computer and use it in GitHub Desktop.
Installing caffe on ubuntu 16.04 with Anaconda

Caffe Installation

Credit

Thank you to Changjiang as most of the code here comes from this tutorial and I have only added a few lines in order to get caffe working.

Caffe and Anaconda

Install Anaconda (for Python 2.7) Then clone the caffe repository somewhere:

git clone git@github.com:BVLC/caffe.git

Cuda

You will want to install CUDA in order to be able to run models on the GPU: Follow the tutorial here: https://developer.nvidia.com/cuda-downloads

Packages for Anaconda

conda update conda
conda install -c menpo opencv3
conda install libgcc

Install caffe dependencies

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y build-essential cmake git pkg-config
sudo apt-get install -y libprotobuf-dev libleveldb-dev libsnappy-dev protobuf-compiler
sudo apt-get install -y libatlas-base-dev 
sudo apt-get install -y --no-install-recommends libboost-all-dev
sudo apt-get install -y libgflags-dev libgoogle-glog-dev liblmdb-dev
sudo apt-get install libopencv-dev libhdf5-serial-dev
sudo apt-get -y install build-essential cmake git libgtk2.0-dev pkg-config python-dev python-numpy libdc1394-22 libdc1394-22-dev libjpeg-dev libpng12-dev libtiff5-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libxine2-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev libtbb-dev libqt4-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils unzip

Build caffe

cd path/caffe_repository
cp Makefile.config.example Makefile.config

Change the settings in Makefile.config (namely uncomment settings for anaconda).

mkdir build
cd build
cmake ..
make all
make install
make runtest

If there is no error, then run

conda install cython scikit-image ipython h5py nose pandas protobuf pyyaml jupyter
cd ../python

Add the module directory to your $PYTHONPATH by

export PYTHONPATH=`pwd`${PYTHONPATH:+:${PYTHONPATH}}

Test Run

First verify the installation:

python -c "import caffe;print caffe.__version__"

If the Caffe version number is shown up correctly, then change directory to examples, execute command:

jupyter notebook

Choose one of the notebook examples to test the Caffe installation.

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