Logo of Trellis2
Trellis 2
工作台AI 助手价格方案
博客
  1. 首页
  2. 博客
  3. 如何安装 TRELLIS 2:全平台完整安装指南(2026)
如何安装 TRELLIS 2:全平台完整安装指南(2026)
2026/04/17
3 分钟阅读

如何安装 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 前,请确认你的系统满足以下要求:

最低要求

组件最低配置推荐配置
GPUNVIDIA 8GB 显存NVIDIA 16GB+ 显存
内存16 GB32 GB
存储10 GB 可用空间20 GB 可用空间(推荐 SSD)
Python3.103.11
CUDA11.812.1+
操作系统Linux(Ubuntu 20.04+)Linux(Ubuntu 22.04+)

GPU 兼容性

GPU 系列示例 GPU最大分辨率性能
RTX 30/40 系列RTX 3060, 4070, 4080, 40901536³优秀
RTX 20 系列RTX 2060, 2070, 20801024³良好
GTX 16/10 系列GTX 1660, 1080, 1080 Ti512³可接受
服务器 GPUA100, V100, H1001536³优秀

注意: 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:一键安装器(推荐新手使用)

社区提供了一键安装器,自动处理大部分设置:

  1. 从 TRELLIS Windows 安装器下载安装器
  2. 将压缩包解压到路径不含空格的文件夹(例如 C:\TRELLIS2)
  3. 以管理员身份运行 install.bat
  4. 等待安装完成(10-15 分钟)
  5. 运行 run.bat 启动 Web 界面

选项 B:手动安装

第 1 步:安装前置依赖

  1. 安装 Python 3.11(勾选"Add to PATH")
  2. 安装 Git for Windows
  3. 安装 CUDA Toolkit 12.1
  4. 安装 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 Export3D 模型文件导出为各种格式

方式四: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

解决方案:

  1. 降低分辨率:--resolution 256 或 --resolution 512
  2. 减少采样步数:--sampling_steps 4
  3. 关闭其他占用 GPU 的应用
  4. 使用在线平台进行高分辨率生成

Python 版本问题

症状: ModuleNotFoundError 或语法错误

解决方案: 确保使用 Python 3.10 或 3.11:

python --version  # 应为 3.10.x 或 3.11.x

CUDA 版本不匹配

症状: 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 上生成速度慢

症状: 生成时间远超预期

解决方案:

  1. 确认 CUDA 正确安装(nvidia-smi 应正常工作)
  2. 检查 PyTorch 是否使用 GPU:python -c "import torch; print(torch.cuda.is_available())"
  3. 关闭 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

本地安装的替代方案

如果你的硬件不满足要求或不想本地安装:

在线使用 TRELLIS 2 — 无需 GPU

特性本地安装在线平台
安装时间15-60 分钟0 分钟
需要 GPU是(NVIDIA)否
最大分辨率取决于 GPU高达 1536³
批量处理支持支持
成本硬件 + 电费提供免费额度
更新手动自动

下一步

安装完成后,学习如何有效使用 TRELLIS 2:

  • 如何使用 TRELLIS 2:完整使用指南和参数调优
  • 如何测试 TRELLIS 2:通过基准测试评估输出质量
  • 什么是 TRELLIS 3D?:了解模型背后的技术

相关文章:

  • 如何使用 TRELLIS 2:完整使用指南
  • 什么是 TRELLIS 3D?:了解 AI 模型
  • 如何将图片转为 3D 模型:涵盖多种方法的更广泛指南
全部文章

作者

avatar for Trellis2 团队
Trellis2 团队

专注于AI驱动的3D模型生成、格式转换和浏览器端3D渲染的3D技术团队。我们亲测并评测每一款3D工具。

分类

    更多文章

    • MakerWorld 下载 STL:3MF 转换与打印完全指南(2026)MakerWorld 下载的是 3MF 而不是 STL。本文讲解如何下载 MakerWorld 模型、在浏览器中免费把 3MF 转成 STL,并用任意切片器和打印机打印。2026/09/11
    • TRELLIS.2-4B 完全指南:显存要求、ComfyUI 与免费在线生成TRELLIS.2-4B 深度解析:微软 4B 参数图生 3D 模型。对比规格与 PBR 材质质量,查看显存需求,配置 ComfyUI 工作流,或直接使用免费在线 3D 生成。2026/09/10
    • 如何使用 Blender 进行 3D 建模:完整新手指南(2026)从零开始学习如何使用 Blender 进行 3D 建模。涵盖界面导航、核心工具(G/R/S、挤出、修改器)、硬表面与雕刻工作流,以及结构化学习路径。2026/07/12
    Logo of Trellis2
    Trellis 2

    Transform images into stunning 3D models with AI-powered technology

    Product

    • Features
    • Pricing
    • Blog
    • FAQ

    3D Tools & AI Models

    • AI 3D Model Generator
    • Microsoft TRELLIS 2
    • Hunyuan 3D
    • Tripo 3D
    • 3D Reconstruction
    • Image to STL Converter
    • 3D Viewer

    Company

    • About
    • Contact

    Legal

    • Privacy Policy
    • Terms of Service

    This website is an independent third-party platform. We are not directly affiliated with, endorsed by, or sponsored by Microsoft, Tencent, Tripo AI, or any other official service providers mentioned on this site. All trademarks, product names, and brands are the property of their respective owners.

    © 2026 Trellis 2. All rights reserved.