-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathDockerfile.template
More file actions
119 lines (101 loc) · 3.24 KB
/
Dockerfile.template
File metadata and controls
119 lines (101 loc) · 3.24 KB
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
# Don't edit this file directly, since it was generated from a template,
# and you're changes will be *clobbered*. Edit the template instead.
{{ if .GPU }}
FROM tleyden5iwx/ubuntu-cuda
{{ else }}
FROM ubuntu:14.04
{{ end }}
ENV PYTHONPATH /opt/caffe/python
# Add caffe binaries to path
ENV PATH $PATH:/opt/caffe/.build_release/tools
# Get dependencies
RUN apt-get update && apt-get install -y \
bc \
cmake \
curl \
gcc-4.6 \
g++-4.6 \
gcc-4.6-multilib \
g++-4.6-multilib \
gfortran \
git \
libprotobuf-dev \
libleveldb-dev \
libsnappy-dev \
libopencv-dev \
libboost-all-dev \
libhdf5-serial-dev \
liblmdb-dev \
libjpeg62 \
libfreeimage-dev \
libatlas-base-dev \
pkgconf \
protobuf-compiler \
python-dev \
python-pip \
unzip \
wget
# Use gcc 4.6
RUN update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-4.6 30 && \
update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-4.6 30 && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 30 && \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 30
{{ if .GPU }}
# Allow it to find CUDA libs
RUN echo "/usr/local/cuda/lib64" > /etc/ld.so.conf.d/cuda.conf && \
ldconfig
{{ end }}
# Clone the Caffe repo
RUN cd /opt && git clone https://github.com/BVLC/caffe.git
{{ if .DEVELOP_BRANCH }}
RUN cd /opt/caffe && git checkout -t origin/dev
{{ end }}
# Glog
RUN cd /opt && wget https://google-glog.googlecode.com/files/glog-0.3.3.tar.gz && \
tar zxvf glog-0.3.3.tar.gz && \
cd /opt/glog-0.3.3 && \
./configure && \
make && \
make install
# Workaround for error loading libglog:
# error while loading shared libraries: libglog.so.0: cannot open shared object file
# The system already has /usr/local/lib listed in /etc/ld.so.conf.d/libc.conf, so
# running `ldconfig` fixes the problem (which is simpler than using $LD_LIBRARY_PATH)
# TODO: looks like this needs to be run _every_ time a new docker instance is run,
# so maybe LD_LIBRARY_PATh is a better approach (or add call to ldconfig in ~/.bashrc)
RUN ldconfig
# Gflags
RUN cd /opt && \
wget https://github.com/schuhschuh/gflags/archive/master.zip && \
unzip master.zip && \
cd /opt/gflags-master && \
mkdir build && \
cd /opt/gflags-master/build && \
export CXXFLAGS="-fPIC" && \
cmake .. && \
make VERBOSE=1 && \
make && \
make install
# Build Caffe core
RUN cd /opt/caffe && \
cp Makefile.config.example Makefile.config && \
{{ if .CPU }} echo "CPU_ONLY := 1" >> Makefile.config && \ {{ else }} \ {{ end }}
echo "CXX := /usr/bin/g++-4.6" >> Makefile.config && \
sed -i 's/CXX :=/CXX ?=/' Makefile && \
make all
# Add ld-so.conf so it can find libcaffe.so
ADD caffe-ld-so.conf /etc/ld.so.conf.d/
# Run ldconfig again (not sure if needed)
RUN ldconfig
# Install python deps
RUN cd /opt/caffe && \
cat python/requirements.txt | xargs -L 1 sudo pip install
# Numpy include path hack - github.com/BVLC/caffe/wiki/Ubuntu-14.04-VirtualBox-VM
RUN ln -s /usr/include/python2.7/ /usr/local/include/python2.7 && \
ln -s /usr/local/lib/python2.7/dist-packages/numpy/core/include/numpy/ /usr/local/include/python2.7/numpy
# Build Caffe python bindings
RUN cd /opt/caffe && make pycaffe
{{ if .CPU }}
# Make + run tests
RUN cd /opt/caffe && make test && make runtest
{{ end }}