Last active
October 16, 2018 10:09
-
-
Save naviocean/0959d52bfcf44436a5871eff901cb131 to your computer and use it in GitHub Desktop.
Caffe cuda9 ubuntu 16.04
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM nvidia/cuda:9.0-devel-ubuntu16.04 | |
MAINTAINER NaviOcean <[email protected]> | |
#install Cuda & Cudnn | |
ENV CUDNN_VERSION 7.2.1.38 | |
LABEL com.nvidia.cudnn.version="${CUDNN_VERSION}" | |
RUN apt-get update && apt-get install -y --no-install-recommends apt-utils \ | |
libcudnn7=$CUDNN_VERSION-1+cuda9.0 \ | |
libcudnn7-dev=$CUDNN_VERSION-1+cuda9.0 && \ | |
apt-mark hold libcudnn7 && \ | |
rm -rf /var/lib/apt/lists/* | |
RUN apt-get update && apt-get install -y --no-install-recommends \ | |
build-essential \ | |
cmake \ | |
git \ | |
wget \ | |
libatlas-base-dev \ | |
libboost-all-dev \ | |
libgflags-dev \ | |
libgoogle-glog-dev \ | |
libhdf5-serial-dev \ | |
libleveldb-dev \ | |
liblmdb-dev \ | |
libopencv-dev \ | |
libprotobuf-dev \ | |
libsnappy-dev \ | |
protobuf-compiler \ | |
python-dev \ | |
python-numpy \ | |
python-pip \ | |
python-setuptools \ | |
python-scipy && \ | |
rm -rf /var/lib/apt/lists/* | |
ENV CAFFE_ROOT=/opt/caffe | |
WORKDIR $CAFFE_ROOT | |
# FIXME: use ARG instead of ENV once DockerHub supports this | |
# https://github.com/docker/hub-feedback/issues/460 | |
ENV CLONE_TAG=1.0 | |
# upgrade pip | |
RUN pip install --upgrade pip | |
RUN hash -r | |
# Download caffe | |
RUN git clone -b ${CLONE_TAG} --depth 1 https://github.com/BVLC/caffe.git . | |
# Copy to Makefile.config | |
RUN cp Makefile.config.example Makefile.config | |
# Edit Makefile.config | |
RUN echo "PYTHON_INCLUDE := /usr/include/python2.7 /usr/lib/python2.7/dist-packages/numpy/core/include" >> Makefile.config && \ | |
echo "WITH_PYTHON_LAYER := 1" >> Makefile.config && \ | |
echo "INCLUDE_DIRS := \$(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial" >> Makefile.config && \ | |
echo "LIBRARY_DIRS := \$(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/hdf5/serial" >> Makefile.config | |
RUN sed -i -e 's/# USE_CUDNN := 1/ USE_CUDNN := 1/g' Makefile.config | |
RUN sed -i -e 's/-gencode arch=compute_20,code=sm_20/#-gencode arch=compute_20,code=sm_20/g' Makefile.config | |
RUN sed -i -e 's/-gencode arch=compute_20,code=sm_21/#-gencode arch=compute_20,code=sm_21/g' Makefile.config | |
# Edit Makefile | |
RUN sed -i -e 's/NVCCFLAGS += -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)/NVCCFLAGS += -D_FORCE_INLINES -ccbin=$(CXX) -Xcompiler -fPIC $(COMMON_FLAGS)/g' Makefile | |
RUN cat Makefile.config | |
# Install Caffe python requirements | |
RUN cd python && for req in $(cat requirements.txt) pydot; do pip install $req; done | |
RUN pwd | |
# Complie Caffe | |
RUN make all -j"$(nproc)" | |
RUN make test | |
RUN make pycaffe | |
ENV PYCAFFE_ROOT $CAFFE_ROOT/python | |
ENV PYTHONPATH $PYCAFFE_ROOT:$PYTHONPATH | |
ENV PATH $CAFFE_ROOT/build/tools:$PYCAFFE_ROOT:$PATH | |
RUN echo "$CAFFE_ROOT/build/lib" >> /etc/ld.so.conf.d/caffe.conf && ldconfig | |
WORKDIR / |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment