Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
fix(longcat): build for an 80 GB GPU and install ffmpeg for audio sizing
nirholasd19fe560a85d
diff --git a/workers/longcat/Dockerfile b/workers/longcat/Dockerfileindex 6158edb2f..e4e7df383 100644--- a/workers/longcat/Dockerfile+++ b/workers/longcat/Dockerfile@@ -1,7 +1,11 @@# ── Stage: base ────────────────────────────────────────────────────────────────-# CUDA 12.4 matches LongCat's torch==2.6.0+cu124 requirement.-# L4 GPU on Cloud Run (24 GB VRAM) runs Avatar-1.5 with INT8 quantization-# (~14 GB footprint at inference time).+# CUDA 12.4 matches LongCat's torch==2.6.0+cu124 requirement. The *runtime*+# image is enough because every CUDA extension in this image arrives as a+# pre-built wheel; nothing compiles here, so nvcc is not needed.+#+# Target hardware is a single 80 GB GPU (A100-80GB or H100-80GB, compute+# capability sm_80/sm_90, both covered by the cu124 wheels). See README.md for+# why an L4 is not enough: the resident weight set is about 45 GB.FROM nvidia/cuda:12.4.1-cudnn-runtime-ubuntu22.04ENV PYTHONDONTWRITEBYTECODE=1 \@@ -11,6 +15,8 @@ ENV PYTHONDONTWRITEBYTECODE=1 \HF_HUB_DISABLE_PROGRESS_BARS=1# ── System dependencies ────────────────────────────────────────────────────────+# ffmpeg carries ffprobe, which the service uses to size the segment count from+# the real audio duration, and which upstream's save_video_ffmpeg shells out to.RUN apt-get update && apt-get install -y --no-install-recommends \python3.10 python3.10-dev python3-pip \git curl wget ffmpeg \@@ -28,43 +34,67 @@ RUN git clone --depth=1 https://github.com/meituan-longcat/LongCat-Video.git /loRUN pip install torch==2.6.0 torchvision torchaudio \--index-url https://download.pytorch.org/whl/cu124-# ── Install FlashAttention-2 pre-built wheel ───────────────────────────────────-# Build from source is ~30 min; use the pre-built cu124 + sm89 wheel for L4.-RUN pip install flash-attn==2.7.4.post1 --no-build-isolation+# ── Install FlashAttention-2 from a pre-built wheel ────────────────────────────+# The shipped avatar-1.5 config sets enable_flashattn2: true, so flash_attn is a+# hard runtime import, not an optimisation. Do NOT switch this back to+# "pip install flash-attn": that is an sdist, it needs nvcc (absent from the+# runtime base image), and a from-source build takes ~40 minutes and routinely+# OOMs the builder. The ABI tag is read from the installed torch rather than+# hardcoded, because picking the wrong one yields an undefined-symbol crash at+# import time, long after the build reports success.+ARG FLASH_ATTN_VERSION=2.7.4.post1+RUN ABI=$(python -c "import torch; print('TRUE' if torch._C._GLIBCXX_USE_CXX11_ABI else 'FALSE')") \+ && echo "torch cxx11 abi: ${ABI}" \+ && pip install "https://github.com/Dao-AILab/flash-attention/releases/download/v${FLASH_ATTN_VERSION}/flash_attn-${FLASH_ATTN_VERSION}+cu12torch2.6cxx11abi${ABI}-cp310-cp310-linux_x86_64.whl" \+ && python -c "import flash_attn; from flash_attn import flash_attn_func; print('flash_attn', flash_attn.__version__)"-# ── Install LongCat model requirements (minus torch, minus flash-attn) ─────────-RUN pip install \- numpy==1.26.4 \- transformers==4.41.0 \- loguru==0.7.2 \- diffusers==0.35.1 \- einops==0.8.0 \- ftfy==6.2.0 \- psutil==6.0.0 \- av==12.0.0 \- opencv-python-headless==4.9.0.80 \- imageio==2.37.0 \- imageio-ffmpeg==0.6.0 \- librosa==0.11.0 \- soundfile==0.13.1+# ── Install LongCat model + avatar requirements ────────────────────────────────+COPY requirements-model.txt constraints.txt /app/+RUN pip install -c /app/constraints.txt -r /app/requirements-model.txt# ── Install service requirements ───────────────────────────────────────────────COPY requirements.txt /app/requirements.txt-RUN pip install -r /app/requirements.txt+RUN pip install -c /app/constraints.txt -r /app/requirements.txt++# Fail the build, not the first job, if a transitive resolution replaced the+# CUDA torch build or moved numpy to 2.x.+RUN python - <<'PY'+import numpy, torch, transformers, diffusers+assert torch.__version__.startswith("2.6.0"), f"torch drifted to {torch.__version__}"+assert "cu124" in torch.__version__ or torch.version.cuda == "12.4", (+ f"expected a cu124 torch build, got {torch.__version__} / cuda {torch.version.cuda}"+)+assert numpy.__version__.startswith("1.26"), f"numpy drifted to {numpy.__version__}"+print("pins ok:", torch.__version__, numpy.__version__, transformers.__version__, diffusers.__version__)+PY# ── App code ───────────────────────────────────────────────────────────────────WORKDIR /app-COPY worker_security.py /app/worker_security.py-COPY main.py /app/main.py+COPY worker_security.py /app/worker_security.py+COPY model_weights.py /app/model_weights.py+COPY inference_plan.py /app/inference_plan.py+COPY main.py /app/main.py++# ── Build gates ────────────────────────────────────────────────────────────────+# Pure-logic tests, run at build time so a regression in the segment math, the+# output-file choice, the weights layout, or the auth path fails the image+# instead of shipping. Each is also runnable on a laptop:+# python3 workers/longcat/test_inference_plan.py+COPY test_inference_plan.py /app/test_inference_plan.py+COPY test_model_weights.py /app/test_model_weights.py+COPY test_app_smoke.py /app/test_app_smoke.py+RUN python /app/test_inference_plan.py \+ && python /app/test_model_weights.py \+ && python /app/test_app_smoke.py-# Model weights are NOT baked into the image (13.6 B params = ~27 GB bf16 /-# ~14 GB int8). They are downloaded at first startup into WEIGHTS_DIR, which-# should be a Cloud Run volume mount backed by a persistent GCS bucket so-# subsequent cold starts reuse the cached weights.+# Model weights are NOT baked into the image (about 45 GB across two HuggingFace+# repos). They are staged once into a GCS bucket with stage-weights.sh and+# mounted at WEIGHTS_DIR. The service reports an incomplete staging on /health+# and answers 503 from /generate rather than accepting jobs it cannot run.EXPOSE 8080-# Single worker — GPU is not re-entrant across processes.+# Single worker: the GPU is not re-entrant across processes.CMD ["uvicorn", "main:app", \"--host", "0.0.0.0", \"--port", "8080", \