90 lines
3.9 KiB
Docker
Executable File
90 lines
3.9 KiB
Docker
Executable File
# 开发镜像(GPU):Ubuntu 22.04 + CUDA 12.1 runtime + Node 22 + cadquery + PyTorch(cu121) + PyTorch3D
|
||
# 用于装配检测「最近零件」服务端 GPU(scripts/assembly_nearest_gpu.py)
|
||
# 宿主机需:NVIDIA 驱动 + nvidia-container-toolkit;构建不要求 GPU,运行需 --gpus
|
||
#
|
||
# 构建:docker build -t massive-point-cloud-app-dev:local -f docker/Dockerfile.dev.gpu .
|
||
#
|
||
# 无 NVIDIA 的机器请改用 docker/Dockerfile.dev(仅 CPU),compose 中去掉 gpus 与 ASSEMBLY_USE_GPU
|
||
|
||
FROM nvidia/cuda:12.1.1-cudnn8-runtime-ubuntu22.04
|
||
|
||
ENV DEBIAN_FRONTEND=noninteractive \
|
||
PYTHON3_PATH=/usr/bin/python3 \
|
||
ASSEMBLY_USE_GPU=1 \
|
||
NVIDIA_VISIBLE_DEVICES=all \
|
||
NVIDIA_DRIVER_CAPABILITIES=compute,utility
|
||
|
||
# apt 换阿里云(国内构建加速);需官方源时可在下方注释掉本段
|
||
RUN set -eux; \
|
||
if [ -f /etc/apt/sources.list ]; then \
|
||
sed -i 's|http://archive.ubuntu.com/ubuntu|http://mirrors.aliyun.com/ubuntu|g' /etc/apt/sources.list; \
|
||
sed -i 's|http://security.ubuntu.com/ubuntu|http://mirrors.aliyun.com/ubuntu|g' /etc/apt/sources.list; \
|
||
fi
|
||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||
python3 \
|
||
python3-pip \
|
||
python3-dev \
|
||
ca-certificates \
|
||
curl \
|
||
gnupg \
|
||
libgl1 \
|
||
libglib2.0-0 \
|
||
libxrender1 \
|
||
libxext6 \
|
||
libsm6 \
|
||
libice6 \
|
||
libx11-6 \
|
||
&& rm -rf /var/lib/apt/lists/*
|
||
|
||
# CUDA runtime 镜像默认不带 nvidia-smi;装 Ubuntu 的 nvidia-utils(主版本与宿主机驱动大版本一致,如 535/550)
|
||
# 构建失败时改:--build-arg NVIDIA_UTILS_MAJOR=550
|
||
ARG NVIDIA_UTILS_MAJOR=535
|
||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||
"nvidia-utils-${NVIDIA_UTILS_MAJOR}" \
|
||
&& rm -rf /var/lib/apt/lists/*
|
||
|
||
RUN mkdir -p /etc/apt/keyrings \
|
||
&& curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
|
||
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_22.x nodistro main" > /etc/apt/sources.list.d/nodesource.list \
|
||
&& apt-get update && apt-get install -y --no-install-recommends nodejs \
|
||
&& rm -rf /var/lib/apt/lists/*
|
||
|
||
RUN python3 -m pip install --no-cache-dir --upgrade pip setuptools wheel
|
||
|
||
# cadquery(与 Dockerfile.dev 一致)
|
||
ARG PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
|
||
ARG PIP_DEFAULT_TIMEOUT=300
|
||
COPY requirements-geometry.txt /tmp/requirements-geometry.txt
|
||
RUN python3 -m pip install --no-cache-dir --break-system-packages \
|
||
--default-timeout="${PIP_DEFAULT_TIMEOUT}" \
|
||
--retries 10 \
|
||
-i "${PIP_INDEX_URL}" \
|
||
-r /tmp/requirements-geometry.txt \
|
||
&& rm /tmp/requirements-geometry.txt \
|
||
&& python3 -c "import cadquery; print('cadquery OK')"
|
||
|
||
# PyTorch CUDA 12.1:默认清华镜像;覆盖示例:--build-arg TORCH_INDEX_URL=https://download.pytorch.org/whl/cu121
|
||
ARG TORCH_INDEX_URL=https://mirrors.tuna.tsinghua.edu.cn/pytorch/whl/cu121
|
||
RUN python3 -m pip install --no-cache-dir --break-system-packages \
|
||
--default-timeout=300 --retries 10 \
|
||
torch==2.3.1 torchvision==0.18.1 \
|
||
--index-url "${TORCH_INDEX_URL}"
|
||
|
||
# PyTorch3D 预编译轮仅 Meta 官方 CDN,无稳定国内镜像;加大超时。可本地下载 wheel 后 COPY + pip install。
|
||
RUN python3 -m pip install --no-cache-dir --break-system-packages \
|
||
--default-timeout=300 --retries 10 \
|
||
-i https://pypi.tuna.tsinghua.edu.cn/simple \
|
||
trimesh \
|
||
&& python3 -m pip install --no-cache-dir --break-system-packages \
|
||
--default-timeout=600 --retries 15 \
|
||
pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/py310_cu121_pyt231/download.html
|
||
|
||
RUN python3 -c "import torch; import pytorch3d; import trimesh; print('pytorch', torch.__version__, 'pytorch3d', pytorch3d.__version__)"
|
||
|
||
WORKDIR /app
|
||
|
||
RUN corepack enable && corepack prepare pnpm@latest --activate
|
||
|
||
CMD ["node", "-e", "console.log('use docker-compose command')"]
|