3DGRUT部署及高斯模型转换为USDZ格式
- 平台
NVIDIA RTX 5080;
CUDA 12.8;
Windows 11;
Visual Studio 2022.
2. 环境准备
下载Git仓库3dgrut,git clone --recursive https://github.com/nv-tlabs/3dgrut.git
安装uv,powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
安装CUDA;
安装以及编译3dgrut:
$env:CUDA_HOME = "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8"
.\install_env_uv.ps1
安装完毕之后,在venv目录下会有个虚拟环境,用以下命令启动即可:
.venv\Scripts\Activate.ps1
安装完毕之后的log长这样:
(base) PS D:\zhangwx03\3dgrut> .\install_env_uv.ps1 [1/9] Initializing git submodules... [2/9] Detecting CUDA toolkit... Using CUDA_HOME=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8 CUDA version: 12.8 [3/9] Detecting Visual Studio build tools... cl.exe: D:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\bin\HostX64\x64 (environment already configured) cmake: D:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin ninja: D:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja [4/9] Resolving CUDA configuration... - cuda: 12.8.1 [5/9] Checking virtual environment... - uv: uv 0.11.7 (9d177269e 2026-04-15 x86_64-pc-windows-msvc) Virtual environment already exists at .venv To recreate, remove it first: Remove-Item -Recurse -Force .venv Environment variables: CUDA_HOME: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.8 CUDA_VERSION: 12.8 CUDA_FULL_VERSION: 12.8.1 CUDA_MAJOR_TARGET: 12 CUDA_MINOR_TARGET: 8 UV_PROJECT_ENVIRONMENT: D:\zhangwx03\3dgrut\.venv UV_PYTHON: D:\zhangwx03\3dgrut\.venv\Scripts\python.exe TORCH_INDEX_URL: https://download.pytorch.org/whl/cu128 TORCH_VERSION: ==2.8.0 TORCH_CUDA_ARCH_LIST: 7.5;8.0;8.6;9.0;10.0;12.0+PTX Environment variables already persisted in .venv\Scripts\Activate.ps1 [6/9] Setting constraints and index... UV constraint file: D:\zhangwx03\3dgrut\.venv\constraints.txt PyTorch index: https://download.pytorch.org/whl/cu128 [7/9] Installing project and dependencies... Resolved 136 packages in 1m 26s Built threedgrut @ file:///D:/zhangwx03/3dgrut Prepared 1 package in 1.55s Uninstalled 1 package in 1ms ░░░░░░░░░░░░░░░░░░░░ [0/1] Installing wheels... warning: Failed to hardlink files; falling back to full copy. This may lead to degraded performance. If the cache and target directories are on different filesystems, hardlinking may not be supported. If this is intentional, set `export UV_LINK_MODE=copy` or use `--link-mode=copy` to suppress this warning. Installed 1 package in 6ms ~ threedgrut==0.0.2 (from file:///D:/zhangwx03/3dgrut) [8/9] Installing Kaolin from pre-built wheel... Kaolin find link: https://nvidia-kaolin.s3.us-east-2.amazonaws.com/torch-2.8.0_cu128.html Resolved 117 packages in 41.14s Built threedgrut @ file:///D:/zhangwx03/3dgrut Prepared 1 package in 991ms Uninstalled 1 package in 0.95ms ░░░░░░░░░░░░░░░░░░░░ [0/1] Installing wheels... warning: Failed to hardlink files; falling back to full copy. This may lead to degraded performance. If the cache and target directories are on different filesystems, hardlinking may not be supported. If this is intentional, set `export UV_LINK_MODE=copy` or use `--link-mode=copy` to suppress this warning. Installed 1 package in 6ms ~ threedgrut==0.0.2 (from file:///D:/zhangwx03/3dgrut) [9/9] Installing extra requirements... Updated https://github.com/rahul-goel/fused-ssim (1272e21a282342e89537159e4bad508b19b34157) Resolved 22 packages in 4m 15s Checked 22 packages in 0.77ms Installing slangc... Installing slangc from the official source environment: D:\zhangwx03\3dgrut\.venv Extracting... Slangc installed at D:\zhangwx03\3dgrut\.venv\Scripts\slangc.exe Verifying the installation... PyTorch: 2.8.0+cu128, CUDA: True Kaolin: 0.18.0 PPISP: 1.0.1 Fused-SSIM: ready ========================================== Installation complete! ========================================== To activate the environment, run: .venv\Scripts\activate (base) PS D:\zhangwx03\3dgrut>
3. 坑点
3.1 3dgrut默认从C盘下面寻找MSVC编译器,但实际情况各异。
需要手动修改install_env_uv.ps1的以下内容:
# If the MSVC environment is already fully configured (Developer Command Prompt, # vcvarsall.bat, or ilammy/msvc-dev-cmd in CI), respect it. We verify both cl.exe # on PATH and LIB containing x64 paths to catch partial setups that cause x86/x64 # linker mismatches. $existingCl = Get-Command cl.exe -ErrorAction SilentlyContinue $libIsX64 = $env:LIB -and ($env:LIB -match "\\x64|\\amd64") if ($existingCl -and $libIsX64) { $clDir = Split-Path $existingCl.Source Write-Host " cl.exe: $clDir (environment already configured)" } else { $vcvarsall = Find-InVsInstall @( "D:\Program Files\Microsoft Visual Studio\*\*\VC\Auxiliary\Build\vcvarsall.bat", # 修改此处(包括后面1行)的路径,指向正确的编译系统 "D:\Program Files (x86)\Microsoft Visual Studio\*\*\VC\Auxiliary\Build\vcvarsall.bat" ) if (-not $vcvarsall) { Write-Error-And-Exit @" ERROR: Visual Studio C++ compiler not found. Install Visual Studio Build Tools from: https://visualstudio.microsoft.com/visual-cpp-build-tools/ Include the 'Desktop development with C++' workload. "@ } Write-Host " Initializing MSVC x64 environment via vcvarsall.bat..." foreach ($line in (cmd /c "`"$vcvarsall`" x64 >nul 2>&1 && set" 2>&1)) { if ($line -match "^([^=]+)=(.*)$") { [System.Environment]::SetEnvironmentVariable($matches[1], $matches[2], "Process") } } $existingCl = Get-Command cl.exe -ErrorAction SilentlyContinue if (-not $existingCl) { Write-Error-And-Exit "vcvarsall.bat ran but cl.exe is still not on PATH." } $clDir = Split-Path $existingCl.Source Write-Host " cl.exe: $clDir" }
3.2 [7/9]步骤极容易出错,尤其是libigl的编译
[7/9]会从网络内下载巨量的C++源文件并进行本地编译,在中文系统的电脑上非常容易因为符号原因引发警告,部分警告会因为工程设置的原因,而被当作错误,从而触发编译出错。因为libigl 2.6.2在PyPI上没有Windows版本的预编译包,所以libigl全部依赖项均需要在线下载编译。而libigl库只用于3dgrut gui,不需要的话,可以通过修改以下部分,跳过libigl编译。
# ========================================== # Step 7: Install project and dependencies # ========================================== Write-Host "[7/9] Installing project and dependencies..." uv pip install -e ".[dev]" # 此处去掉gui if ($LASTEXITCODE -ne 0) { Write-Error-And-Exit "Failed to install project dependencies" } Write-Host ""
3.3 部分情况下,dependencies的下载速度极慢,对于此类情况,可以中断.\install_env_uv.ps1的执行,下载对应的wheel文件,通过uv pip install的方式安装了再重新执行.\install_env_uv.ps1,此时脚本检测到已安装对应库就不会再下载编译,并自动从未完成的安装步骤往下走。
3.4 在Step 9b步骤中,会有slangc的安装,电脑会主动下载slangc的zip压缩包,并通过Power Shell指令解压缩到APPData/Local/Temp/slang-extract下面。部分情况下,shell没法正确执行解压缩指令(可能权限的原因),此时,可手动解压到该目录,然后手动注释install_slangc.ps1的此处2行:
$downloadUrl = "https://github.com/shader-slang/slang/releases/download/v${SLANGC_VERSION}/slang-${SLANGC_VERSION}-windows-x86_64.zip" $zipPath = Join-Path $env:TEMP "slang-${SLANGC_VERSION}-windows-x86_64.zip" $extractPath = Join-Path $env:TEMP "slang-extract" if (-not (Test-Path $zipPath)) { Write-Host " Downloading slangc $SLANGC_VERSION..." Invoke-WebRequest -Uri $downloadUrl -OutFile $zipPath -UseBasicParsing } Write-Host " Extracting..." # if (Test-Path $extractPath) { Remove-Item $extractPath -Recurse -Force } # 注释此行与下面1行 # Expand-Archive -Path $zipPath -DestinationPath $extractPath -Force $scriptsDir = Join-Path $env:UV_PROJECT_ENVIRONMENT "Scripts" if (-not (Test-Path $scriptsDir)) { Write-Host " ERROR: $scriptsDir does not exist, the virtual environment may not have been created correctly." -ForegroundColor Red exit 1 }
安装完成按提示,激活环境即可使用该工程。

浙公网安备 33010602011771号