|  |  | 
					
						
						|  | FROM nvidia/cuda:12.6.2-cudnn-runtime-ubuntu22.04 | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | RUN apt-get update && apt-get install -y --no-install-recommends \ | 
					
						
						|  | cuda-libraries-12-4 && rm -rf /var/lib/apt/lists/* | 
					
						
						|  | 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} | 
					
						
						|  | RUN ln -sf /usr/local/cuda/targets/x86_64-linux/lib /usr/local/cuda/lib64 || true | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | RUN set -eux; \ | 
					
						
						|  | apt-get update && apt-get install -y --no-install-recommends gnupg ca-certificates curl; \ | 
					
						
						|  | install -d -m 0755 /usr/share/keyrings; \ | 
					
						
						|  |  | 
					
						
						|  | curl -fsSL https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/3bf863cc.pub \ | 
					
						
						|  | | gpg --batch --yes --dearmor -o /usr/share/keyrings/cuda-archive-keyring.gpg; \ | 
					
						
						|  | apt-get update; \ | 
					
						
						|  |  | 
					
						
						|  | apt-mark unhold libcudnn9-cuda-12 || true; \ | 
					
						
						|  |  | 
					
						
						|  | apt-get install -y --no-install-recommends \ | 
					
						
						|  | 'libcudnn9-cuda-12=9.8.*' \ | 
					
						
						|  | 'libcudnn9-dev-cuda-12=9.8.*' \ | 
					
						
						|  | --allow-downgrades --allow-change-held-packages; \ | 
					
						
						|  | apt-mark hold libcudnn9-cuda-12 || true; \ | 
					
						
						|  | ldconfig; \ | 
					
						
						|  | rm -rf /var/lib/apt/lists/* | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | 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 | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | ENV TF_GPU_ALLOCATOR=cuda_malloc_async | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | ENV TF_ENABLE_CUBLAS_TF32=1 NVIDIA_TF32_OVERRIDE=1 | 
					
						
						|  |  | 
					
						
						|  | ENV DEBIAN_FRONTEND=noninteractive \ | 
					
						
						|  | PYTHONUNBUFFERED=1 \ | 
					
						
						|  | PIP_NO_CACHE_DIR=1 \ | 
					
						
						|  | TF_FORCE_GPU_ALLOW_GROWTH=true \ | 
					
						
						|  | XLA_PYTHON_CLIENT_PREALLOCATE=false | 
					
						
						|  |  | 
					
						
						|  | ENV JAX_PLATFORMS="" | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | RUN apt-get update && apt-get install -y --no-install-recommends \ | 
					
						
						|  | software-properties-common curl ca-certificates git \ | 
					
						
						|  | libsndfile1 ffmpeg \ | 
					
						
						|  | build-essential pkg-config \ | 
					
						
						|  | && add-apt-repository ppa:deadsnakes/ppa -y \ | 
					
						
						|  | && apt-get update && apt-get install -y --no-install-recommends \ | 
					
						
						|  | python3.11 python3.11-venv python3.11-distutils python3-pip \ | 
					
						
						|  | && rm -rf /var/lib/apt/lists/* | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | RUN ln -sf /usr/bin/python3.11 /usr/bin/python && python -m pip install --upgrade pip | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | RUN python -m pip install "jax[cuda12]==0.7.1" "jaxlib==0.7.1" | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | RUN python -m pip install "seqio==0.0.11" | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | RUN python -m pip install --no-deps 'git+https://github.com/magenta/magenta-realtime#egg=magenta_rt[gpu]' | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | RUN python -m pip install \ | 
					
						
						|  | "tf_nightly==2.20.0.dev20250619" \ | 
					
						
						|  | "tensorflow-text-nightly==2.20.0.dev20250316" \ | 
					
						
						|  | "tf-hub-nightly" | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | RUN python -m pip install tf2jax "tf_nightly==2.20.0.dev20250619" | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | RUN python -m pip install \ | 
					
						
						|  | gin-config librosa resampy soundfile \ | 
					
						
						|  | google-auth google-auth-oauthlib google-auth-httplib2 \ | 
					
						
						|  | google-api-core googleapis-common-protos google-resumable-media \ | 
					
						
						|  | google-cloud-storage requests tqdm typing-extensions numpy==2.1.3 \ | 
					
						
						|  | fastapi uvicorn[standard] python-multipart pyloudnorm | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | RUN python -m pip install \ | 
					
						
						|  | "t5x @ git+https://github.com/google-research/t5x.git@92c5b46" \ | 
					
						
						|  | "flaxformer @ git+https://github.com/google/flaxformer@399ea3a" | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | RUN python - <<'PY' | 
					
						
						|  | import sys, sysconfig, glob, os, shutil | 
					
						
						|  |  | 
					
						
						|  | cands = [sysconfig.get_paths().get('purelib'), sysconfig.get_paths().get('platlib')] | 
					
						
						|  | cands += [p for p in sys.path if p and p.endswith(('site-packages','dist-packages'))] | 
					
						
						|  | site = next(p for p in cands if p and os.path.isdir(p)) | 
					
						
						|  |  | 
					
						
						|  | patterns = [ | 
					
						
						|  | "tensorflow", "tensorflow-*.dist-info", "tensorflow-*.egg-info", | 
					
						
						|  | "tf-nightly-*.dist-info", "tf_nightly-*.dist-info", | 
					
						
						|  | "tensorflow_text", "tensorflow_text-*.dist-info", | 
					
						
						|  | "tf-hub-nightly-*.dist-info", "tf_hub_nightly-*.dist-info", | 
					
						
						|  | "tf_keras-nightly-*.dist-info", "tf_keras_nightly-*.dist-info", | 
					
						
						|  | "tensorboard*", "tb-nightly-*.dist-info", | 
					
						
						|  | "keras*", | 
					
						
						|  | "tensorflow_hub*", "tensorflow_io*", | 
					
						
						|  | ] | 
					
						
						|  | for pat in patterns: | 
					
						
						|  | for path in glob.glob(os.path.join(site, pat)): | 
					
						
						|  | if os.path.isdir(path): shutil.rmtree(path, ignore_errors=True) | 
					
						
						|  | else: | 
					
						
						|  | try: os.remove(path) | 
					
						
						|  | except FileNotFoundError: pass | 
					
						
						|  |  | 
					
						
						|  | print("TF/Hub/Text cleared in:", site) | 
					
						
						|  | PY | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | RUN python -m pip install --no-cache-dir --force-reinstall \ | 
					
						
						|  | "tf-nightly==2.20.0.dev20250619" \ | 
					
						
						|  | "tensorflow-text-nightly==2.20.0.dev20250316" \ | 
					
						
						|  | "tf-hub-nightly" | 
					
						
						|  |  | 
					
						
						|  | RUN python -m pip install huggingface_hub | 
					
						
						|  |  | 
					
						
						|  | RUN python -m pip install --no-cache-dir --force-reinstall "protobuf==4.25.3" | 
					
						
						|  |  | 
					
						
						|  | RUN python -m pip install gradio | 
					
						
						|  |  | 
					
						
						|  | RUN python -m pip install soxr | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | RUN useradd -m -u 1000 appuser | 
					
						
						|  | WORKDIR /home/appuser/app | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | COPY --chown=appuser:appuser app.py /home/appuser/app/app.py | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | COPY --chown=appuser:appuser utils.py /home/appuser/app/utils.py | 
					
						
						|  | COPY --chown=appuser:appuser jam_worker.py /home/appuser/app/jam_worker.py | 
					
						
						|  |  | 
					
						
						|  | COPY --chown=appuser:appuser one_shot_generation.py /home/appuser/app/one_shot_generation.py | 
					
						
						|  |  | 
					
						
						|  | COPY --chown=appuser:appuser model_management.py /home/appuser/app/model_management.py | 
					
						
						|  |  | 
					
						
						|  | COPY --chown=appuser:appuser documentation.html /home/appuser/app/documentation.html | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | COPY --chown=appuser:appuser docs/ /home/appuser/app/docs/ | 
					
						
						|  |  | 
					
						
						|  | USER appuser | 
					
						
						|  |  | 
					
						
						|  | EXPOSE 7860 | 
					
						
						|  | CMD ["bash", "-lc", "python -m uvicorn app:app --host 0.0.0.0 --port ${PORT:-7860}"] |