Setting Up Caffe and Digits for Machine Learning

Setting Up Caffe and Digits for Machine Learning

Caffe Installation on Ubuntu 16:04

Step 1

Find all the install instructions at Caffe but here I have done a step by step with error debugging as well.
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev lib

Step 2

sudo apt-get install libatlas-base-dev

Step 3

$mkdir MachineLearning
$cd MachineLearning
$git clone https://github.com/BVLC/caffe.git Caffe
$cd Caffe/
$cp Makefile.config.example Makefile.config
$sudo make all
fatal error: boost/shared_ptr.hpp: No such file or directory compilation terminated
 
#Tried this so not sure if it affected it
$sudo apt install cmake
#This worked
$sudo apt-get install libboost-all-dev
$sudo make all
fatal error: gflags/gflags.h: No such file or directory compilation terminated
 
#Inside your Caffe folder
$wget https://github.com/schuhschuh/gflags/archive/master.zip
$unzip master.zip
$cd gflags-master
$mkdir build && cd build
$export CXXFLAGS="-fPIC" && cmake .. && make VERBOSE=1
$make
$sudo make install
$cd ..
$cd ..
$sudo make all
fatal error: glog/logging.h: No such file or directory compilation terminated.
 
$sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
$sudo make all
fatal error: hdf5.h: No such file or directory compilation terminated.
 
$cd /usr/lib/x86_64-linux-gnu
$sudo ln -s libhdf5_serial.so.8.0.2 libhdf5.so
$sudo ln -s libhdf5_serial_hl.so.8.0.2 libhdf5_hl.so
$cd
$cd MachineLearning/Caffe
$sudo make all
fatal error: hdf5.h: No such file or directory compilation terminated.
 
$find . -type f -exec sed -i -e 's^"hdf5.h"^"hdf5/serial/hdf5.h"^g' -e 's^"hdf5_hl.h"^"hdf5/serial/hdf5_hl.h"^g' '{}' \;
$sudo make all
/usr/bin/ld: cannot find -lhdf5_hl
# Ran the following but not sure what fixed it but try this order
# Change in your Makefile.config LIBRARY_DIRS to LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial
# $sudo ln -s libhdf5_serial.so.10.1.0 libhdf5.so
# $sudo ln -s libhdf5_serial_hl.so.10.0.2 libhdf5_hl.so
# $sudo ln -s libhdf5_serial.so.10.1.0 lhdf5.so
# $sudo ln -s libhdf5_serial_hl.so.10.0.2 lhdf5_hl.so
$sudo make all
$make test && make runtest

Step 4

#In Caffe Directory still
$cd python
$sudo apt install python-pip
$pip install -r requirements.txt
$cd ..
$make pycaffe && make pytest
#fatal error: numpy/arrayobject.h: No such file or directory compilation terminated.
$sudo apt-get install python-numpy
$make pycaffe && make pytest
$make distribute

Set Path To Caffe

$vim ~/.bashrc
#At the bottom add
export CAFFE_ROOT=~/MachineLearning/Caffe/
export PATH

Step 5

Install Digits or another tutorial here
#Bugs for Digits
#No module named flask.ext.socketio
$pip install Flask
$pip install flask-socketio
 
~/digits$ ./digits-devserver
#ImportError: No module named psutil
$pip install psutil

$./digits-devserver
#ImportError: No module named skfmm
$sudo pip install scikit-fmm

#exc_class = default_exceptions[exc_class_or_code]
#KeyError: 300
$sudo pip uninstall Flask
$pip install Flask==0.10.1

#No module names lmdb
$pip install lmdb
$OSError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/
$sudo chown -R $USER /usr/local/lib/python2.7/
 
$./digits-devserver
#ImportError: No module named pydot
$pip install pydot
$./digits-devserver
Now digits should run. If you go to localhost:5000 you should see the welcome page. Continue to set up you machine learning here

Categories: Posts