Commit
·
a628b37
1
Parent(s):
c985b41
solving for those nightlys that no longer exist lol
Browse files- Dockerfile +101 -116
Dockerfile
CHANGED
|
@@ -1,23 +1,20 @@
|
|
| 1 |
-
# thecollabagepatch/magenta:latest
|
| 2 |
FROM nvidia/cuda:12.6.2-cudnn-runtime-ubuntu22.04
|
| 3 |
|
| 4 |
-
# CUDA
|
| 5 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 6 |
cuda-libraries-12-4 && rm -rf /var/lib/apt/lists/*
|
| 7 |
ENV LD_LIBRARY_PATH=/usr/local/cuda/lib64:/usr/local/cuda-12.4/lib64:/usr/local/cuda-12.4/compat:/usr/local/cuda/targets/x86_64-linux/lib:${LD_LIBRARY_PATH}
|
| 8 |
RUN ln -sf /usr/local/cuda/targets/x86_64-linux/lib /usr/local/cuda/lib64 || true
|
| 9 |
|
| 10 |
-
#
|
| 11 |
RUN set -eux; \
|
| 12 |
apt-get update && apt-get install -y --no-install-recommends gnupg ca-certificates curl; \
|
| 13 |
install -d -m 0755 /usr/share/keyrings; \
|
| 14 |
-
# Refresh the *same* keyring the base source uses (no second source file)
|
| 15 |
curl -fsSL https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/3bf863cc.pub \
|
| 16 |
| gpg --batch --yes --dearmor -o /usr/share/keyrings/cuda-archive-keyring.gpg; \
|
| 17 |
apt-get update; \
|
| 18 |
-
# If libcudnn is "held", unhold it so we can move to 9.8
|
| 19 |
apt-mark unhold libcudnn9-cuda-12 || true; \
|
| 20 |
-
# Install cuDNN 9.8 for CUDA 12 (correct dev package name!)
|
| 21 |
apt-get install -y --no-install-recommends \
|
| 22 |
'libcudnn9-cuda-12=9.8.*' \
|
| 23 |
'libcudnn9-dev-cuda-12=9.8.*' \
|
|
@@ -26,135 +23,123 @@ RUN set -eux; \
|
|
| 26 |
ldconfig; \
|
| 27 |
rm -rf /var/lib/apt/lists/*
|
| 28 |
|
| 29 |
-
#
|
| 30 |
ENV LD_PRELOAD=/usr/local/cuda/lib64/libcusparse.so.12:/usr/local/cuda/lib64/libcublas.so.12:/usr/local/cuda/lib64/libcublasLt.so.12:/usr/local/cuda/lib64/libcufft.so.11:/usr/local/cuda/lib64/libcusolver.so.11
|
| 31 |
-
|
| 32 |
-
# Better allocator (less fragmentation than BFC during XLA autotune)
|
| 33 |
ENV TF_GPU_ALLOCATOR=cuda_malloc_async
|
| 34 |
-
|
| 35 |
-
# Let cuBLAS use TF32 fast path on Ada (L40S) for big GEMMs
|
| 36 |
ENV TF_ENABLE_CUBLAS_TF32=1 NVIDIA_TF32_OVERRIDE=1
|
| 37 |
|
| 38 |
ENV DEBIAN_FRONTEND=noninteractive \
|
| 39 |
PYTHONUNBUFFERED=1 \
|
| 40 |
PIP_NO_CACHE_DIR=1 \
|
| 41 |
TF_FORCE_GPU_ALLOW_GROWTH=true \
|
| 42 |
-
XLA_PYTHON_CLIENT_PREALLOCATE=false
|
|
|
|
| 43 |
|
| 44 |
-
|
| 45 |
|
| 46 |
-
#
|
| 47 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 48 |
-
software-properties-common curl ca-certificates
|
|
|
|
| 49 |
libsndfile1 ffmpeg \
|
| 50 |
-
build-essential pkg-config \
|
| 51 |
&& add-apt-repository ppa:deadsnakes/ppa -y \
|
| 52 |
&& apt-get update && apt-get install -y --no-install-recommends \
|
| 53 |
-
python3.11 python3.11-
|
| 54 |
&& rm -rf /var/lib/apt/lists/*
|
| 55 |
|
| 56 |
-
# Make python3
|
| 57 |
-
RUN ln -sf /usr/bin/python3.11 /usr/bin/python &&
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
#
|
| 64 |
-
RUN
|
| 65 |
-
|
| 66 |
-
#
|
| 67 |
-
RUN
|
| 68 |
-
|
| 69 |
-
#
|
| 70 |
-
RUN
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
#
|
| 87 |
-
RUN
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
RUN
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
# Switch to Spaces’ preferred user
|
| 134 |
-
# Switch to Spaces’ preferred user
|
| 135 |
RUN useradd -m -u 1000 appuser
|
| 136 |
WORKDIR /home/appuser/app
|
| 137 |
|
| 138 |
-
#
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
COPY --chown=appuser:appuser
|
| 144 |
-
|
| 145 |
-
COPY --chown=appuser:appuser
|
| 146 |
-
|
| 147 |
-
COPY --chown=appuser:appuser model_management.py /home/appuser/app/
|
| 148 |
-
|
| 149 |
-
COPY --chown=appuser:appuser
|
| 150 |
-
|
| 151 |
-
COPY --chown=appuser:appuser
|
| 152 |
-
|
| 153 |
-
COPY --chown=appuser:appuser magentaRT_rt_tester.html /home/appuser/app/magentaRT_rt_tester.html
|
| 154 |
-
|
| 155 |
-
COPY --chown=appuser:appuser magenta_prompts.js /home/appuser/app/magenta_prompts.js
|
| 156 |
-
|
| 157 |
-
# Create docs directory and copy documentation files
|
| 158 |
COPY --chown=appuser:appuser docs/ /home/appuser/app/docs/
|
| 159 |
|
| 160 |
USER appuser
|
|
|
|
| 1 |
+
# thecollabagepatch/magenta:latest - Duplicable x86_64 build
|
| 2 |
FROM nvidia/cuda:12.6.2-cudnn-runtime-ubuntu22.04
|
| 3 |
|
| 4 |
+
# Ensure CUDA libraries are on loader path
|
| 5 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 6 |
cuda-libraries-12-4 && rm -rf /var/lib/apt/lists/*
|
| 7 |
ENV LD_LIBRARY_PATH=/usr/local/cuda/lib64:/usr/local/cuda-12.4/lib64:/usr/local/cuda-12.4/compat:/usr/local/cuda/targets/x86_64-linux/lib:${LD_LIBRARY_PATH}
|
| 8 |
RUN ln -sf /usr/local/cuda/targets/x86_64-linux/lib /usr/local/cuda/lib64 || true
|
| 9 |
|
| 10 |
+
# Install cuDNN 9.8 for better compatibility
|
| 11 |
RUN set -eux; \
|
| 12 |
apt-get update && apt-get install -y --no-install-recommends gnupg ca-certificates curl; \
|
| 13 |
install -d -m 0755 /usr/share/keyrings; \
|
|
|
|
| 14 |
curl -fsSL https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/3bf863cc.pub \
|
| 15 |
| gpg --batch --yes --dearmor -o /usr/share/keyrings/cuda-archive-keyring.gpg; \
|
| 16 |
apt-get update; \
|
|
|
|
| 17 |
apt-mark unhold libcudnn9-cuda-12 || true; \
|
|
|
|
| 18 |
apt-get install -y --no-install-recommends \
|
| 19 |
'libcudnn9-cuda-12=9.8.*' \
|
| 20 |
'libcudnn9-dev-cuda-12=9.8.*' \
|
|
|
|
| 23 |
ldconfig; \
|
| 24 |
rm -rf /var/lib/apt/lists/*
|
| 25 |
|
| 26 |
+
# Performance optimizations for L40S/Ada
|
| 27 |
ENV LD_PRELOAD=/usr/local/cuda/lib64/libcusparse.so.12:/usr/local/cuda/lib64/libcublas.so.12:/usr/local/cuda/lib64/libcublasLt.so.12:/usr/local/cuda/lib64/libcufft.so.11:/usr/local/cuda/lib64/libcusolver.so.11
|
|
|
|
|
|
|
| 28 |
ENV TF_GPU_ALLOCATOR=cuda_malloc_async
|
|
|
|
|
|
|
| 29 |
ENV TF_ENABLE_CUBLAS_TF32=1 NVIDIA_TF32_OVERRIDE=1
|
| 30 |
|
| 31 |
ENV DEBIAN_FRONTEND=noninteractive \
|
| 32 |
PYTHONUNBUFFERED=1 \
|
| 33 |
PIP_NO_CACHE_DIR=1 \
|
| 34 |
TF_FORCE_GPU_ALLOW_GROWTH=true \
|
| 35 |
+
XLA_PYTHON_CLIENT_PREALLOCATE=false \
|
| 36 |
+
JAX_PLATFORMS=""
|
| 37 |
|
| 38 |
+
SHELL ["/bin/bash", "-c"]
|
| 39 |
|
| 40 |
+
# Install system dependencies
|
| 41 |
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 42 |
+
software-properties-common curl ca-certificates \
|
| 43 |
+
build-essential pkg-config git \
|
| 44 |
libsndfile1 ffmpeg \
|
|
|
|
| 45 |
&& add-apt-repository ppa:deadsnakes/ppa -y \
|
| 46 |
&& apt-get update && apt-get install -y --no-install-recommends \
|
| 47 |
+
python3.11 python3.11-dev python3.11-venv python3-pip \
|
| 48 |
&& rm -rf /var/lib/apt/lists/*
|
| 49 |
|
| 50 |
+
# Make python3.11 default and install uv for faster package installs
|
| 51 |
+
RUN ln -sf /usr/bin/python3.11 /usr/bin/python && \
|
| 52 |
+
ln -sf /usr/bin/python3.11 /usr/bin/python3 && \
|
| 53 |
+
python -m pip install --upgrade pip && \
|
| 54 |
+
python -m pip install uv
|
| 55 |
+
|
| 56 |
+
# CRITICAL: Install TensorFlow FIRST to block tensorflow-cpu
|
| 57 |
+
# Using generic tf-nightly (no specific date) for duplicability
|
| 58 |
+
RUN uv pip install --system tf-nightly
|
| 59 |
+
|
| 60 |
+
# Install JAX with CUDA support (pinned for stability)
|
| 61 |
+
RUN uv pip install --system "jax[cuda12]==0.4.35" "jaxlib==0.4.35"
|
| 62 |
+
|
| 63 |
+
# Install base dependencies
|
| 64 |
+
RUN uv pip install --system \
|
| 65 |
+
absl-py chex gin-config numpy requests tqdm typing-extensions \
|
| 66 |
+
google-cloud-storage librosa resampy soundfile sentencepiece
|
| 67 |
+
|
| 68 |
+
# Clone and install t5x WITHOUT dependencies (avoid tensorflow-cpu)
|
| 69 |
+
RUN git clone https://github.com/google-research/t5x.git /t5x && \
|
| 70 |
+
cd /t5x && \
|
| 71 |
+
git checkout 92c5b467a5964d06c351c7eae4aa4bcd341c7ded && \
|
| 72 |
+
uv pip install --system --no-deps -e .
|
| 73 |
+
|
| 74 |
+
# Install flaxformer without deps
|
| 75 |
+
RUN git clone https://github.com/google/flaxformer.git /flaxformer && \
|
| 76 |
+
cd /flaxformer && \
|
| 77 |
+
git checkout 399ea3a && \
|
| 78 |
+
uv pip install --system --no-deps -e .
|
| 79 |
+
|
| 80 |
+
# Install seqio without deps and PATCH OUT tensorflow_text
|
| 81 |
+
RUN git clone https://github.com/google/seqio.git /seqio && \
|
| 82 |
+
cd /seqio && \
|
| 83 |
+
uv pip install --system --no-deps -e . && \
|
| 84 |
+
# CRITICAL FIX: Remove unused tensorflow_text import (not needed by Magenta RT)
|
| 85 |
+
sed -i '/import tensorflow_text as tf_text/d' /seqio/seqio/vocabularies.py
|
| 86 |
+
|
| 87 |
+
# Install airio (t5x dependency) without deps
|
| 88 |
+
RUN git clone https://github.com/google/airio.git /airio && \
|
| 89 |
+
cd /airio && \
|
| 90 |
+
uv pip install --system --no-deps -e .
|
| 91 |
+
|
| 92 |
+
# Install clu without deps
|
| 93 |
+
RUN git clone https://github.com/google/CommonLoopUtils.git /clu && \
|
| 94 |
+
cd /clu && \
|
| 95 |
+
uv pip install --system --no-deps -e .
|
| 96 |
+
|
| 97 |
+
# Now install all remaining dependencies these packages need
|
| 98 |
+
RUN uv pip install --system \
|
| 99 |
+
flax optax orbax-checkpoint \
|
| 100 |
+
fiddle cached_property tf2jax \
|
| 101 |
+
aqtp etils jestimator \
|
| 102 |
+
tensorflow-datasets tfds-nightly \
|
| 103 |
+
apache-beam pyyaml rouge-score sacrebleu scipy \
|
| 104 |
+
grain-nightly editdistance pyglove
|
| 105 |
+
|
| 106 |
+
# Patch jestimator for newer JAX - PartitionSpec moved to jax.sharding
|
| 107 |
+
RUN sed -i 's|from jax.experimental.pjit import PartitionSpec|from jax.sharding import PartitionSpec|g' \
|
| 108 |
+
/usr/local/lib/python3.11/dist-packages/jestimator/amos_helper.py || \
|
| 109 |
+
sed -i 's|from jax.experimental.pjit import PartitionSpec|from jax.sharding import PartitionSpec|g' \
|
| 110 |
+
/usr/lib/python3.11/dist-packages/jestimator/amos_helper.py || true
|
| 111 |
+
|
| 112 |
+
# Install magenta-realtime without deps
|
| 113 |
+
RUN git clone https://github.com/magenta/magenta-realtime.git /magenta-realtime-src && \
|
| 114 |
+
cd /magenta-realtime-src && \
|
| 115 |
+
uv pip install --system --no-deps -e .
|
| 116 |
+
|
| 117 |
+
# API and audio processing dependencies
|
| 118 |
+
RUN uv pip install --system \
|
| 119 |
+
fastapi uvicorn[standard] python-multipart \
|
| 120 |
+
pyloudnorm gradio soxr huggingface_hub
|
| 121 |
+
|
| 122 |
+
# Ensure compatible protobuf version
|
| 123 |
+
RUN uv pip install --system --force-reinstall "protobuf>=5.27.0"
|
| 124 |
+
|
| 125 |
+
# Create HuggingFace Space user
|
|
|
|
|
|
|
|
|
|
| 126 |
RUN useradd -m -u 1000 appuser
|
| 127 |
WORKDIR /home/appuser/app
|
| 128 |
|
| 129 |
+
# Set cache directory
|
| 130 |
+
ENV MAGENTA_RT_CACHE_DIR=/home/appuser/.cache/magenta_rt
|
| 131 |
+
RUN mkdir -p $MAGENTA_RT_CACHE_DIR && chown -R appuser:appuser /home/appuser/.cache
|
| 132 |
+
|
| 133 |
+
# Copy application files with proper ownership
|
| 134 |
+
COPY --chown=appuser:appuser app.py /home/appuser/app/
|
| 135 |
+
COPY --chown=appuser:appuser utils.py /home/appuser/app/
|
| 136 |
+
COPY --chown=appuser:appuser jam_worker.py /home/appuser/app/
|
| 137 |
+
COPY --chown=appuser:appuser one_shot_generation.py /home/appuser/app/
|
| 138 |
+
COPY --chown=appuser:appuser model_management.py /home/appuser/app/
|
| 139 |
+
COPY --chown=appuser:appuser documentation.html /home/appuser/app/
|
| 140 |
+
COPY --chown=appuser:appuser lil_demo_540p.mp4 /home/appuser/app/
|
| 141 |
+
COPY --chown=appuser:appuser magentaRT_rt_tester.html /home/appuser/app/
|
| 142 |
+
COPY --chown=appuser:appuser magenta_prompts.js /home/appuser/app/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
COPY --chown=appuser:appuser docs/ /home/appuser/app/docs/
|
| 144 |
|
| 145 |
USER appuser
|