| # AVH-Align 开发镜像 | |
| # --------------------------------------------------------------- | |
| # base: NVIDIA CUDA 12.1 + cuDNN8 devel(与 av env 的 torch 2.2.0+cu121 对齐) | |
| # 用 devel 而不是 runtime,是因为 fairseq / dlib 编译时需要 nvcc 与头文件。 | |
| # (如果确定不再重编译扩展,可以换 runtime 减小 ~2GB。) | |
| # python: 3.10.20(与 av env 一致) | |
| # 假设:仓库代码通过 -v /apdcephfs_gy5/...:/workspace/AVH-Align 挂载进来, | |
| # 所以 fairseq 的 editable install 的路径在容器里是 /workspace/AVH-Align/av_hubert/fairseq | |
| FROM nvidia/cuda:12.1.1-cudnn8-devel-ubuntu22.04 | |
| ENV DEBIAN_FRONTEND=noninteractive \ | |
| LANG=C.UTF-8 \ | |
| PYTHONDONTWRITEBYTECODE=1 \ | |
| PYTHONUNBUFFERED=1 \ | |
| PIP_NO_CACHE_DIR=1 \ | |
| PIP_DISABLE_PIP_VERSION_CHECK=1 | |
| # ----- 系统依赖 ----- | |
| # ffmpeg : distortions.py 的 crf / bitrate / frame_rate 等扰动需要 | |
| # libsndfile1: librosa / soundfile 需要 | |
| # libgl1 : opencv-python-headless 仍需 libGL | |
| # git : fairseq editable install 需要 | |
| # build-essential + cmake + ninja: dlib / 某些 native ext 需要 | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| python3.10 python3.10-dev python3.10-distutils python3-pip \ | |
| ffmpeg libsndfile1 libgl1 libglib2.0-0 \ | |
| git wget curl ca-certificates \ | |
| build-essential cmake ninja-build pkg-config \ | |
| && ln -sf /usr/bin/python3.10 /usr/bin/python \ | |
| && ln -sf /usr/bin/python3.10 /usr/bin/python3 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # 升级 pip / setuptools / wheel(某些老包如 hydra-core==1.0.7 需要 setuptools<60) | |
| RUN python -m pip install --upgrade "pip<25" "setuptools<60" "wheel" | |
| # ----- pip 依赖 ----- | |
| # 先装 torch(cu121 wheel 直接指定 index url,避免升级到最新版) | |
| RUN pip install \ | |
| torch==2.2.0+cu121 \ | |
| torchvision==0.17.0+cu121 \ | |
| --index-url https://download.pytorch.org/whl/cu121 | |
| # 其余业务依赖 | |
| COPY requirements.txt /tmp/requirements.txt | |
| # torch/torchvision 已单独装,requirements 里可能再列一遍,不影响(pip 会跳过) | |
| RUN pip install -r /tmp/requirements.txt | |
| # ----- fairseq (editable) ----- | |
| # 约定:运行时通过 -v 把整个 AVH-Align 仓库挂到 /workspace/AVH-Align | |
| # 首次进入容器时(或 image build 时,如果 COPY 了仓库)执行: | |
| # cd /workspace/AVH-Align/av_hubert/fairseq && pip install -e . --no-deps | |
| # 这里给一个 entrypoint 帮忙自动检测 + 安装。 | |
| COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh | |
| RUN chmod +x /usr/local/bin/docker-entrypoint.sh | |
| # 默认工作目录:代码挂载点 | |
| WORKDIR /workspace/AVH-Align | |
| # 默认打开 bash;开发用 | |
| ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] | |
| CMD ["/bin/bash"] | |