Saturday, October 7, 2017

Install Caffe on Ubuntu 16.04 (CPU only)


  1. Install a clean Ubuntu 16.04 and mkdir workspace
  2. sudo apt install git and git clone https://github.com/BVLC/caffe
  3. sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
  4. sudo apt-get install libatlas-base-dev
  5. sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
  6. Go to python folder inside the caffe directory: cd python/
  7. Install pip: sudo apt install python-pip
  8. Upgrade pip: sudo -H pip install --upgrade pip
  9. Install all the dependency in requirements.txt via: 
    1. for req in 'cat requirements.txt'; do pip install $req; done
    2. sudo pip install -r requirements.txt
  10. sudo apt-get install python-dev
  11. sudo apt-get install -y python-numpy python-scipy
  12. sudo apt-get install --no-install-recommends libboost-all-dev
  13. Go to caffe folder and cp Makefile.config.example Makefile.config. 
  14. Edit Makefile.config: 
    1. INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial
    2. LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/hdf5/serial
    3. Uncomment: CPU_ONLY := 1 if this is CPU only mode
  15. Now make!
    1. make pycaffe
    2. make all
    3. make test
    4. make runtest
    5. make distribute
  16. export PYTHONPATH=/path/to/caffe/python:$PYTHONPATH
  17. Verify by running python2.7:
    1. >>> import caffe
    2. >>> caffe._version__
  18. Install opencv: 
    1. sudo apt-get install python-opencv
    2. sudo pip install opencv-python
  19. Install lmdb: sudo pip install lmdb
You should be able to see All Pass. Happy Ending. 
http://blog.csdn.net/qq_25737169/article/details/77773884

No comments:

Post a Comment