-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathDockerfile
More file actions
202 lines (164 loc) · 5.39 KB
/
Dockerfile
File metadata and controls
202 lines (164 loc) · 5.39 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
FROM nvcr.io/nvidia/tensorrt:19.10-py3
LABEL maintainer "M. Amine Hadj-Youcef <hadjyoucef.amine@gmail.com>"
# If you have any comment : LinkedIn - https://www.linkedin.com/in/aminehy/
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/Minsk
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
##---------------install prerequisites---------------
RUN apt-get -qq update && apt-get -qq install -y --no-install-recommends \
protobuf-compiler \
geany \
python3 \
python3-tk \
python3-pip \
python3-dev \
python3-setuptools \
eog \
gedit \
build-essential \
ssh \
ca-certificates \
curl \
cmake \
git \
wget \
unzip \
yasm \
pkg-config \
libswscale-dev \
libtbb2 \
libtbb-dev \
libjpeg-dev \
libgflags-dev \
libgoogle-glog-dev \
libprotobuf-dev \
liblmdb-dev \
libpng-dev \
libtiff-dev \
libavformat-dev \
libpq-dev \
libgtk2.0-dev \
libhdf5-dev \
libcurl4-openssl-dev\
libprotoc-dev \
swig\
qt5-default \
libboost-all-dev \
libboost-dev \
xdg-utils \
snapd \
rsync \
&& rm -rf /var/lib/apt/lists/*
RUN cd /usr/local/bin &&\
ln -s /usr/bin/python3 python
#---------------Install pip package---------------
RUN cd /usr/local/src \
&& wget -q https://bootstrap.pypa.io/get-pip.py \
&& python3 get-pip.py \
&& pip3 install --upgrade pip \
&& rm -f get-pip.py \
&& python3 -m pip --version\
&& pip install --user --upgrade pip
RUN pip3 install --upgrade pip
#---------------Install opencv----------------------
WORKDIR /
ENV OPENCV_VERSION="4.1.1"
RUN wget -O opencv.zip https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip
# RUN wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip
RUN unzip opencv.zip
# RUN unzip opencv_contrib.zip
RUN mkdir /opencv-${OPENCV_VERSION}/cmake_binary
WORKDIR /opencv-${OPENCV_VERSION}/cmake_binary
RUN cmake -DBUILD_TIFF=ON \
-DBUILD_opencv_java=OFF \
-DWITH_CUDA=ON \
-DENABLE_FAST_MATH=1 \
-DCUDA_FAST_MATH=1 \
-DWITH_CUBLAS=1 \
-DENABLE_AVX=ON \
-DWITH_OPENGL=ON \
-DWITH_OPENCL=ON \
-DWITH_IPP=ON \
-DWITH_TBB=ON \
-DWITH_EIGEN=ON \
-DWITH_V4L=ON \
-DBUILD_TESTS=OFF \
-DBUILD_PERF_TESTS=OFF \
-DCMAKE_BUILD_TYPE=RELEASE \
-DCMAKE_INSTALL_PREFIX=$(python3.6 -c "import sys; print(sys.prefix)") \
-DPYTHON_EXECUTABLE=$(which python3.6) \
-DPYTHON_INCLUDE_DIR=$(python3.6 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
-DPYTHON_PACKAGES_PATH=$(python3.6 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
-DINSTALL_PYTHON_EXAMPLES=ON \
-DINSTALL_C_EXAMPLES=OFF \
-DOPENCV_ENABLE_NONFREE=ON \
-DOPENCV_GENERATE_PKGCONFIG=ON \
# -DOPENCV_EXTRA_MODULES_PATH=/opencv_contrib-${OPENCV_VERSION}/modules \
-DBUILD_EXAMPLES=ON \
-D CUDA_TOOLKIT_ROOT_DIR= /usr/local/cuda-10.1 \
-DWITH_QT=ON ..
RUN chmod +x download_with_curl.sh \
&& sh ./download_with_curl.sh
RUN make -j8 \
&& make install \
&& rm /opencv.zip \
# && rm opencv_contrib.zip \
&& rm -rf /opencv-${OPENCV_VERSION}
# && rm -rf /opencv_contrib-${OPENCV_VERSION}
RUN ln -s \
/usr/lib/python3.6/dist-packages/cv2/python-3.6/cv2.cpython-36m-x86_64-linux-gnu.so \
/usr/local/lib/python3.6/dist-packages/cv2.so
####################################################
# Deep learning frameworks
####################################################
#---------------Install PyTorch---------------------
RUN pip3 install torch==1.2.0+cu92 torchvision==0.4.0+cu92 -f https://download.pytorch.org/whl/torch_stable.html
#---------------Install TensorFlow------------------
RUN pip3 install tensorflow-gpu
RUN pip3 install tflearn
#---------------Install ONNX------------------------
RUN pip3 install onnx onnxmltools onnxruntime-gpu
#---------------Install keras------------------------
RUN pip3 install keras
#---------------Install ONNX-TensorRT---------------
# determine DGPU_ARCHS from https://developer.nvidia.com/cuda-gpus
# https://github.com/onnx/onnx-tensorrt
RUN git clone --recursive -b 6.0 https://github.com/onnx/onnx-tensorrt.git &&\
cd onnx-tensorrt &&\
mkdir build &&\
cd build &&\
cmake .. -DCUDA_INCLUDE_DIRS=/usr/local/cuda/include -DTENSORRT_ROOT=/usr/src/tensorrt -DGPU_ARCHS="35" &&\
make -j8 &&\
make install &&\
ldconfig && \
cd .. && \
python setup.py build &&\
python setup.py install &&\
rm -rf ./build/
#----------------Install TensorBoardX -----------------------
RUN git clone https://github.com/lanpa/tensorboardX && cd tensorboardX && python setup.py install
#---------------Install python requirements---------
COPY requirements.txt /tmp/
RUN pip3 install --requirement /tmp/requirements.txt
# ---------------Install Heroku for deplyment of application on the server
RUN curl https://cli-assets.heroku.com/install.sh | sh
# ---------------Configure Streamlit
RUN mkdir -p /root/.streamlit
RUN bash -c 'echo -e "\
[general]\n\
email = \"hadjyoucef.amine@gmail.com\"\n\
" > /root/.streamlit/credentials.toml'
RUN bash -c 'echo -e "\
[server]\n\
enableCORS = false\n\
" > /root/.streamlit/config.toml'
EXPOSE 8501
# Declare environnement variable
RUN echo 'export LC_ALL=C.UTF-8' >> ~/.bashrc
RUN echo 'export LANG=C.UTF-8' >> ~/.bashrc
#----------------Perform some cleaning-----------------------
RUN (apt-get -qq autoremove -y; \
apt-get -qq autoclean -y)
#----------------set the working directory-------------------
WORKDIR /workspace
CMD ["jupyter", "notebook", "--allow-root", "--port=8888", "--ip=0.0.0.0", "--no-browser"]