如何安装 TRELLIS 2:全平台完整安装指南(2026)
逐步讲解如何在 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 系列 | 示例 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 分钟 |
方式一:Linux 安装
第 1 步:安装前置依赖
# 更新系统包
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第 2 步:克隆仓库
# 克隆 TRELLIS 2
git clone https://github.com/microsoft/TRELLIS.2.git
cd TRELLIS.2第 3 步:创建虚拟环境
# 创建并激活虚拟环境
python3.11 -m venv venv
source venv/bin/activate
# 升级 pip
pip install --upgrade pip第 4 步:安装依赖
# 安装支持 CUDA 的 PyTorch
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121
# 安装 TRELLIS 2 依赖
pip install -r requirements.txt第 5 步:下载模型权重
# 从 Hugging Face 下载预训练权重
python download_weights.py这会下载约 8 GB 的模型权重,保存在 weights/ 目录中。
第 6 步:验证安装
# 运行快速测试
python infer.py --text_prompt "a red cube" --output_path test_output.glb如果安装成功,你会在项目目录中找到 test_output.glb 文件。
方式二:Windows 安装
选项 A:一键安装器(推荐新手使用)
社区提供了一键安装器,自动处理大部分设置:
- 从 TRELLIS Windows 安装器下载安装器
- 将压缩包解压到路径不含空格的文件夹(例如
C:\TRELLIS2) - 以管理员身份运行
install.bat - 等待安装完成(10-15 分钟)
- 运行
run.bat启动 Web 界面
选项 B:手动安装
第 1 步:安装前置依赖
- 安装 Python 3.11(勾选"Add to PATH")
- 安装 Git for Windows
- 安装 CUDA Toolkit 12.1
- 安装 Visual Studio Build Tools(选择"Desktop development with C++")
第 2 步:克隆和设置
# 克隆仓库
git clone https://github.com/microsoft/TRELLIS.2.git
cd TRELLIS.2
# 创建虚拟环境
python -m venv venv
.\venv\Scripts\activate
# 升级 pip
pip install --upgrade pip第 3 步:安装依赖
# 安装支持 CUDA 的 PyTorch
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121
# 安装依赖
pip install -r requirements.txt第 4 步:下载权重并测试
# 下载模型权重
python download_weights.py
# 运行测试
python infer.py --text_prompt "a red cube" --output_path test_output.glb方式三:ComfyUI 集成
TRELLIS 2 可以集成到 ComfyUI 中,实现基于节点的 3D 生成工作流。
第 1 步:安装 ComfyUI
如果你还没有安装 ComfyUI:
git clone https://github.com/comfyanonymous/ComfyUI.git
cd ComfyUI
pip install -r requirements.txt第 2 步:安装 TRELLIS 2 自定义节点
cd ComfyUI/custom_nodes/
git clone https://github.com/comfyui-extensions/ComfyUI-TRELLIS.2.git
cd ComfyUI-TRELLIS.2
pip install -r requirements.txt第 3 步:下载模型权重
将 TRELLIS 2 权重放入 ComfyUI 模型目录:
# 创建目录(如果不存在)
mkdir -p ComfyUI/models/trellis/
# 下载权重
python ComfyUI/custom_nodes/ComfyUI-TRELLIS.2/download_weights.py \
--output_dir ComfyUI/models/trellis/第 4 步:启动 ComfyUI
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 安装
Docker 提供可复现的环境,跨平台运行。
第 1 步:安装 Docker
# Ubuntu
sudo apt install docker.io docker-compose -y
sudo usermod -aG docker $USER
# 启动 Docker
sudo systemctl start docker
sudo systemctl enable docker第 2 步:构建 Docker 镜像
git clone https://github.com/microsoft/TRELLIS.2.git
cd TRELLIS.2
# 构建镜像(包含 CUDA 支持)
docker build -t trellis2 .第 3 步:运行容器
# 使用 GPU 支持运行
docker run --gpus all -p 7860:7860 -v ./outputs:/app/outputs trellis2在浏览器中访问 http://localhost:7860 使用 Web 界面。
配置选项
安装完成后,可以通过配置文件或命令行参数配置 TRELLIS 2。
配置文件 (config.yaml)
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: false命令行参数
python infer.py \
--image_path input.png \
--output_path output.glb \
--resolution 1024 \
--sampling_steps 25 \
--guidance_scale 10.0 \
--seed 42常见问题排查
CUDA 内存不足
症状: RuntimeError: CUDA out of memory
解决方案:
- 降低分辨率:
--resolution 256或--resolution 512 - 减少采样步数:
--sampling_steps 4 - 关闭其他占用 GPU 的应用
- 使用在线平台进行高分辨率生成
Python 版本问题
症状: ModuleNotFoundError 或语法错误
解决方案: 确保使用 Python 3.10 或 3.11:
python --version # 应为 3.10.x 或 3.11.xCUDA 版本不匹配
症状: 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/Windows 上生成速度慢
症状: 生成时间远超预期
解决方案:
- 确认 CUDA 正确安装(
nvidia-smi应正常工作) - 检查 PyTorch 是否使用 GPU:
python -c "import torch; print(torch.cuda.is_available())" - 关闭 Windows GPU 调度:设置 → 系统 → 显示 → 图形 → 更改默认图形设置
性能基准
各 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 |
更新 TRELLIS 2
更新到最新版本:
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:
- 如何使用 TRELLIS 2:完整使用指南和参数调优
- 如何测试 TRELLIS 2:通过基准测试评估输出质量
- 什么是 TRELLIS 3D?:了解模型背后的技术
相关文章:
- 如何使用 TRELLIS 2:完整使用指南
- 什么是 TRELLIS 3D?:了解 AI 模型
- 如何将图片转为 3D 模型:涵盖多种方法的更广泛指南
作者
专注于AI驱动的3D模型生成、格式转换和浏览器端3D渲染的3D技术团队。我们亲测并评测每一款3D工具。
分类
更多文章
- MakerWorld 下载 STL:3MF 转换与打印完全指南(2026)MakerWorld 下载的是 3MF 而不是 STL。本文讲解如何下载 MakerWorld 模型、在浏览器中免费把 3MF 转成 STL,并用任意切片器和打印机打印。
- TRELLIS.2-4B 完全指南:显存要求、ComfyUI 与免费在线生成TRELLIS.2-4B 深度解析:微软 4B 参数图生 3D 模型。对比规格与 PBR 材质质量,查看显存需求,配置 ComfyUI 工作流,或直接使用免费在线 3D 生成。
- 如何使用 Blender 进行 3D 建模:完整新手指南(2026)从零开始学习如何使用 Blender 进行 3D 建模。涵盖界面导航、核心工具(G/R/S、挤出、修改器)、硬表面与雕刻工作流,以及结构化学习路径。
