forked from NVIDIA/gpu-rest-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.caffe_server
79 lines (69 loc) · 3.19 KB
/
Dockerfile.caffe_server
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
FROM nvidia/cuda:8.0-cudnn6-devel-ubuntu16.04
MAINTAINER Felix Abecassis "fabecassis@nvidia.com"
ENV CUDA_ARCH_BIN "30 35 50 52 60"
ENV CUDA_ARCH_PTX "60"
# Install dependencies.
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
cmake \
git \
libatlas-base-dev \
libatlas-dev \
libboost-all-dev \
libgflags-dev \
libgoogle-glog-dev \
libhdf5-dev \
libprotobuf-dev \
pkg-config \
protobuf-compiler \
python-yaml \
python-six \
wget && \
rm -rf /var/lib/apt/lists/*
# OpenCV 3.2.0 is needed to support custom allocators for GpuMat objects.
RUN git clone --depth 1 -b 3.2.0 https://github.com/Itseez/opencv.git /opencv && \
cd /opencv && \
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON \
-DWITH_CUDA=ON -DCUDA_ARCH_BIN="${CUDA_ARCH_BIN}" -DCUDA_ARCH_PTX="${CUDA_ARCH_PTX}" \
-DWITH_JPEG=ON -DBUILD_JPEG=ON -DWITH_PNG=ON -DBUILD_PNG=ON \
-DBUILD_TESTS=OFF -DBUILD_EXAMPLES=OFF -DWITH_FFMPEG=OFF -DWITH_GTK=OFF \
-DWITH_OPENCL=OFF -DWITH_QT=OFF -DWITH_V4L=OFF -DWITH_JASPER=OFF \
-DWITH_1394=OFF -DWITH_TIFF=OFF -DWITH_OPENEXR=OFF -DWITH_IPP=OFF -DWITH_WEBP=OFF \
-DBUILD_opencv_superres=OFF -DBUILD_opencv_java=OFF -DBUILD_opencv_python2=OFF \
-DBUILD_opencv_videostab=OFF -DBUILD_opencv_apps=OFF -DBUILD_opencv_flann=OFF \
-DBUILD_opencv_ml=OFF -DBUILD_opencv_photo=OFF -DBUILD_opencv_shape=OFF \
-DBUILD_opencv_cudabgsegm=OFF -DBUILD_opencv_cudaoptflow=OFF -DBUILD_opencv_cudalegacy=OFF \
-DCUDA_NVCC_FLAGS="-O3" -DCUDA_FAST_MATH=ON && \
make -j"$(nproc)" install && \
rm -rf /opencv
# A modified version of Caffe is used to properly handle multithreading and CUDA streams.
RUN git clone --depth 1 -b bvlc_inference https://github.com/flx42/caffe.git /caffe && \
cd /caffe && \
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON \
-DCUDA_ARCH_NAME=Manual -DCUDA_ARCH_BIN="${CUDA_ARCH_BIN}" -DCUDA_ARCH_PTX="${CUDA_ARCH_PTX}" \
-DUSE_CUDNN=ON -DUSE_OPENCV=ON -DUSE_LEVELDB=OFF -DUSE_LMDB=OFF \
-DBUILD_python=OFF -DBUILD_python_layer=OFF -DBUILD_matlab=OFF \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DCUDA_NVCC_FLAGS="-O3" && \
make -j"$(nproc)" install && \
make clean
# Download Caffenet
RUN /caffe/scripts/download_model_binary.py /caffe/models/bvlc_reference_caffenet && \
/caffe/data/ilsvrc12/get_ilsvrc_aux.sh
RUN echo "/usr/local/lib" >> /etc/ld.so.conf && \
ldconfig
# Install golang
ENV GOLANG_VERSION 1.8.1
RUN wget -O - https://storage.googleapis.com/golang/go${GOLANG_VERSION}.linux-amd64.tar.gz \
| tar -v -C /usr/local -xz
ENV GOPATH /go
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
# Build inference server
COPY caffe /go/src/caffe-server
COPY common.h /go/src/common.h
RUN go get -ldflags="-s" caffe-server
CMD ["caffe-server", \
"/caffe/models/bvlc_reference_caffenet/deploy.prototxt", \
"/caffe/models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel", \
"/caffe/data/ilsvrc12/imagenet_mean.binaryproto", \
"/caffe/data/ilsvrc12/synset_words.txt"]