2024-10-21 18:26:23 +08:00
ARG BASE_IMAGE = { base_image}
2023-06-08 10:01:58 +08:00
FROM $BASE_IMAGE
ARG DEBIAN_FRONTEND = noninteractive
ENV TZ = Asia/Shanghai
ENV arch = x86_64
SHELL [ "/bin/bash" , "-c" ]
COPY docker/rcfiles /tmp/resources
2024-06-05 19:08:46 +08:00
RUN apt-get update && apt-get upgrade -y && apt-get install -y --reinstall ca-certificates && \
apt-get install -y make apt-utils openssh-server locales wget git strace gdb sox libopenmpi-dev curl \
2023-11-27 20:21:00 +08:00
iputils-ping net-tools iproute2 autoconf automake gperf libre2-dev libssl-dev \
libtool libcurl4-openssl-dev libb64-dev libgoogle-perftools-dev patchelf \
rapidjson-dev scons software-properties-common pkg-config unzip zlib1g-dev \
2024-06-05 19:08:46 +08:00
libbz2-dev libreadline-dev libsqlite3-dev llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev liblzma-dev \
libarchive-dev libxml2-dev libnuma-dev cmake \
2023-06-08 10:01:58 +08:00
libgeos-dev strace vim ffmpeg libsm6 tzdata language-pack-zh-hans \
2024-06-05 19:08:46 +08:00
ttf-wqy-microhei ttf-wqy-zenhei xfonts-wqy libxext6 build-essential ninja-build \
libjpeg-dev libpng-dev && \
2023-06-08 10:01:58 +08:00
wget https://packagecloud.io/github/git-lfs/packages/debian/bullseye/git-lfs_3.2.0_amd64.deb/download -O ./git-lfs_3.2.0_amd64.deb && \
dpkg -i ./git-lfs_3.2.0_amd64.deb && \
rm -f ./git-lfs_3.2.0_amd64.deb && \
locale-gen zh_CN && \
locale-gen zh_CN.utf8 && \
update-locale LANG = zh_CN.UTF-8 LC_ALL = zh_CN.UTF-8 LANGUAGE = zh_CN.UTF-8 && \
ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
dpkg-reconfigure --frontend noninteractive tzdata && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
ENV LANG = zh_CN.UTF-8 LANGUAGE = zh_CN.UTF-8 LC_ALL = zh_CN.UTF-8
2024-06-05 19:08:46 +08:00
RUN wget -O /tmp/boost.tar.gz https://boostorg.jfrog.io/artifactory/main/release/1.80.0/source/boost_1_80_0.tar.gz && \
cd /tmp && tar xzf boost.tar.gz && \
mv /tmp/boost_1_80_0/boost /usr/include/boost && \
rm -rf /tmp/boost_1_80_0 && rm -rf boost.tar.gz
#install and config python copy from https://github.com/docker-library/python/blob/1b7a1106674a21e699b155cbd53bf39387284cca/3.10/bookworm/Dockerfile
2024-10-21 18:26:23 +08:00
ARG PYTHON_VERSION = { python_version}
2024-06-05 19:08:46 +08:00
ENV PATH /usr/local/bin:$PATH
ENV GPG_KEY A035C8C19219BA821ECEA86B64E628F8D684696D
2024-10-21 18:26:23 +08:00
ENV PYTHON_VERSION { python_version}
2024-06-05 19:08:46 +08:00
RUN set -eux; \
\
wget -O python.tar.xz " https://www.python.org/ftp/python/ ${ PYTHON_VERSION %%[a-z]* } /Python- $PYTHON_VERSION .tar.xz " ; \
wget -O python.tar.xz.asc " https://www.python.org/ftp/python/ ${ PYTHON_VERSION %%[a-z]* } /Python- $PYTHON_VERSION .tar.xz.asc " ; \
GNUPGHOME = " $( mktemp -d) " ; export GNUPGHOME; \
gpg --batch --keyserver hkps://keys.openpgp.org --recv-keys " $GPG_KEY " ; \
gpg --batch --verify python.tar.xz.asc python.tar.xz; \
gpgconf --kill all; \
rm -rf " $GNUPGHOME " python.tar.xz.asc; \
mkdir -p /usr/src/python; \
tar --extract --directory /usr/src/python --strip-components= 1 --file python.tar.xz; \
rm python.tar.xz; \
\
cd /usr/src/python; \
gnuArch = " $( dpkg-architecture --query DEB_BUILD_GNU_TYPE) " ; \
./configure \
--build= " $gnuArch " \
--enable-loadable-sqlite-extensions \
--enable-optimizations \
--enable-option-checking= fatal \
--enable-shared \
--with-lto \
--with-system-expat \
--without-ensurepip \
; \
nproc = " $( nproc) " ; \
EXTRA_CFLAGS = " $( dpkg-buildflags --get CFLAGS) " ; \
LDFLAGS = " $( dpkg-buildflags --get LDFLAGS) " ; \
make -j " $nproc " \
" EXTRA_CFLAGS= ${ EXTRA_CFLAGS :- } " \
" LDFLAGS= ${ LDFLAGS :- } " \
" PROFILE_TASK= ${ PROFILE_TASK :- } " \
; \
# https://github.com/docker-library/python/issues/784
# prevent accidental usage of a system installed libpython of the same version
rm python; \
make -j " $nproc " \
" EXTRA_CFLAGS= ${ EXTRA_CFLAGS :- } " \
" LDFLAGS= ${ LDFLAGS :- -Wl } ,-rpath='\$\$ORIGIN/../lib' " \
" PROFILE_TASK= ${ PROFILE_TASK :- } " \
python \
; \
make install; \
\
# enable GDB to load debugging data: https://github.com/docker-library/python/pull/701
bin = " $( readlink -ve /usr/local/bin/python3) " ; \
dir = " $( dirname " $bin " ) " ; \
mkdir -p " /usr/share/gdb/auto-load/ $dir " ; \
cp -vL Tools/gdb/libpython.py " /usr/share/gdb/auto-load/ $bin -gdb.py " ; \
\
cd /; \
rm -rf /usr/src/python; \
\
find /usr/local -depth \
\( \
\( -type d -a \( -name test -o -name tests -o -name idle_test \) \) \
-o \( -type f -a \( -name '*.pyc' -o -name '*.pyo' -o -name 'libpython*.a' \) \) \
\) -exec rm -rf '{}' + \
; \
\
ldconfig; \
\
python3 --version
# make some useful symlinks that are expected to exist ("/usr/local/bin/python" and friends)
RUN set -eux; \
for src in idle3 pydoc3 python3 python3-config; do \
dst = " $( echo " $src " | tr -d 3) " ; \
[ -s " /usr/local/bin/ $src " ] ; \
[ ! -e " /usr/local/bin/ $dst " ] ; \
ln -svT " $src " " /usr/local/bin/ $dst " ; \
done
# if this is called "PIP_VERSION", pip explodes with "ValueError: invalid truth value '<VERSION>'"
ENV PYTHON_PIP_VERSION 23.0.1
# https://github.com/docker-library/python/issues/365
ENV PYTHON_SETUPTOOLS_VERSION 65.5.1
# https://github.com/pypa/get-pip
ENV PYTHON_GET_PIP_URL https://github.com/pypa/get-pip/raw/dbf0c85f76fb6e1ab42aa672ffca6f0a675d9ee4/public/get-pip.py
ENV PYTHON_GET_PIP_SHA256 dfe9fd5c28dc98b5ac17979a953ea550cec37ae1b47a5116007395bfacff2ab9
RUN set -eux; \
\
wget -O get-pip.py " $PYTHON_GET_PIP_URL " ; \
echo " $PYTHON_GET_PIP_SHA256 *get-pip.py " | sha256sum -c -; \
\
export PYTHONDONTWRITEBYTECODE = 1; \
\
python get-pip.py \
--disable-pip-version-check \
--no-cache-dir \
--no-compile \
" pip== $PYTHON_PIP_VERSION " \
" setuptools== $PYTHON_SETUPTOOLS_VERSION " \
; \
rm -f get-pip.py; \
\
pip --version
# end of install python
2023-06-08 10:01:58 +08:00
2024-10-21 18:26:23 +08:00
ARG USE_GPU = { use_gpu}
2023-06-08 10:01:58 +08:00
# install pytorch
2024-10-21 18:26:23 +08:00
ARG TORCH_VERSION = { torch_version}
ARG CUDATOOLKIT_VERSION = { cudatoolkit_version}
2023-06-08 10:01:58 +08:00
RUN if [ " $USE_GPU " = "True" ] ; then \
2024-10-21 18:26:23 +08:00
pip install --no-cache-dir torch = = $TORCH_VERSION torchvision torchaudio; \
2023-06-08 10:01:58 +08:00
else \
2024-06-05 19:08:46 +08:00
pip install --no-cache-dir torch = = $TORCH_VERSION torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cpu; \
2023-06-08 10:01:58 +08:00
fi
# default shell bash
ENV SHELL = /bin/bash
# install special package
RUN if [ " $USE_GPU " = "True" ] ; then \
2024-10-23 09:59:51 +08:00
pip install --no-cache-dir dgl -f https://data.dgl.ai/wheels/$CUDATOOLKIT_VERSION /repo.html; \
2023-06-08 10:01:58 +08:00
else \
2023-11-27 20:21:00 +08:00
pip install --no-cache-dir dgl dglgo -f https://data.dgl.ai/wheels/repo.html; \
2023-06-08 10:01:58 +08:00
fi
# copy install scripts
COPY docker/scripts/install_unifold.sh docker/scripts/install_colmap.sh docker/scripts/install_pytorch3d_nvdiffrast.sh docker/scripts/install_tiny_cuda_nn.sh docker/scripts/install_apex.sh /tmp/
2023-11-27 20:21:00 +08:00
# 3d supports
2023-06-08 10:01:58 +08:00
RUN if [ " $USE_GPU " = "True" ] ; then \
2023-11-27 20:21:00 +08:00
bash /tmp/install_colmap.sh; \
2023-06-08 10:01:58 +08:00
else \
2023-11-27 20:21:00 +08:00
echo 'cpu unsupport colmap' ; \
2023-06-08 10:01:58 +08:00
fi
2023-11-27 20:21:00 +08:00
# install pytorch3d
2023-06-08 10:01:58 +08:00
RUN if [ " $USE_GPU " = "True" ] ; then \
2023-11-27 20:21:00 +08:00
bash /tmp/install_pytorch3d_nvdiffrast.sh; \
2023-06-08 10:01:58 +08:00
else \
2023-11-27 20:21:00 +08:00
echo 'cpu unsupport pytorch3d nvdiffrast' ; \
2023-06-08 10:01:58 +08:00
fi
2023-11-27 20:21:00 +08:00
# for uniford
2023-06-08 10:01:58 +08:00
RUN if [ " $USE_GPU " = "True" ] ; then \
2023-11-27 20:21:00 +08:00
bash /tmp/install_unifold.sh; \
2023-06-08 10:01:58 +08:00
else \
2023-11-27 20:21:00 +08:00
echo 'cpu unsupport uniford' ; \
2023-06-08 10:01:58 +08:00
fi
2023-11-27 20:21:00 +08:00
2023-06-08 10:01:58 +08:00
RUN if [ " $USE_GPU " = "True" ] ; then \
2023-11-27 20:21:00 +08:00
export TORCH_CUDA_ARCH_LIST = "6.0;6.1;7.0;7.5;8.0;8.9;9.0;8.6+PTX" && pip install --no-cache-dir git+https://github.com/gxd1994/Pointnet2.PyTorch.git@master#subdirectory= pointnet2; \
2023-06-08 10:01:58 +08:00
else \
2025-04-07 13:32:09 +08:00
echo 'CPU env does not support Pointnet2' ; \
fi
# NVIDIA apex building
RUN if [ " $USE_GPU " = "True" ] ; then \
pip install --no-cache-dir packaging && \
bash /tmp/install_apex.sh; \
else \
echo 'CPU env does not support NVIDIA Apex.' ; \
2023-06-08 10:01:58 +08:00
fi
2023-11-27 20:21:00 +08:00
2024-06-05 19:08:46 +08:00
2024-10-21 18:26:23 +08:00
ARG TENSORFLOW_VERSION = { tf_version}
2024-06-05 19:08:46 +08:00
RUN if [ " $USE_GPU " = "True" ] ; then \
pip install --no-cache-dir tensorflow = = $TENSORFLOW_VERSION ; \
else \
echo 'cpu not install tensorflow' ; \
2023-06-08 10:01:58 +08:00
fi
2023-07-25 21:15:00 +08:00
2024-06-05 19:08:46 +08:00
RUN if [ " $USE_GPU " = "True" ] ; then \
2024-10-23 09:59:51 +08:00
cd /tmp && git clone -b ms_build --single-branch https://github.com/tastelikefeet/mmcv.git && cd mmcv && TORCH_CUDA_ARCH_LIST = "6.0;6.1;7.0;7.5;8.0;8.9;9.0;8.6+PTX" MMCV_WITH_OPS = 1 MAX_JOBS = 32 FORCE_CUDA = 1 pip install . && cd / && rm -fr /tmp/mmcv && pip cache purge; \
2024-06-05 19:08:46 +08:00
else \
2024-10-23 09:59:51 +08:00
cd /tmp && git clone -b ms_build --single-branch https://github.com/tastelikefeet/mmcv.git && cd mmcv && MMCV_WITH_OPS = 1 MAX_JOBS = 32 pip install . && cd / && rm -fr /tmp/mmcv && pip cache purge; \
2023-11-27 20:21:00 +08:00
fi
2024-06-05 19:08:46 +08:00
2025-04-07 13:32:09 +08:00
RUN pip install --no-cache-dir https://github.com/liyaodev/fairseq/releases/download/v0.12.3.1/fairseq-0.12.3.1-cp311-cp311-linux_x86_64.whl # for py311
2024-10-23 09:59:51 +08:00
2023-07-25 21:15:00 +08:00
ENTRYPOINT [ ]