-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build(Dockerfile): Update to use newer base image
- Loading branch information
1 parent
5c5db16
commit 7cf37ee
Showing
1 changed file
with
49 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,55 @@ | ||
# 第一阶段:基础镜像,安装必要的依赖项 | ||
FROM nvidia/cuda:11.6.1-cudnn8-devel-ubuntu20.04 AS base | ||
FROM nvidia/cuda:12.4.1-cudnn-devel-ubuntu22.04 | ||
|
||
# Required to build Ubuntu 22.04 without user prompts with DLFW container | ||
ARG DEBIAN_FRONTEND=noninteractive | ||
ENV TZ=Asia/Shanghai | ||
|
||
RUN apt update && apt install -y --no-install-recommends \ | ||
software-properties-common \ | ||
liblapack-dev \ | ||
libblas-dev \ | ||
unzip \ | ||
p7zip \ | ||
git \ | ||
wget \ | ||
python3-pip \ | ||
ffmpeg \ | ||
libopencv-dev \ | ||
&& add-apt-repository ppa:xmake-io/xmake \ | ||
&& apt install -y --no-install-recommends xmake \ | ||
&& apt clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# 第二阶段:安装 TensorRT | ||
FROM base AS trt_install | ||
|
||
RUN wget --no-check-certificate -O tensorrt.tar.gz https://developer.nvidia.com/compute/machine-learning/tensorrt/secure/8.6.1/tars/TensorRT-8.6.1.6.Linux.x86_64-gnu.cuda-11.8.tar.gz \ | ||
&& tar -xvf tensorrt.tar.gz -C /usr/local --transform 's/^TensorRT-8.6.1.6/tensorrt/' \ | ||
&& rm -f tensorrt.tar.gz | ||
|
||
# 第三阶段:最终镜像 | ||
FROM base | ||
|
||
COPY --from=trt_install /usr/local/tensorrt /usr/local/tensorrt | ||
|
||
# 安装 Python 包 | ||
RUN python3 -m pip install /usr/local/tensorrt/python/tensorrt-8.6.1-cp38-none-linux_x86_64.whl \ | ||
/usr/local/tensorrt/python/tensorrt_dispatch-8.6.1-cp38-none-linux_x86_64.whl \ | ||
/usr/local/tensorrt/python/tensorrt_lean-8.6.1-cp38-none-linux_x86_64.whl \ | ||
/usr/local/tensorrt/onnx_graphsurgeon/onnx_graphsurgeon-0.3.12-py2.py3-none-any.whl \ | ||
cuda-python==11.6.1 | ||
|
||
RUN python3 -m pip install torch torchvision --index-url https://download.pytorch.org/whl/cu116 | ||
|
||
RUN python3 -m pip install tensorrt-yolo | ||
|
||
# 设置环境变量 | ||
ENV XMAKE_ROOT=y \ | ||
# Set environment and working directory | ||
ENV TZ=Asia/Shanghai \ | ||
PATH="${PATH}:/usr/local/tensorrt/bin" \ | ||
LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/local/tensorrt/lib" | ||
|
||
# 默认命令 | ||
CMD ["/bin/bash"] | ||
# Install requried libraries | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
software-properties-common \ | ||
build-essential \ | ||
gdb \ | ||
libopencv-dev \ | ||
wget \ | ||
git \ | ||
pkg-config \ | ||
ssh \ | ||
pbzip2 \ | ||
bzip2 \ | ||
unzip \ | ||
axel | ||
|
||
# Install python3 | ||
RUN apt-get install -y --no-install-recommends \ | ||
python3 \ | ||
python3-pip \ | ||
python3-dev \ | ||
python3-wheel &&\ | ||
cd /usr/local/bin &&\ | ||
ln -s /usr/bin/python3 python &&\ | ||
ln -s /usr/bin/pip3 pip; | ||
|
||
# Install TensorRT | ||
RUN axel --insecure -o /tmp/tensorrt.tar.gz https://developer.nvidia.com/downloads/compute/machine-learning/tensorrt/10.4.0/tars/TensorRT-10.4.0.26.Linux.x86_64-gnu.cuda-12.6.tar.gz \ | ||
&& tar -xvf /tmp/tensorrt.tar.gz -C /usr/local --transform 's/^TensorRT-10.4.0.26/tensorrt/' \ | ||
&& rm -f /tmp/tensorrt.tar.gz | ||
|
||
# Install PyPI packages | ||
RUN pip3 install --upgrade pip | ||
RUN pip3 install setuptools>=41.0.0 | ||
RUN pip3 install "pybind11[global]" | ||
|
||
# Install Cmake | ||
RUN axel --insecure -o /tmp/cmake.sh https://www.ghproxy.cn/https://github.com/Kitware/CMake/releases/download/v3.30.5/cmake-3.30.5-linux-x86_64.sh && \ | ||
chmod +x /tmp/cmake.sh && \ | ||
/tmp/cmake.sh --prefix=/usr/local --exclude-subdir --skip-license && \ | ||
rm /tmp/cmake.sh | ||
|
||
WORKDIR /workspace | ||
VOLUME /workspace | ||
|
||
RUN ["/bin/bash"] |