forked from jfemiani/facade-segmentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
139 lines (110 loc) · 4.45 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# from https://github.com/BVLC/caffe/blob/master/docker/standalone/gpu/Dockerfile
FROM nvidia/cuda:7.5-cudnn3-devel-ubuntu14.04
MAINTAINER [email protected]
# Handy instructions:
# Install nvidia-docker
# https://github.com/NVIDIA/nvidia-docker/wiki/Installation
#
# I will ASSUME you are in the top level directory of this repo when you type this...
#
# To build the image:
#
# nvidia-docker build -t facades docker/gpu
#
# To start the container:
#
# sudo nvidia-docker run -it -v ${PWD}:/workspace facades
#
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-scipy \
vim && \
rm -rf /var/lib/apt/lists/*
# Used by the facade processing shell scripts in order to package up our results
RUN apt-get install zip
ENV CAFFE_ROOT=/opt/caffe
WORKDIR $CAFFE_ROOT
RUN python -m pip install -U pip
RUN pip install scikit-learn -U
RUN pip install scikit-image -U
# NOTE: Do not install any python packages after building segnet!
# The risk of an incompatability is just too great.
# Segnet ends up compiling against the particular version of numpy/opencv that
# are present when it is build.
# NOTE: I _wanted_ to use the latest (or a leter) version of cudnn because I thought it could
# improve performance, but TomoSaemann's repo does not unclude the modifications needed
# to the Dropout layer that are needed for bayesian inference.
#
# # ENV SEGNET_REPO=https://github.com/TimoSaemann/caffe-segnet-cudnn5
ENV SEGNET_REPO=https://github.com/alexgkendall/caffe-segnet
RUN git clone --depth 1 ${SEGNET_REPO} .
RUN for req in $(cat python/requirements.txt) pydot; do pip install $req; done && \
mkdir build && cd build
# NOTE: I _could_ make a Makefile and usin the Dockerfile 'ADD' command instead
# of appendining to the example like this, but this seems to work.
RUN cp Makefile.config.example Makefile.config
RUN echo USE_CUDNN := 1 >> Makefile.config
RUN echo WITH_PYTHON_LAYER := 1 >> Makefile.config
RUN make -j
RUN make -j python
RUN make -j pycaffe
#NOTE: I am considering shipping a Jupyter interface to help guide people through
# the software, but for processing lot's of data I prefer bash
RUN pip install jupyter scipy xmltodict configargparse
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
#NOTE: I am not sure that this line is necessary given the 'ldconfig' stuff above; I
# had an unrelated issue and added this just-in-case
ENV LD_LIBRARY_PATH=${CAFFE_ROOT}/build/lib:$LD_LIBRARY_PATH
# This is used by the finish-training.sh script to set the I12 caffe model weights in an
# environment variable.
RUN apt-get install coreutils
#NOTE: I am not sure what the purpose of a 'VOLUME' in a Dockerfile is, as it seems that
# you still have to
# This is a volume used to hold the output
# Use -v /path/to/output:/output in order to preserve the output
VOLUME /output
# This is a voume used to hold the data
# Use -v /path/to/data:/data in order to provide your data
VOLUME /data
# I generate plots (often to files), and this does not work by default on systems without
# an X-server setup properly (such as docker images...) so I am setting it up to use Agg for plotting.
ENV MATPLOTLIBRC ${HOME}/.config/matplotlib
RUN mkdir -p ${MATPLOTLIBRC}
RUN echo backend: Agg > ${MATPLOTLIBRC}/matplotlibrc
# Expose some ports for http or ipynb
# EXPOSE 80
# EXPOSE 8888
RUN \
apt-get update && \
apt-get install -y sudo curl git && \
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash && \
sudo apt-get install git-lfs
# Add files to the container
WORKDIR /opt
RUN git clone https://github.com/jfemiani/facade-segmentation /opt/facades
ENV PYTHONPATH=/opt/facades:${PYTHONPATH}
RUN ln -s /opt/facades/scripts/i12-inference/generate /usr/bin/i12-inference
RUN ln -s /opt/facades/scripts/i12-inference/generate /usr/bin/inference
VOLUME /workspace
WORKDIR /workspace
CMD /bin/bash