-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
60 lines (48 loc) · 2.14 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# 使用 CUDA 11.6 开发版镜像(Ubuntu 20.04),便于编译 CUDA 代码
FROM nvidia/cuda:11.6.1-cudnn8-devel-ubuntu20.04
# 安装必要的系统工具(wget、git、bzip2、ca-certificates 等)
RUN apt-get update && apt-get install -y --no-install-recommends \
libgl1-mesa-glx \
wget \
git \
bzip2 \
ca-certificates \
libglib2.0-0 \
libxext6 \
libsm6 \
libxrender1 \
&& rm -rf /var/lib/apt/lists/*
# 安装 Miniconda 及编译工具
RUN apt-get update && apt-get install -y wget build-essential && \
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \
bash Miniconda3-latest-Linux-x86_64.sh -b -p /opt/conda && \
rm Miniconda3-latest-Linux-x86_64.sh && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# 将 Miniconda 加入 PATH
ENV CONDA_DIR=/opt/conda
ENV PATH=$CONDA_DIR/bin:$PATH
# 设置工作目录为 /workspace/mvipnerf
WORKDIR /workspace/mvipnerf
# 使用 conda 创建虚拟环境 mvipnerf(Python 3.8)
RUN conda create -n mvipnerf python=3.8 -y && \
conda clean -afy
# 将 requirements 文件复制到工作目录下(确保文件名正确)
COPY requirements_df.txt ./
# 设置用于 tiny-cuda-nn 编译的目标 CUDA compute capabilities
ENV TCNN_CUDA_ARCHITECTURES="75,80,86,90"
# 在 mvipnerf 环境中安装 PyTorch 和其他依赖包
RUN /bin/bash -c "source /opt/conda/etc/profile.d/conda.sh && \
conda activate mvipnerf && \
pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 torchaudio==0.13.1 --extra-index-url https://download.pytorch.org/whl/cu117 && \
pip install -r requirements_df.txt && \
pip install lpips && \
pip install ConfigArgParse"
# 初始化 conda 到 bash 中,并在 .bashrc 中追加自动激活 mvipnerf 环境
RUN /opt/conda/bin/conda init bash && echo "conda activate mvipnerf" >> ~/.bashrc
# 设置默认使用 mvipnerf 环境中的 Python
ENV CONDA_DEFAULT_ENV=mvipnerf
ENV PATH=/opt/conda/envs/mvipnerf/bin:$PATH
# 声明挂载点,方便在运行容器时将本地工作目录挂载进来
VOLUME ["/workspace/mvipnerf"]
# 默认启动 bash(.bashrc 中自动激活 mvipnerf 环境)
CMD ["/bin/bash"]