Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Caffe with Python3 on Centos 7
/opt/caffe/lib
diff --git a/Makefile b/Makefile
index 985fffd..d19170d 100644
--- a/Makefile
+++ b/Makefile
@@ -191,7 +191,7 @@ ifeq ($(USE_OPENCV), 1)
endif
endif
-PYTHON_LIBRARIES := boost_python python2.7
+PYTHON_LIBRARIES ?= boost_python python2.7
WARNINGS := -Wall -Wno-sign-compare
##############################
/opt/caffe/python/
FROM centos:7
MAINTAINER graphaelli "http://g.raphaelli.com/2016/01/04/centos-python3-caffe.html"
RUN yum -y update && yum clean all
# python3 deps
RUN yum -y groupinstall 'Development Tools'
RUN yum -y install bzip2-devel db4-devel gdbm-devel libpcap-devel ncurses-devel openssl-devel readline-devel sqlite-devel xz-devel zlib-devel
# jupyter deps
RUN yum -y install epel-release
RUN yum -y install blas-devel freetype-devel gcc gcc-c++ gcc-fortran git hdf5-devel lapack-devel libjpeg-turbo-devel libpng-devel make opencv-devel patch readline-devel zeromq-devel
COPY jupyter-requirements.txt /tmp/
# caffe deps
RUN yum -y install epel-release
RUN yum -y install freetype-devel gflags-devel git glog-devel hdf5-devel leveldb-devel libjpeg-turbo-devel libpng-devel lmdb-devel openblas-devel opencv-devel snappy-devel
# install python 3.5.1
RUN curl https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tar.xz | tar Jx && \
pushd Python-3.5.1 && ./configure --prefix=/usr --enable-shared --with-ensurepip=install && \
make && make install && ldconfig && \
popd && rm -rf Python-3.5.1
# install tini
RUN curl -L https://github.com/krallin/tini/releases/download/v0.6.0/tini > tini && \
echo "d5ed732199c36a1189320e6c4859f0169e950692f451c03e7854243b95f4234b *tini" | sha256sum -c - && \
mv tini /usr/local/bin/tini && \
chmod +x /usr/local/bin/tini
# install boost linked to python3
RUN curl -o boost_1_60_0.tar.bz2 -L 'http://downloads.sourceforge.net/project/boost/boost/1.60.0/boost_1_60_0.tar.bz2' && \
echo "686affff989ac2488f79a97b9479efb9f2abae035b5ed4d8226de6857933fd3b boost_1_60_0.tar.bz2" | sha256sum -c - && \
tar jxf boost_1_60_0.tar.bz2 && \
pushd boost_1_60_0 && \
./bootstrap.sh --with-python=python3 && \
perl -pi -e 's!(\Qincludes ?= $(prefix)/include/python$(version)\E)!\1m!' tools/build/src/tools/python.jam && \
./b2 install --prefix=/usr && \
ldconfig && \
popd && rm -rf boost_1_60_0 boost_1_60_0.tar.bz2
# install recent protobuf
RUN curl -o protobuf-2.6.1.tar.bz2 -L https://github.com/google/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.bz2 && \
echo "ee445612d544d885ae240ffbcbf9267faa9f593b7b101f21d58beceb92661910 protobuf-2.6.1.tar.bz2" | sha256sum -c - && \
tar xjf protobuf-2.6.1.tar.bz2 && \
pushd protobuf-2.6.1/ && \
./configure --prefix=/usr && make && make install && \
ldconfig && \
popd && rm -rf protobuf-2.6.1 protobuf-2.6.1.tar.bz2
# install jupyter deps
RUN pip3 install -r /tmp/jupyter-requirements.txt
# install caffe
COPY caffe.patch /
COPY Makefile.config /
COPY caffe-ld-so.conf /etc/ld.so.conf.d/
RUN git clone https://github.com/BVLC/caffe.git && \
pushd caffe && \
patch -i /caffe.patch && \
cp /Makefile.config . && \
make all pycaffe distribute && \
mkdir -p /opt && mv distribute /opt/caffe && \
git rev-parse HEAD > /opt/caffe/git-rev && \
ldconfig && \
popd && rm -rf caffe
COPY caffe.pth /usr/lib/python3.5/site-packages/caffe.pth
RUN pip3 install scikit-image && pip3 install --pre protobuf
RUN mkdir -p -m 755 /etc/jupyter/ && echo "c.NotebookApp.ip = '*'" >> /etc/jupyter/jupyter_notebook_config.py
RUN yum clean all
EXPOSE 8888
ENTRYPOINT ["tini", "--"]
CMD ["jupyter-notebook", "--no-browser", "--notebook-dir=/notebooks"]
cycler==0.9.0
decorator==4.0.6
ipykernel==4.2.1
ipython==4.0.1
ipython-genutils==0.1.0
ipywidgets==4.1.1
Jinja2==2.8
jsonschema==2.5.1
jupyter==1.0.0
jupyter-client==4.1.1
jupyter-console==4.0.3
jupyter-core==4.0.6
MarkupSafe==0.23
matplotlib==1.5.0
mistune==0.7.1
nbconvert==4.1.0
nbformat==4.0.1
notebook==4.0.6
numpy==1.10.2
pandas==0.17.1
path.py==8.1.2
pexpect==4.0.1
pickleshare==0.5
ptyprocess==0.5
Pygments==2.0.2
pyparsing==2.0.7
python-dateutil==2.4.2
pytz==2015.7
pyzmq==15.1.0
qtconsole==4.1.1
readline==6.2.4.1
scipy==0.16.1
seaborn==0.6.0
simplegeneric==0.8.1
six==1.10.0
terminado==0.5
tornado==4.3
traitlets==4.0.0
# install scikit-learn last for numpy and scipy setup.py dependencies
scikit-learn==0.17
CPU_ONLY := 1
CUDA_DIR := /usr/local/cuda
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 := open
BLAS_INCLUDE := /usr/include/openblas
BLAS_LIB := /usr/lib64
PYTHON_INCLUDE := /usr/include/python3.5m /usr/lib/python3.5/site-packages/numpy/core/include
PYTHON_LIB := /usr/lib
PYTHON_LIBRARIES := boost_python python3.5m
INCLUDE_DIRS := $(PYTHON_INCLUDE)
LIBRARY_DIRS := $(PYTHON_LIB) /usr/lib
BUILD_DIR := build
DISTRIBUTE_DIR := distribute
TEST_GPUID := 0
Q ?= @
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment