Skip to content

Commit 97df9f2

Browse files
committed
add OpenCV
1 parent ac1873f commit 97df9f2

File tree

1 file changed

+172
-23
lines changed

1 file changed

+172
-23
lines changed

vendor/ngc-pytorch/Dockerfile.22.09-py3

Lines changed: 172 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,56 +12,150 @@ ENV DEBIAN_FRONTEND=noninteractive \
1212
C_INCLUDE_PATH=/usr/include/gdal \
1313
LANG=C.UTF-8
1414

15-
RUN apt-get update && \
15+
RUN apt-key adv --refresh-keys --keyserver keyserver.ubuntu.com && \
16+
apt-get update && \
1617
apt-get install -y --no-install-recommends \
1718
automake \
19+
bison \
20+
build-essential \
1821
bzip2 \
22+
ca-certificates \
1923
cabextract \
24+
chrpath \
25+
devscripts \
26+
dh-make \
27+
dirmngr \
28+
dkms \
29+
dpatch \
30+
ethtool \
31+
fakeroot \
2032
ffmpeg \
33+
flex \
2134
fonts-nanum \
2235
fonts-nanum-coding \
2336
fonts-nanum-extra \
37+
g++ \
38+
gcc \
39+
gdal-bin \
2440
gfortran \
41+
gir1.2-gtk-3.0 \
42+
git \
43+
graphviz \
2544
htop \
45+
iputils-ping \
2646
libasound2-dev \
2747
libatlas-base-dev \
48+
libavcodec-dev \
49+
libavformat-dev \
2850
libavresample-dev \
51+
libboost-dev \
52+
libboost-filesystem-dev \
53+
libboost-system-dev \
54+
libcairo-dev \
55+
libcairo2-dev \
56+
libcurl3-dev \
2957
libdc1394-22-dev \
3058
libeigen3-dev \
3159
libfaac-dev \
60+
libfftw3-dev \
61+
libfreetype6-dev \
62+
libfuse2 \
3263
libgdal-dev \
64+
libgeos++-dev \
65+
libgeos-dev \
3366
libgflags-dev \
67+
libgfortran4 \
68+
libgirepository1.0-dev \
69+
libglib2.0-0 \
3470
libgoogle-glog-dev \
3571
libgphoto2-dev \
3672
libgstreamer-plugins-base1.0-dev \
3773
libgstreamer1.0-dev \
3874
libgtk-3-dev \
39-
libhdf5-dev \
75+
libhdf5-dev \
76+
libhdf5-serial-dev \
77+
# libjasper-dev \
4078
libjemalloc-dev \
79+
libjpeg-dev \
80+
liblapack-dev \
81+
libmnl0 \
4182
libmp3lame-dev \
83+
libmpdec2 \
4284
libncurses-dev \
85+
libnl-3-200 \
86+
libnl-3-dev \
87+
libnl-route-3-200 \
88+
libnl-route-3-dev \
89+
libnlopt-dev \
90+
libnuma-dev \
4391
libopenblas-dev \
4492
libopencore-amrnb-dev \
4593
libopencore-amrwb-dev \
94+
libpci3 \
95+
libpng-dev \
96+
libportmidi-dev \
97+
libproj-dev \
4698
libprotobuf-dev \
99+
libsdl-dev \
100+
libsdl-image1.2-dev \
101+
libsdl-mixer1.2-dev \
102+
libsdl-ttf2.0-dev \
103+
libsm6 \
104+
libsmpeg-dev \
105+
libssl-dev \
106+
libswscale-dev \
107+
libtbb-dev \
47108
libtheora-dev \
109+
libtiff-dev \
110+
libv4l-dev \
48111
libvorbis-dev \
49112
libx264-dev \
50113
libxext6 \
114+
libxine2-dev \
115+
libxml2-dev \
51116
libxrender-dev \
117+
libxrender1 \
118+
libxslt1-dev \
52119
libxvidcore-dev \
53-
libsm6 \
54-
libtbb-dev \
120+
libzmq3-dev \
121+
lintian \
122+
lsof \
123+
make \
55124
mercurial \
125+
mime-support \
126+
mpich \
56127
ncurses-term \
57-
openjdk-8-jdk \
128+
net-tools \
129+
nodejs \
130+
openjdk-8-jdk \
131+
openssh-client \
132+
openssh-server \
58133
pbzip2 \
59-
pv \
134+
pciutils \
60135
pdsh \
136+
pkg-config \
137+
proj-bin \
61138
protobuf-compiler \
139+
pv \
140+
python-apt \
141+
python-xkit \
142+
python3-gdal \
143+
screen-resolution-extra \
144+
subversion \
145+
swig \
146+
tk \
147+
unzip \
62148
v4l-utils \
63-
x264
64-
149+
vim \
150+
x264 \
151+
xvfb \
152+
xz-utils \
153+
yarn \
154+
yasm \
155+
zip \
156+
tcl \
157+
udev \
158+
zlib1g-dev
65159
# Install CUDA + cuDNN
66160
RUN ln -s /usr/lib/x86_64-linux-gnu/libcudnn.so.8.3.2 /usr/local/cuda/lib64/libcudnn.so && \
67161
rm -rf /var/lib/apt/lists/* && \
@@ -112,9 +206,6 @@ RUN git clone -q --branch=v0.3.20 https://github.com/xianyi/OpenBLAS.git && \
112206
cd /tmp/scs-python && \
113207
python setup.py install --scs --gpu
114208

115-
RUN /opt/conda/bin/conda install -n base conda==4.13.0
116-
RUN /opt/conda/bin/conda install -c conda-forge opencv ffmpeg
117-
118209
# install git-lfs
119210
WORKDIR /tmp
120211
RUN curl -sLO https://github.com/git-lfs/git-lfs/releases/download/v3.3.0/git-lfs-linux-amd64-v3.3.0.tar.gz && \
@@ -131,20 +222,68 @@ RUN git clone https://github.com/aristocratos/bashtop.git && \
131222
RUN curl -fL https://github.com/cdr/code-server/releases/download/v4.9.1/code-server-4.9.1-linux-amd64.tar.gz \
132223
| tar -C /usr/local/lib -xz && \
133224
mv /usr/local/lib/code-server-4.9.1-linux-amd64 /usr/local/lib/code-server-4.9.1 && \
134-
ln -s /usr/local/lib/code-server-4.9.1/bin/code-server /usr/local/bin/code-server
225+
ln -s /usr/local/lib/code-server-4.9.1/bin/code-server /usr/local/bin/code-server && \
226+
code-server \
227+
--install-extension ms-python.python \
228+
--install-extension ms-ceintl.vscode-language-pack-ko
135229

230+
# OpenCV
231+
ENV OPENCV_VERSION="4.5.5"
136232
WORKDIR /tmp
137-
COPY ./requirements.22.09.1.txt /tmp/requirements.txt
138-
RUN /opt/conda/bin/python3 -m pip install --no-cache-dir -r requirements.txt
139-
COPY ./requirements.22.09.2.txt /tmp/requirements.txt
140-
RUN /opt/conda/bin/python3 -m pip install --no-cache-dir -r requirements.txt
141-
COPY ./requirements.22.09.3.txt /tmp/requirements.txt
142-
RUN /opt/conda/bin/python3 -m pip install --no-cache-dir -r requirements.txt
143-
COPY ./requirements.22.09.4.txt /tmp/requirements.txt
144-
RUN /opt/conda/bin/python3 -m pip install --no-cache-dir -r requirements.txt
145-
COPY ./requirements.22.09.5.txt /tmp/requirements.txt
146-
RUN /opt/conda/bin/python3 -m pip install --no-cache-dir -r requirements.txt && \
147-
rm -f /tmp/*.whl /tmp/requirem*
233+
RUN wget https://github.com/opencv/opencv/archive/${OPENCV_VERSION}.zip && \
234+
wget -O opencv-contrib.zip https://github.com/opencv/opencv_contrib/archive/${OPENCV_VERSION}.zip && \
235+
unzip ${OPENCV_VERSION}.zip && \
236+
unzip opencv-contrib.zip && \
237+
mkdir opencv-${OPENCV_VERSION}/cmake_binary && \
238+
cd opencv-${OPENCV_VERSION}/cmake_binary && \
239+
cmake \
240+
-DCMAKE_BUILD_TYPE=RELEASE \
241+
-D BUILD_TIFF=ON \
242+
-D BUILD_opencv_java=OFF \
243+
-D WITH_CUDA=ON \
244+
-D CUDA_NVCC_FLAGS=--expt-relaxed-constexpr \
245+
-D CUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-11.8 \
246+
-D ENABLE_FAST_MATH=1 \
247+
-D CUDA_FAST_MATH=1 \
248+
-D WITH_CUBLAS=1 \
249+
-D WITH_OPENGL=ON \
250+
-D WITH_OPENCL=ON \
251+
-D WITH_IPP=ON \
252+
-D WITH_TBB=ON \
253+
-D WITH_EIGEN=ON \
254+
-D WITH_V4L=ON \
255+
-D BUILD_TESTS=OFF \
256+
-D BUILD_PERF_TESTS=OFF \
257+
-D OPENCV_EXTRA_MODULES_PATH="../../opencv_contrib-4.5.5/modules" \
258+
-D CMAKE_BUILD_TYPE=RELEASE \
259+
-D CMAKE_INSTALL_PREFIX=$(python3 -c "import sys; print(sys.prefix)") \
260+
-D PYTHON_EXECUTABLE=$(which python3) \
261+
-D PYTHON_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
262+
-D PYTHON_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
263+
.. 2>&1 | tee cmake_messages.txt && \
264+
make -j$(nproc) && \
265+
make install && \
266+
cd /tmp && \
267+
python3 -m pip install --no-cache-dir opencv-python && \
268+
rm -fr opencv*
269+
270+
WORKDIR /tmp
271+
COPY requirements.22.09.txt /tmp/requirements.txt
272+
RUN for f in $(ls requirements*.txt); do pip3 install --disable-pip-version-check --no-cache-dir -r $f; done && \
273+
rm -f /tmp/*.whl /tmp/requirem*
274+
275+
276+
#COPY ./requirements.22.09.1.txt /tmp/requirements.txt
277+
#RUN /opt/conda/bin/python3 -m pip install --no-cache-dir -r requirements.txt
278+
#COPY ./requirements.22.09.2.txt /tmp/requirements.txt
279+
#RUN /opt/conda/bin/python3 -m pip install --no-cache-dir -r requirements.txt
280+
#COPY ./requirements.22.09.3.txt /tmp/requirements.txt
281+
#RUN /opt/conda/bin/python3 -m pip install --no-cache-dir -r requirements.txt
282+
#COPY ./requirements.22.09.4.txt /tmp/requirements.txt
283+
#RUN /opt/conda/bin/python3 -m pip install --no-cache-dir -r requirements.txt
284+
#COPY ./requirements.22.09.5.txt /tmp/requirements.txt
285+
#RUN /opt/conda/bin/python3 -m pip install --no-cache-dir -r requirements.txt && \
286+
# rm -f /tmp/*.whl /tmp/requirem*
148287

149288
# Install Open MPI
150289
RUN mkdir /tmp/openmpi && \
@@ -179,6 +318,16 @@ RUN ldconfig /usr/local/cuda/targets/x86_64-linux/lib/stubs && \
179318
pip install --no-cache-dir horovod==0.24.2 && \
180319
ldconfig
181320

321+
RUN python3 -m pip install pytorch-lightning && \
322+
python3 -m pip install --no-cache-dir \
323+
pyg-lib \
324+
torch-scatter \
325+
torch-sparse \
326+
torch-cluster \
327+
torch-spline-conv \
328+
torch-geometric \
329+
-f https://data.pyg.org/whl/torch-1.13.0+cu117.html
330+
182331
RUN python3 -m pip install --no-cache-dir \
183332
mpi4py==3.1.3 \
184333
nni==2.9 \

0 commit comments

Comments
 (0)