Skip to content

Commit

Permalink
change: custom opencv to opencv-python
Browse files Browse the repository at this point in the history
  • Loading branch information
minostauros committed May 24, 2024
1 parent f8de00e commit e79f5ae
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@

# Associated pytorch version will not be set automatically. Scroll down and set appropriate versions.

FROM ghcr.io/minostauros/cuda-ffmpeg-opencv-docker:4.7.0-cu118-py310
# opencv is not built well with cuda 11.8, we use opencv-python instead
FROM ghcr.io/minostauros/cuda-ffmpeg-docker:6.1-cu118

ARG PYTHON_VERSION=3.10
ARG OPENCV_VERSION=4.9.0.80
ARG PYTORCH_VERSION=2.1.2
ARG TORCHVISION_VERSION=0.16.2
ARG TORCHAUDIO_VERSION=2.1.2
Expand All @@ -20,6 +22,7 @@ ARG TARGET_CUDA_VERSION=cu118
ARG CUDA_VERSION=11.8
# TensorRT for cuda11.8 supports cuda11.x
ARG TENSORRT_VERSION="8.6.1.6-1+cuda11.8"
ARG PIP_TENSORRT=tensorrt-cu11
ARG ONNXRUNTIME_VERSION=1.18.0

# environmental variable for apex
Expand All @@ -45,7 +48,7 @@ RUN echo "Asia/Seoul" > /etc/timezone && \
net-tools \
curl \
openssh-server \
#libpng-dev \ # included in base image
libpng-dev \
swig \
locales \
tzdata \
Expand All @@ -54,7 +57,23 @@ RUN echo "Asia/Seoul" > /etc/timezone && \
ninja-build \
rclone \
libdrm-dev libsystemd-dev \
python${PYTHON_VERSION}-dev && \
wget \
libtbb12 \
pkg-config \
qtbase5-dev qt5-qmake \
build-essential \
libopenblas-base \
libswscale5 \
libtiff5-dev \
libv4l-dev \
libgstreamer-plugins-base1.0-0 \
zlib1g-dev \
libsm6 \
libxext6 \
libxrender1 \
python${PYTHON_VERSION} \
python${PYTHON_VERSION}-dev \
$( [ ${PYTHON_VERSION%%.*} -ge 3 ] && echo "python${PYTHON_VERSION%%.*}-distutils" ) && \
apt-get clean -y && \
# Language & Timezone setting
echo "Asia/Seoul" > /etc/timezone && \
Expand All @@ -64,8 +83,13 @@ RUN echo "Asia/Seoul" > /etc/timezone && \
echo 'LANG="en_US.UTF-8"'>/etc/default/locale && \
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=en_US.UTF-8 && \
# PyTorch (Mind cuda version and associated torch and torchvision versions)
# OpenCV
wget https://bootstrap.pypa.io/get-pip.py --progress=bar:force:noscroll --no-check-certificate && \
python${PYTHON_VERSION} get-pip.py && \
rm get-pip.py && \
python${PYTHON_VERSION} -m pip install --upgrade pip && \
pip${PYTHON_VERSION} install opencv-python==${OPENCV_VERSION} && \
# PyTorch (Mind cuda version and associated torch and torchvision versions)
pip${PYTHON_VERSION} install torch==${PYTORCH_VERSION}+${TARGET_CUDA_VERSION} torchvision==${TORCHVISION_VERSION}+${TARGET_CUDA_VERSION} torchaudio==${TORCHAUDIO_VERSION}+${TARGET_CUDA_VERSION} --index-url https://download.pytorch.org/whl/${TARGET_CUDA_VERSION} && \
# CMake higher version than apt-get
pip${PYTHON_VERSION} install cmake packaging && \
Expand Down Expand Up @@ -126,7 +150,7 @@ RUN echo "Asia/Seoul" > /etc/timezone && \
libnvinfer-lean8=${TENSORRT_VERSION} libnvinfer-samples=${TENSORRT_VERSION} \
libnvinfer-vc-plugin-dev=${TENSORRT_VERSION} libnvinfer-vc-plugin8=${TENSORRT_VERSION} \
tensorrt=${TENSORRT_VERSION} && \
pip${PYTHON_VERSION} install tensorrt && \
pip${PYTHON_VERSION} install ${PIP_TENSORRT} && \
pip${PYTHON_VERSION} install onnxruntime-gpu==${ONNXRUNTIME_VERSION} && \
# DIR=/tmp/onnxruntime && \
# mkdir -p ${DIR} && \
Expand All @@ -153,7 +177,10 @@ RUN echo "Asia/Seoul" > /etc/timezone && \
&& \
apt-get autoremove -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /root/.cache/pip/*
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /root/.cache/pip/* && \
# Set the default python and install PIP packages
update-alternatives --install /usr/bin/python${PYTHON_VERSION%%.*} python${PYTHON_VERSION%%.*} /usr/bin/python${PYTHON_VERSION} 1 && \
update-alternatives --install /usr/bin/python python /usr/bin/python${PYTHON_VERSION} 1


ENV LANG="en_US.UTF-8" \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@

# Associated pytorch version will not be set automatically. Scroll down and set appropriate versions.

FROM ghcr.io/minostauros/cuda-ffmpeg-opencv-docker:4.7.0-cu118-py310
# opencv is not built well with cuda 11.8, we use opencv-python instead
FROM ghcr.io/minostauros/cuda-ffmpeg-docker:6.1-cu118

ARG PYTHON_VERSION=3.10
ARG OPENCV_VERSION=4.9.0.80
ARG PYTORCH_VERSION=2.2.1
ARG TORCHVISION_VERSION=0.17.1
ARG TORCHAUDIO_VERSION=2.2.1
Expand All @@ -20,6 +22,7 @@ ARG TARGET_CUDA_VERSION=cu118
ARG CUDA_VERSION=11.8
# TensorRT for cuda11.8 supports cuda11.x
ARG TENSORRT_VERSION="8.6.1.6-1+cuda11.8"
ARG PIP_TENSORRT=tensorrt-cu11
ARG ONNXRUNTIME_VERSION=1.18.0

# environmental variable for apex
Expand All @@ -45,7 +48,7 @@ RUN echo "Asia/Seoul" > /etc/timezone && \
net-tools \
curl \
openssh-server \
#libpng-dev \ # included in base image
libpng-dev \
swig \
locales \
tzdata \
Expand All @@ -54,7 +57,23 @@ RUN echo "Asia/Seoul" > /etc/timezone && \
ninja-build \
rclone \
libdrm-dev libsystemd-dev \
python${PYTHON_VERSION}-dev && \
wget \
libtbb12 \
pkg-config \
qtbase5-dev qt5-qmake \
build-essential \
libopenblas-base \
libswscale5 \
libtiff5-dev \
libv4l-dev \
libgstreamer-plugins-base1.0-0 \
zlib1g-dev \
libsm6 \
libxext6 \
libxrender1 \
python${PYTHON_VERSION} \
python${PYTHON_VERSION}-dev \
$( [ ${PYTHON_VERSION%%.*} -ge 3 ] && echo "python${PYTHON_VERSION%%.*}-distutils" ) && \
apt-get clean -y && \
# Language & Timezone setting
echo "Asia/Seoul" > /etc/timezone && \
Expand All @@ -64,8 +83,13 @@ RUN echo "Asia/Seoul" > /etc/timezone && \
echo 'LANG="en_US.UTF-8"'>/etc/default/locale && \
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=en_US.UTF-8 && \
# PyTorch (Mind cuda version and associated torch and torchvision versions)
# OpenCV
wget https://bootstrap.pypa.io/get-pip.py --progress=bar:force:noscroll --no-check-certificate && \
python${PYTHON_VERSION} get-pip.py && \
rm get-pip.py && \
python${PYTHON_VERSION} -m pip install --upgrade pip && \
pip${PYTHON_VERSION} install opencv-python==${OPENCV_VERSION} && \
# PyTorch (Mind cuda version and associated torch and torchvision versions)
pip${PYTHON_VERSION} install torch==${PYTORCH_VERSION}+${TARGET_CUDA_VERSION} torchvision==${TORCHVISION_VERSION}+${TARGET_CUDA_VERSION} torchaudio==${TORCHAUDIO_VERSION}+${TARGET_CUDA_VERSION} --index-url https://download.pytorch.org/whl/${TARGET_CUDA_VERSION} && \
# CMake higher version than apt-get
pip${PYTHON_VERSION} install cmake packaging && \
Expand Down Expand Up @@ -126,7 +150,7 @@ RUN echo "Asia/Seoul" > /etc/timezone && \
libnvinfer-lean8=${TENSORRT_VERSION} libnvinfer-samples=${TENSORRT_VERSION} \
libnvinfer-vc-plugin-dev=${TENSORRT_VERSION} libnvinfer-vc-plugin8=${TENSORRT_VERSION} \
tensorrt=${TENSORRT_VERSION} && \
pip${PYTHON_VERSION} install tensorrt && \
pip${PYTHON_VERSION} install ${PIP_TENSORRT} && \
pip${PYTHON_VERSION} install onnxruntime-gpu==${ONNXRUNTIME_VERSION} && \
# DIR=/tmp/onnxruntime && \
# mkdir -p ${DIR} && \
Expand All @@ -153,7 +177,10 @@ RUN echo "Asia/Seoul" > /etc/timezone && \
&& \
apt-get autoremove -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /root/.cache/pip/*
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /root/.cache/pip/* && \
# Set the default python and install PIP packages
update-alternatives --install /usr/bin/python${PYTHON_VERSION%%.*} python${PYTHON_VERSION%%.*} /usr/bin/python${PYTHON_VERSION} 1 && \
update-alternatives --install /usr/bin/python python /usr/bin/python${PYTHON_VERSION} 1


ENV LANG="en_US.UTF-8" \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@

# Associated pytorch version will not be set automatically. Scroll down and set appropriate versions.

FROM ghcr.io/minostauros/cuda-ffmpeg-opencv-docker:4.9.0-cu118-py310
# opencv is not built well with cuda 11.8, we use opencv-python instead
FROM ghcr.io/minostauros/cuda-ffmpeg-docker:6.1-cu118

ARG PYTHON_VERSION=3.10
ARG OPENCV_VERSION=4.9.0.80
ARG PYTORCH_VERSION=2.2.2
ARG TORCHVISION_VERSION=0.17.2
ARG TORCHAUDIO_VERSION=2.2.2
Expand All @@ -20,6 +22,7 @@ ARG TARGET_CUDA_VERSION=cu118
ARG CUDA_VERSION=11.8
# TensorRT for cuda11.8 supports cuda11.x
ARG TENSORRT_VERSION="8.6.1.6-1+cuda11.8"
ARG PIP_TENSORRT=tensorrt-cu11
ARG ONNXRUNTIME_VERSION=1.18.0

# environmental variable for apex
Expand All @@ -45,7 +48,7 @@ RUN echo "Asia/Seoul" > /etc/timezone && \
net-tools \
curl \
openssh-server \
#libpng-dev \ # included in base image
libpng-dev \
swig \
locales \
tzdata \
Expand All @@ -54,7 +57,23 @@ RUN echo "Asia/Seoul" > /etc/timezone && \
ninja-build \
rclone \
libdrm-dev libsystemd-dev \
python${PYTHON_VERSION}-dev && \
wget \
libtbb12 \
pkg-config \
qtbase5-dev qt5-qmake \
build-essential \
libopenblas-base \
libswscale5 \
libtiff5-dev \
libv4l-dev \
libgstreamer-plugins-base1.0-0 \
zlib1g-dev \
libsm6 \
libxext6 \
libxrender1 \
python${PYTHON_VERSION} \
python${PYTHON_VERSION}-dev \
$( [ ${PYTHON_VERSION%%.*} -ge 3 ] && echo "python${PYTHON_VERSION%%.*}-distutils" ) && \
apt-get clean -y && \
# Language & Timezone setting
echo "Asia/Seoul" > /etc/timezone && \
Expand All @@ -64,8 +83,13 @@ RUN echo "Asia/Seoul" > /etc/timezone && \
echo 'LANG="en_US.UTF-8"'>/etc/default/locale && \
DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=en_US.UTF-8 && \
# PyTorch (Mind cuda version and associated torch and torchvision versions)
# OpenCV
wget https://bootstrap.pypa.io/get-pip.py --progress=bar:force:noscroll --no-check-certificate && \
python${PYTHON_VERSION} get-pip.py && \
rm get-pip.py && \
python${PYTHON_VERSION} -m pip install --upgrade pip && \
pip${PYTHON_VERSION} install opencv-python==${OPENCV_VERSION} && \
# PyTorch (Mind cuda version and associated torch and torchvision versions)
pip${PYTHON_VERSION} install torch==${PYTORCH_VERSION}+${TARGET_CUDA_VERSION} torchvision==${TORCHVISION_VERSION}+${TARGET_CUDA_VERSION} torchaudio==${TORCHAUDIO_VERSION}+${TARGET_CUDA_VERSION} --index-url https://download.pytorch.org/whl/${TARGET_CUDA_VERSION} && \
# CMake higher version than apt-get
pip${PYTHON_VERSION} install cmake packaging && \
Expand Down Expand Up @@ -126,7 +150,7 @@ RUN echo "Asia/Seoul" > /etc/timezone && \
libnvinfer-lean8=${TENSORRT_VERSION} libnvinfer-samples=${TENSORRT_VERSION} \
libnvinfer-vc-plugin-dev=${TENSORRT_VERSION} libnvinfer-vc-plugin8=${TENSORRT_VERSION} \
tensorrt=${TENSORRT_VERSION} && \
pip${PYTHON_VERSION} install tensorrt && \
pip${PYTHON_VERSION} install ${PIP_TENSORRT} && \
pip${PYTHON_VERSION} install onnxruntime-gpu==${ONNXRUNTIME_VERSION} && \
# DIR=/tmp/onnxruntime && \
# mkdir -p ${DIR} && \
Expand All @@ -153,7 +177,10 @@ RUN echo "Asia/Seoul" > /etc/timezone && \
&& \
apt-get autoremove -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /root/.cache/pip/*
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /root/.cache/pip/* && \
# Set the default python and install PIP packages
update-alternatives --install /usr/bin/python${PYTHON_VERSION%%.*} python${PYTHON_VERSION%%.*} /usr/bin/python${PYTHON_VERSION} 1 && \
update-alternatives --install /usr/bin/python python /usr/bin/python${PYTHON_VERSION} 1


ENV LANG="en_US.UTF-8" \
Expand Down

0 comments on commit e79f5ae

Please sign in to comment.