Spaces:
Runtime error
Runtime error
FROM nvidia/cuda:12.1.0-devel-ubuntu22.04 | |
# 设置非交互模式 | |
ENV DEBIAN_FRONTEND=noninteractive | |
# 安装必要的系统依赖 | |
RUN apt-get update && apt-get install -y --no-install-recommends \ | |
wget \ | |
curl \ | |
git \ | |
ca-certificates \ | |
&& rm -rf /var/lib/apt/lists/* | |
# 安装 Miniconda | |
RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /tmp/miniconda.sh && \ | |
bash /tmp/miniconda.sh -b -p /opt/conda && \ | |
rm /tmp/miniconda.sh | |
ENV PATH=/opt/conda/bin:$PATH | |
# 创建 conda 环境 “videograin”,指定 Python 3.10 | |
RUN conda create -n videograin python=3.10 -y | |
# 在 “videograin” 环境中安装 PyTorch、CUDA 支持及 Xformers | |
RUN conda install -n videograin pytorch==2.3.1 torchvision==0.18.1 torchaudio==2.3.1 pytorch-cuda=12.1 -c pytorch -c nvidia -y && \ | |
conda run -n videograin pip install --pre -U xformers==0.0.27 | |
# 创建非 root 用户(uid=1000) | |
RUN useradd -m -u 1000 user | |
USER user | |
ENV HOME=/home/user | |
WORKDIR ${HOME}/app | |
# 复制本地 requirements.txt 进容器,并在 “videograin” 环境中安装 pip 依赖 | |
COPY --chown=user:user requirements.txt /tmp/requirements.txt | |
RUN conda run -n videograin pip install --no-cache-dir -r /tmp/requirements.txt | |
# 强制安装指定版本的 huggingface-hub 和 gradio[oauth](同时安装 uvicorn 和 spaces) | |
RUN conda run -n videograin pip install --no-cache-dir huggingface-hub==0.17.3 gradio[oauth]==3.44.4 "uvicorn>=0.14.0" spaces==0.32.0 | |
# 复制应用代码 | |
COPY --chown=user:user . ${HOME}/app | |
# 设置环境变量,确保使用 “videograin” 环境中的 Python | |
ENV PATH=/opt/conda/envs/videograin/bin:$PATH \ | |
PYTHONUNBUFFERED=1 | |
# 默认启动命令 | |
CMD ["python", "app.py"] | |