This guide provides step-by-step instructions for setting up TRELLIS.2 Unity Studio with Docker.
Before starting, ensure you have:
- NVIDIA GPU with 16GB+ VRAM (24GB+ recommended)
- Docker with NVIDIA Container Toolkit installed
- 16GB+ system RAM (64GB+ for optimal performance)
- HuggingFace account with access to gated models
- Ubuntu 22.04 or compatible Linux distribution
- Go to https://huggingface.co and create an account
- Verify your email address
- Navigate to https://huggingface.co/settings/tokens
- Click "New token"
- Name:
trellis2-unity-studio - Type: Read (minimum required)
- Click "Generate token"
- Copy the token (starts with
hf_...)
Visit each model page and click "Request access":
-
DINOv3 (required for image feature extraction)
- https://huggingface.co/facebook/dinov3-vitl16-pretrain-lvd1689m
- Click "Agree and access repository"
-
FLUX.2-klein-4B (required for text-to-image)
- https://huggingface.co/black-forest-labs/FLUX.2-klein-4B
- Read and accept the license agreement
-
RMBG-2.0 (optional, for background removal)
- https://huggingface.co/briaai/RMBG-2.0
- Accept the license
Access approval may take a few minutes to several hours
# Clone with submodules (required for TRELLIS.2 core)
git clone --recursive https://github.com/Scriptwonder/trellis2-unity-studio.git
cd trellis2-unity-studio
# If you already cloned without --recursive:
git submodule update --init --recursiveVerify the submodule is loaded:
ls vendor/TRELLIS.2/trellis2/
# Should show: __init__.py, models/, modules/, pipelines/, etc.Edit .env and replace the placeholder:
# Using nano
nano .env
# Or vim
vim .env
# Or any text editor
code .envReplace:
HF_TOKEN=your_huggingface_token_here
With your actual token:
HF_TOKEN=hf_xxxxxxxxxxxxxxxxxxxxx
Security Note:
- Never commit
.envto git (already in.gitignore) - Don't share your token publicly
- The
.envfile is automatically loaded byrun_docker.sh
# Build the image (this will take 10-20 minutes)
docker build -f docker/Dockerfile -t trellis2-unity-studio .What happens during build:
- Installs CUDA 12.4 base image
- Installs PyTorch 2.6.0 with CUDA support
- Compiles Flash Attention, nvdiffrast, CuMesh, FlexGEMM
- Installs TRELLIS.2 and o-voxel packages
- Configures Python environment
Expected output:
[+] Building 600.0s (25/25) FINISHED
=> exporting to image
=> => writing image sha256:...
=> => naming to docker.io/library/trellis2-unity-studio
# Run in background
./run_docker.sh --detach
# View logs
docker logs -f trellis2-unity-studio
# Stop server
docker stop trellis2-unity-studiodocker run --gpus all --rm \
-p 8000:8000 \
-v $(pwd)/outputs:/app/outputs \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env-file .env \
-e MEMORY_MODE=auto \
--shm-size=8g \
--name trellis2-unity-studio \
-d \
trellis2-unity-studio# Auto-detect (recommended)
./run_docker.sh --memory auto
# Force swap mode (32GB+ RAM)
./run_docker.sh --memory swap
# Keep models loaded (64GB+ RAM, fastest)
./run_docker.sh --memory keepcurl http://localhost:8000/healthExpected response:
{"status":"healthy","service":"trellis2"}docker logs trellis2-unity-studioExpected output:
[SPARSE] Conv backend: flex_gemm; Attention backend: flash_attn
[INFO] Initializing pipeline...
[INFO] Memory mode: swap
[INFO] Pipeline ready.
INFO: Uvicorn running on http://0.0.0.0:8000
# Submit a simple test job
curl -X POST http://localhost:8000/submit/text \
-H "Content-Type: application/json" \
-d '{"prompt": "A red cube", "quality": "superfast", "seed": 42}'Expected response:
{"job_id":"abc123-...", "status":"queued"}Check status:
curl http://localhost:8000/status/abc123-...# From your Unity project root:
cp -r /path/to/trellis2-unity-studio/unity/* Assets/Trellis2/Install one of these packages via Unity Package Manager:
-
GLTFUtility (recommended):
https://github.com/Siccity/GLTFUtility.git -
UnityGLTF (official Khronos):
https://github.com/KhronosGroup/UnityGLTF.git?path=/UnityGLTF/Assets/UnityGLTF
In Unity Editor:
- Tools → TRELLIS.2 → Generation Window
- Set Server URL:
http://localhost:8000 - Test connection (should show green checkmark)
Cause: HuggingFace token not configured or access not granted
Solution:
- Check
.envfile has correct token format:HF_TOKEN=hf_... - Verify you requested access to all required models
- Restart container:
docker restart trellis2-unity-studio - Check logs:
docker logs trellis2-unity-studio
Cause: Model access not approved yet
Solution:
- Visit model pages and check approval status
- Wait for approval (can take hours)
- Verify token has "Read" permission at https://huggingface.co/settings/tokens
Cause: Insufficient system RAM
Solution:
- Use swap mode:
./run_docker.sh --memory swap - Use lower quality preset:
superfastorfast - Close other applications
- Check available RAM:
free -h
Cause: Missing dependencies or CUDA incompatibility
Solutions:
- Ensure NVIDIA drivers are up to date
- Verify CUDA 12.4 compatibility
- Clean build:
docker build --no-cache -f docker/Dockerfile . - Check Docker has GPU access:
docker run --gpus all nvidia/cuda:12.4.1-base-ubuntu22.04 nvidia-smi
Cause: First-time model downloads are large (~40GB total)
Solution:
- Be patient - first run downloads all models
- Use cached models:
-v ~/.cache/huggingface:/root/.cache/huggingface - Check download progress in logs
| Mode | RAM | Description | Best For |
|---|---|---|---|
auto |
Any | Auto-detects based on available RAM | Default |
swap |
32GB+ | Unload Flux before loading TRELLIS.2 | Limited RAM |
keep_loaded |
64GB+ | Keep both models in memory | Maximum speed |
| Preset | Time | Use Case |
|---|---|---|
superfast |
~15s | Rapid prototyping |
fast |
~60s | Iteration, mobile assets |
balanced |
~90s | Production, PC games |
high |
~180s | Hero assets, cinematics |
Server is running at http://localhost:8000
Unity integration is ready
Try generating your first asset:
- Open Unity: Tools → TRELLIS.2 → Generation Window
- Enter prompt: "A cute robot toy"
- Quality: Balanced
- Click Generate from Text
- Wait ~90 seconds
- Model auto-imports to
Assets/Trellis2Results/
Explore the API:
- View API docs:
http://localhost:8000/docs - See example scripts in
examples/
- Issues: https://github.com/Scriptwonder/trellis2-unity-studio/issues
- TRELLIS.2 Core: https://github.com/microsoft/TRELLIS.2
- HuggingFace Help: https://huggingface.co/docs