NatureLM-Audio / Dockerfile
gagannarula's picture
test PR #226: sync app package with gpu group, --no-sync at start, clone branch
c2cb7b8 verified
Raw History Blame Contribute Delete
1.74 kB
FROM nvidia/cuda:12.6.3-cudnn-runtime-ubuntu22.04
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONUNBUFFERED=1
ENV UV_NO_DEV=1
ENV UV_NO_CACHE=1
ENV GRADIO_ANALYTICS_ENABLED="False"
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
RUN apt-get update && apt-get install -y \
git \
git-lfs \
ffmpeg \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& git lfs install
# HF Spaces runs the container as a non-root user (UID 1000) at runtime. Create
# that user and build everything under it so it owns the .venv and can execute
# /app/esp-research/.venv/bin/python3.
RUN useradd -m -u 1000 user
RUN mkdir -p /app && chown -R user:user /app
USER user
ENV HOME=/home/user
RUN --mount=type=secret,id=GH_TOKEN,mode=0444,required=true \
git -c "http.https://github.com/.extraheader=Authorization: Basic $(printf 'x-access-token:%s' "$(cat /run/secrets/GH_TOKEN)" | base64 | tr -d '\n')" \
clone --single-branch --depth 1 --branch fix-hf-app-cuda-torch https://github.com/earthspecies/esp-research.git /app/esp-research
# alp-data is now published on PyPI and is in esp-research's pyproject.toml,
# so uv sync resolves it directly, no clone needed.
# Sync this app's package (and its `gpu` group, which pins torch/torchaudio to
# the cu126 index) so the venv built here is exactly what the app runs with.
WORKDIR /app/esp-research
RUN uv sync --frozen --package naturelm-audio-hf-app --group gpu
WORKDIR /app/esp-research/projects/NatureLM-audio-hf-app
EXPOSE 7860
# --no-sync: never re-resolve at container start. `uv run` would otherwise sync
# the app package without its `gpu` group and replace the cu126 torch stack with
# the CUDA 13 wheel from PyPI.
CMD ["uv", "run", "--no-sync", "app.py"]