Skip to content

Commit

Permalink
Merge pull request deeplearningparis#19 from eickenberg/caffe2
Browse files Browse the repository at this point in the history
[ENH] add caffe installation
  • Loading branch information
charlesollion committed Jan 16, 2016
2 parents bf87365 + 4e871d4 commit e5a76b2
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 17 deletions.
106 changes: 106 additions & 0 deletions caffe-Makefile.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
## Refer to http://caffe.berkeleyvision.org/installation.html
# Contributions simplifying and improving our build system are welcome!

# cuDNN acceleration switch (uncomment to build with cuDNN).
# USE_CUDNN := 1

# CPU-only switch (uncomment to build without GPU support).
# CPU_ONLY := 1

# uncomment to disable IO dependencies and corresponding data layers
# USE_OPENCV := 0
# USE_LEVELDB := 0
# USE_LMDB := 0

# uncomment to allow MDB_NOLOCK when reading LMDB files (only if necessary)
# You should not set this flag if you will be reading LMDBs with any
# possibility of simultaneous read and write
# ALLOW_LMDB_NOLOCK := 1

# Uncomment if you're using OpenCV 3
# OPENCV_VERSION := 3

# To customize your choice of compiler, uncomment and set the following.
# N.B. the default for Linux is g++ and the default for OSX is clang++
# CUSTOM_CXX := g++

# CUDA directory contains bin/ and lib/ directories that we need.
CUDA_DIR := /usr/local/cuda
# On Ubuntu 14.04, if cuda tools are installed via
# "sudo apt-get install nvidia-cuda-toolkit" then use this instead:
# CUDA_DIR := /usr

# CUDA architecture setting: going with all of them.
# For CUDA < 6.0, comment the *_50 lines for compatibility.
CUDA_ARCH := -gencode arch=compute_20,code=sm_20 \
-gencode arch=compute_20,code=sm_21 \
-gencode arch=compute_30,code=sm_30 \
-gencode arch=compute_35,code=sm_35 \
-gencode arch=compute_50,code=sm_50 \
-gencode arch=compute_50,code=compute_50

# BLAS choice:
# atlas for ATLAS (default)
# mkl for MKL
# open for OpenBlas
BLAS := open
# Custom (MKL/ATLAS/OpenBLAS) include and lib directories.
# Leave commented to accept the defaults for your choice of BLAS
# (which should work)!
BLAS_INCLUDE := /opt/OpenBLAS-no-openmp/include
BLAS_LIB := /opt/OpenBLAS-no-openmp/bin

# Homebrew puts openblas in a directory that is not on the standard search path
# BLAS_INCLUDE := $(shell brew --prefix openblas)/include
# BLAS_LIB := $(shell brew --prefix openblas)/lib

# This is required only if you will compile the matlab interface.
# MATLAB directory should contain the mex binary in /bin.
# MATLAB_DIR := /usr/local
# MATLAB_DIR := /Applications/MATLAB_R2012b.app

# NOTE: this is required only if you will compile the python interface.
# We need to be able to find Python.h and numpy/arrayobject.h.
PYTHON_INCLUDE := /usr/include/python2.7 \
/home/ubuntu/venv/lib/python2.7/site-packages/numpy/core/include/numpy
# Anaconda Python distribution is quite popular. Include path:
# Verify anaconda location, sometimes it's in root.
# ANACONDA_HOME := $(HOME)/anaconda
# PYTHON_INCLUDE := $(ANACONDA_HOME)/include \
# $(ANACONDA_HOME)/include/python2.7 \
# $(ANACONDA_HOME)/lib/python2.7/site-packages/numpy/core/include \

# We need to be able to find libpythonX.X.so or .dylib.
PYTHON_LIB := /usr/lib/python2.7/config-x86_64-linux-gnu
# PYTHON_LIB := $(ANACONDA_HOME)/lib

# Homebrew installs numpy in a non standard path (keg only)
# PYTHON_INCLUDE += $(dir $(shell python -c 'import numpy.core; print(numpy.core.__file__)'))/include
# PYTHON_LIB += $(shell brew --prefix numpy)/lib

# Uncomment to support layers written in Python (will link against Python libs)
# WITH_PYTHON_LAYER := 1

# Whatever else you find you need goes here.
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib

# If Homebrew is installed at a non standard location (for example your home directory) and you use it for general dependencies
# INCLUDE_DIRS += $(shell brew --prefix)/include
# LIBRARY_DIRS += $(shell brew --prefix)/lib

# Uncomment to use `pkg-config` to specify OpenCV library paths.
# (Usually not necessary -- OpenCV libraries are normally installed in one of the above $LIBRARY_DIRS.)
# USE_PKG_CONFIG := 1

BUILD_DIR := build
DISTRIBUTE_DIR := distribute

# Uncomment for debugging. Does not work on OSX due to https://github.com/BVLC/caffe/issues/171
# DEBUG := 1

# The ID of the GPU that 'make runtest' will use to run unit tests.
TEST_GPUID := 0

# enable pretty build (comment to see full commands)
Q ?= @
38 changes: 22 additions & 16 deletions scripts/install-deeplearning-libraries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@
set -xe
cd $HOME

# Make it possible to pull from the HTTP remote when ssh environment is
# not available such for instance at boot time
if [ "$2" == 'http' ]; then
REMOTE="http"
else
REMOTE="origin"
fi

# Check that the NVIDIA drivers are installed properly and the GPU is in a
# good shape:
Expand Down Expand Up @@ -51,11 +44,10 @@ pip install -U circus circus-web Cython Pillow

# Checkout this project to access installation script and additional resources
if [ ! -d "dl-machine" ]; then
git clone [email protected]:deeplearningparis/dl-machine.git
(cd dl-machine && git remote add http https://github.com/deeplearningparis/dl-machine.git)
git clone https://github.com:deeplearningparis/dl-machine.git
else
if [ "$1" == "reset" ]; then
(cd dl-machine && git reset --hard && git checkout master && git pull --rebase $REMOTE master)
(cd dl-machine && git reset --hard && git checkout master && git pull --rebase origin master)
fi
fi

Expand Down Expand Up @@ -86,11 +78,10 @@ fi

# Tutorial files
if [ ! -d "DL4H" ]; then
git clone [email protected]:SnippyHolloW/DL4H.git
(cd DL4H && git remote add http https://github.com/SnippyHolloW/DL4H.git)
git clone https://github.com/SnippyHolloW/DL4H.git
else
if [ "$1" == "reset" ]; then
(cd DL4H && git reset --hard && git checkout master && git pull --rebase $REMOTE master)
(cd DL4H && git reset --hard && git checkout master && git pull --rebase origin master)
fi
fi

Expand All @@ -103,15 +94,30 @@ fi
. ~/torch/install/bin/torch-activate

if [ ! -d "iTorch" ]; then
git clone [email protected]:facebook/iTorch.git
(cd iTorch && git remote add http https://github.com/facebook/iTorch.git)
git clone https://github.com/facebook/iTorch.git
else
if [ "$1" == "reset" ]; then
(cd iTorch && git reset --hard && git checkout master && git pull --rebase $REMOTE master)
(cd iTorch && git reset --hard && git checkout master && git pull --rebase origin master)
fi
fi
(cd iTorch && luarocks make)


# Install caffe

sudo apt-get install -y protobuf-compiler libboost-all-dev libgflags-dev libgoogle-glog-dev libhdf5-serial-dev libleveldb-dev liblmdb-dev libsnappy-dev libopencv-dev libyaml-dev libprotobuf-dev

if [ ! -d "caffe" ]; then
git clone https://github.com/BVLC/caffe.git
(cd caffe && cp $HOME/dl-machine/caffe-Makefile.conf Makefile.conf && cmake -DBLAS=open . && make all)
(cd caffe/python && pip install -r requirements.txt)
else
if [ "$1" == "reset" ]; then
(cd caffe && git reset --hard && git checkout master && git pull --rebase origin master && cp $HOME/dl-machine/caffe-Makefile.conf Makefile.conf && cmake -DBLAS=open . && make all)
fi
fi


# Register the circus daemon with Upstart
if [ ! -f "/etc/init/circus.conf" ]; then
sudo ln -s $HOME/dl-machine/circus.conf /etc/init/circus.conf
Expand Down
2 changes: 1 addition & 1 deletion update-instance.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ stop on runlevel [!2345]
task

script
su - ubuntu -c 'bash /home/ubuntu/dl-machine/scripts/install-deeplearning-libraries.sh reset http'
su - ubuntu -c 'bash /home/ubuntu/dl-machine/scripts/install-deeplearning-libraries.sh reset'
end script

0 comments on commit e5a76b2

Please sign in to comment.