Spaces:
Runtime error
Runtime error
File size: 2,579 Bytes
61e5352 415d6ab 61e5352 415d6ab 40bffeb 415d6ab 40bffeb 415d6ab 2a2f471 415d6ab 2a2f471 415d6ab 61e5352 415d6ab 61e5352 415d6ab 61e5352 415d6ab 06112bf 415d6ab 40bffeb 415d6ab 40bffeb 06112bf 40bffeb 2a2f471 40bffeb 06112bf 2a2f471 06112bf 2a2f471 06112bf 40bffeb 2a2f471 415d6ab 2a2f471 415d6ab 2a2f471 06112bf |
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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# 使用与原始模板相同的基础镜像
FROM nvidia/cuda:12.5.1-cudnn-devel-ubuntu20.04
# 设置环境变量,避免交互式提示
ENV DEBIAN_FRONTEND=noninteractive \
TZ=Europe/Paris
# 安装所有必要的工具
RUN rm -f /etc/apt/sources.list.d/*.list && \
apt-get update && apt-get install -y --no-install-recommends \
curl ca-certificates git wget procps git-lfs zip unzip htop vim nano bzip2 \
libx11-6 build-essential libsndfile-dev software-properties-common dos2unix mount file \
&& rm -rf /var/lib/apt/lists/*
# 安装 nvtop 和 nodejs
RUN add-apt-repository ppa:flexiondotorg/nvtop && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends nvtop
RUN curl -sL https://deb.nodesource.com/setup_21.x | bash - && \
apt-get install -y nodejs && \
npm install -g configurable-http-proxy
# 设置 Conda 环境
ENV CONDA_AUTO_UPDATE_CONDA=false \
PATH=/opt/conda/bin:$PATH
RUN curl -sLo ~/miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-py39_4.10.3-Linux-x86_64.sh \
&& chmod +x ~/miniconda.sh \
&& ~/miniconda.sh -b -p /opt/conda \
&& rm ~/miniconda.sh \
&& conda clean -ya
# 设置 HOME 环境变量和工作目录
ENV HOME=/root
WORKDIR $HOME/app
# 保留您原有的、完整的root执行部分
RUN --mount=target=/root/packages.txt,source=packages.txt \
apt-get update && \
xargs -r -a /root/packages.txt apt-get install -y --no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
RUN --mount=target=/root/on_startup.sh,source=on_startup.sh,readwrite \
bash /root/on_startup.sh
RUN --mount=target=requirements.txt,source=requirements.txt \
pip install --no-cache-dir --upgrade -r requirements.txt
# --- 终极核心解决方案:重定向所有配置和数据目录 ---
# 1. 在 /data 目录下创建 jupyter 和 ipython 需要的所有子目录
RUN mkdir -p /data/jupyter/config /data/jupyter/data /data/jupyter/runtime /data/ipython
# 2. 通过环境变量,强制 jupyter 和 ipython 使用 /data 下的目录
ENV JUPYTER_CONFIG_DIR=/data/jupyter/config
ENV JUPYTER_DATA_DIR=/data/jupyter/data
ENV JUPYTER_RUNTIME_DIR=/data/jupyter/runtime
ENV IPYTHONDIR=/data/ipython
# --- 解决方案结束 ---
# 复制所有项目文件
COPY . $HOME/app
# 确保脚本可执行
RUN chmod +x start_server.sh
# 设置其他环境变量
ENV PYTHONUNBUFFERED=1 \
GRADIO_ALLOW_FLAGGING=never \
GRADIO_NUM_PORTS=1 \
GRADIO_SERVER_NAME=0.0.0.0 \
GRADIO_THEME=huggingface \
SYSTEM=spaces \
SHELL=/bin/bash
# 使用最稳健的方式启动
CMD ["/bin/bash", "./start_server.sh"] |