Caffe Installation : Ubuntu 16.04

Prepare

  1. sudo apt update
  2. sudo apt install build-essential git libatlas-base-dev
  3. sudo apt-get install python-pip
  4. pip install --upgrade pip
  5. sudo apt-get install graphviz
  6. sudo pip install graphviz
  7. sudo apt install libprotobuf-dev libleveldb-dev libsnappy-dev libboost-all-dev libhdf5-serial-dev protobuf-compiler gfortran libjpeg62 libfreeimage-dev libgoogle-glog-dev libbz2-dev libxml2-dev libxslt-dev libffi-dev libssl-dev libgflags-dev liblmdb-dev python-yaml
  8. sudo apt-get install libopencv-dev python-opencv

Config

  1. # git clone https://github.com/BVLC/caffe. git
  2. # Or
  3. unzip caffe-master.zip 
  4. cd caffe-master/
  5. cp Makefile.config.example Makefile.config
  6.  
  7. d@ubuntu:~/Documents/caffe$ diff Makefile.config.example Makefile.config
  8. 8c8
  9. < # CPU_ONLY := 1
  10. ---
  11. > CPU_ONLY := 1
  12. 94c94
  13. < # WITH_PYTHON_LAYER := 1
  14. ---
  15. > WITH_PYTHON_LAYER := 1
  16. 97,98c97,98
  17. < INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
  18. < LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib
  19. ---
  20. > INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial/
  21. > LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial/
  22. d@ubuntu:~/Documents/caffe$

Compile & Test

  1. export LD_LIBRARY=$LD_LIBRARY:/usr/include/hdf5
  2. export PYTHONPATH=$PYTHONPATH:/home/d/Documents/caffe/python
  3. make pycaffe -j
  4. make all -j
  5. make test -j
  6. make runtest

virtual memory exhausted

  1. sudo mkdir /opt/images/
  2. sudo rm -rf /opt/images/swap
  3. sudo dd if=/dev/zero of=/opt/images/swap bs=1024 count=10240000
  4. sudo mkswap /opt/images/swap
  5. sudo swapon /opt/images/swap