🎉 上线特惠 — 所有积分包立减 20%!
立即购买
逐步讲解如何在 Windows、Linux 和 macOS 上安装 TRELLIS 2。涵盖 GPU 要求、Python 环境配置、ComfyUI 集成、Docker 安装以及常见安装问题排查。
最后更新:2026 年 4 月 14 日
微软研究院的 TRELLIS 2 是一个开源 AI 模型,用于从文本或图片生成高质量 3D 资产。本指南详细介绍每种安装方式——从快速本地安装到 Docker 和 ComfyUI 集成——帮助你在自己的硬件上开始生成 3D 模型。
如果你想跳过安装步骤,可以直接在线使用 TRELLIS 2,无需任何安装。
安装 TRELLIS 2 前,请确认你的系统满足以下要求:
加入我们的社区
订阅邮件列表,及时获取最新消息和更新
| 组件 | 最低配置 | 推荐配置 |
|---|---|---|
| GPU | NVIDIA 8GB 显存 | NVIDIA 16GB+ 显存 |
| 内存 | 16 GB | 32 GB |
| 存储 | 10 GB 可用空间 | 20 GB 可用空间(推荐 SSD) |
| Python | 3.10 | 3.11 |
| CUDA | 11.8 | 12.1+ |
| 操作系统 | Linux(Ubuntu 20.04+) | Linux(Ubuntu 22.04+) |
| GPU 系列 | 示例 GPU | 最大分辨率 | 性能 |
|---|---|---|---|
| RTX 30/40 系列 | RTX 3060, 4070, 4080, 4090 | 1536³ | 优秀 |
| RTX 20 系列 | RTX 2060, 2070, 2080 | 1024³ | 良好 |
| GTX 16/10 系列 | GTX 1660, 1080, 1080 Ti | 512³ | 可接受 |
| 服务器 GPU | A100, V100, H100 | 1536³ | 优秀 |
注意: AMD 和 Apple Silicon GPU 未获官方支持。AMD 用户可尝试 ROCm 构建,但兼容性有限。Mac 用户建议使用 TRELLIS 2 在线版。
选择适合你的安装方式:
| 方式 | 难度 | 适用场景 | 安装时间 |
|---|---|---|---|
| Linux(原生) | 中级 | 大多数 Linux 环境 | 15-30 分钟 |
| Windows(原生) | 中级 | Windows 用户 | 15-30 分钟 |
| ComfyUI 集成 | 中级 | ComfyUI 用户 | 20-40 分钟 |
| Docker | 高级 | 可复现环境 | 10-20 分钟 |
| 一键安装器 | 初级 | Windows 快速安装 | 5-10 分钟 |
# 更新系统包
sudo apt update && sudo apt upgrade -y
# 安装 Python 3.11 和 pip
sudo apt install python3.11 python3.11-venv python3-pip -y
# 安装 CUDA 工具包(如果尚未安装)
# CUDA 12.1:
wget https://developer.download.nvidia.com/compute/cuda/12.1.0/local_installers/cuda_12.1.0_530.32.01_linux.run
sudo sh cuda_12.1.0_530.32.01_linux.run
# 验证 CUDA 安装
nvcc --version
nvidia-smi# 克隆 TRELLIS 2
git clone https://github.com/microsoft/TRELLIS.2.git
cd TRELLIS.2# 创建并激活虚拟环境
python3.11 -m venv venv
source venv/bin/activate
# 升级 pip
pip install --upgrade pip# 安装支持 CUDA 的 PyTorch
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121
# 安装 TRELLIS 2 依赖
pip install -r requirements.txt# 从 Hugging Face 下载预训练权重
python download_weights.py这会下载约 8 GB 的模型权重,保存在 weights/ 目录中。
# 运行快速测试
python infer.py --text_prompt "a red cube" --output_path test_output.glb如果安装成功,你会在项目目录中找到 test_output.glb 文件。
社区提供了一键安装器,自动处理大部分设置:
C:\TRELLIS2)install.batrun.bat 启动 Web 界面# 克隆仓库
git clone https://github.com/microsoft/TRELLIS.2.git
cd TRELLIS.2
# 创建虚拟环境
python -m venv venv
.\venv\Scripts\activate
# 升级 pip
pip install --upgrade pip# 安装支持 CUDA 的 PyTorch
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121
# 安装依赖
pip install -r requirements.txt# 下载模型权重
python download_weights.py
# 运行测试
python infer.py --text_prompt "a red cube" --output_path test_output.glbTRELLIS 2 可以集成到 ComfyUI 中,实现基于节点的 3D 生成工作流。
如果你还没有安装 ComfyUI:
git clone https://github.com/comfyanonymous/ComfyUI.git
cd ComfyUI
pip install -r requirements.txtcd ComfyUI/custom_nodes/
git clone https://github.com/comfyui-extensions/ComfyUI-TRELLIS.2.git
cd ComfyUI-TRELLIS.2
pip install -r requirements.txt将 TRELLIS 2 权重放入 ComfyUI 模型目录:
# 创建目录(如果不存在)
mkdir -p ComfyUI/models/trellis/
# 下载权重
python ComfyUI/custom_nodes/ComfyUI-TRELLIS.2/download_weights.py \
--output_dir ComfyUI/models/trellis/cd ComfyUI
python main.py在浏览器中访问 http://localhost:8188,在节点浏览器中搜索 TRELLIS 节点。
| 节点 | 输入 | 输出 | 描述 |
|---|---|---|---|
| TRELLIS Image to 3D | 图片 | 3D 模型 (GLB) | 将单张图片转为 3D |
| TRELLIS Text to 3D | 文字提示词 | 3D 模型 (GLB) | 从描述生成 3D |
| TRELLIS Multi-View | 多张图片 | 3D 模型 (GLB) | 使用多个视角获得更好质量 |
| TRELLIS Export | 3D 模型 | 文件 | 导出为各种格式 |
Docker 提供可复现的环境,跨平台运行。
# Ubuntu
sudo apt install docker.io docker-compose -y
sudo usermod -aG docker $USER
# 启动 Docker
sudo systemctl start docker
sudo systemctl enable dockergit clone https://github.com/microsoft/TRELLIS.2.git
cd TRELLIS.2
# 构建镜像(包含 CUDA 支持)
docker build -t trellis2 .# 使用 GPU 支持运行
docker run --gpus all -p 7860:7860 -v ./outputs:/app/outputs trellis2在浏览器中访问 http://localhost:7860 使用 Web 界面。
安装完成后,可以通过配置文件或命令行参数配置 TRELLIS 2。
model:
name: "trellis2-4b"
weights_path: "./weights/"
generation:
default_resolution: 512
default_sampling_steps: 12
default_guidance_scale: 7.5
server:
host: "0.0.0.0"
port: 7860
max_batch_size: 4
output:
default_format: "glb"
save_intermediates: falsepython infer.py \
--image_path input.png \
--output_path output.glb \
--resolution 1024 \
--sampling_steps 25 \
--guidance_scale 10.0 \
--seed 42症状: RuntimeError: CUDA out of memory
解决方案:
--resolution 256 或 --resolution 512--sampling_steps 4症状: ModuleNotFoundError 或语法错误
解决方案: 确保使用 Python 3.10 或 3.11:
python --version # 应为 3.10.x 或 3.11.x症状: RuntimeError: CUDA version mismatch
解决方案: 重新安装与你的 CUDA 版本匹配的 PyTorch:
# CUDA 11.8
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118
# CUDA 12.1
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121症状: 下载超时或文件损坏
解决方案: 从 Hugging Face 手动下载权重:
# 使用 huggingface-cli
pip install huggingface-hub
huggingface-cli download microsoft/TRELLIS.2-4B --local-dir ./weights/症状: 生成时间远超预期
解决方案:
nvidia-smi 应正常工作)python -c "import torch; print(torch.cuda.is_available())"各 GPU 预期生成时间(512 分辨率,12 采样步数):
| GPU | 生成时间 | 显存占用 |
|---|---|---|
| RTX 4090 | ~2.5s | ~6 GB |
| RTX 4080 | ~3s | ~7 GB |
| RTX 3090 | ~4s | ~8 GB |
| RTX 3080 | ~5s | ~8 GB |
| RTX 4070 | ~4s | ~6 GB |
| RTX 3060 | ~8s | ~8 GB |
| GTX 1080 Ti | ~12s | ~8 GB |
| A100 | ~2s | ~6 GB |
更新到最新版本:
cd TRELLIS.2
# 拉取最新更改
git pull origin main
# 更新依赖
pip install -r requirements.txt
# 下载新权重(如果有)
python download_weights.py如果你的硬件不满足要求或不想本地安装:
| 特性 | 本地安装 | 在线平台 |
|---|---|---|
| 安装时间 | 15-60 分钟 | 0 分钟 |
| 需要 GPU | 是(NVIDIA) | 否 |
| 最大分辨率 | 取决于 GPU | 高达 1536³ |
| 批量处理 | 支持 | 支持 |
| 成本 | 硬件 + 电费 | 提供免费额度 |
| 更新 | 手动 | 自动 |
安装完成后,学习如何有效使用 TRELLIS 2:
相关文章:
专注于AI驱动的3D模型生成、格式转换和浏览器端3D渲染的3D技术团队。我们亲测并评测每一款3D工具。