【bug】diff-gaussian-rasterization Windows下编译 bug 解决

问题1 vcvarsall.bat" x86_amd64 && set

具体问题

\x00 \x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00*\x00\r\x00\n\x00'

error: Error executing cmd /u /c "F:\Program Files (x86)\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64 && set

原因

这个是跨平台编译(32位→64位),大概率会失败,因为你已经在 64 位开发者 PowerShell 里了。

PyTorch 的 cpp_extension 依然会默认调用 x86_amd64,所以必须强制改成 x64 才行。

解决方式

设置环境变量

bash 复制代码
$env:PLATFORM="x64"
$env:DISTUTILS_USE_SDK="1"

问题2 "crtdefs.h": No such file or directory

具体问题

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\include\crt/host_config.h(231): fatal error C1083: 无法打开包括文件: "crtdefs.h": No such file or directory

error: command 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\bin\nvcc' failed with exit code 2

原因

1、Windows SDK 或 MSVC 头文件没装全 或者路径不对

2、CUDA 用的 nvcc 指向了错误的编译器

解决方法

cuda我是有安装的,系统路径也是有的。

vs 2022也有安装,路径也有,但还是要增加以下环境变量,增加后可以解决

bash 复制代码
$env:INCLUDE="$env:INCLUDE;F:\Program Files (x86)\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include"

问题3 crtdefs.h(10): fatal error C1083: 无法打开包括文件: "corecrt.h": No such file or directory

具体问题

F:/Program Files (x86)/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.36.32532/include\crtdefs.h(10): fatal error C1083: 无法打开包括文件: "corecrt.h": No such file or directory

error: command 'C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\bin\nvcc' failed with exit code 2

原因

你现在这个错误说明我们虽然把 crtdefs.h 找到了,但它自己还依赖 corecrt.h,而这个文件是在 Windows SDK 里,不在 MSVC 目录下。

解决

一开始忽略了Windows SDK这个东西,竟然是有用的,增加以下环境变量

$winSDK = "F:\Windows Kits\10\Include\10.0.22000.0"

bash 复制代码
$env:INCLUDE="$env:INCLUDE;$winSDK\ucrt;$winSDK\shared;$winSDK\um"

原因

LINK : fatal error LNK1104: 无法打开文件"msvcprt.lib" 表示链接器找不到 MSVC的标准C++运行库静态库文件,这是链接阶段必需的库。

解决

bash 复制代码
$msvcLib = "F:\Program Files (x86)\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\lib\x64"
$env:LIB="$env:LIB;$msvcLib"

原因

LINK : fatal error LNK1104: 无法打开文件"uuid.lib" 表示链接器找不到 Windows SDK 的 uuid.lib,这是一个系统库,通常在 Windows SDK 的 Lib 目录下。

解决

bash 复制代码
$winSdkLib = "F:\Windows Kits\10\Lib\10.0.22000.0"
$env:LIB="$env:LIB;$winSdkLib\um\x64;$winSdkLib\ucrt\x64"

具体问题

正在创建库 build\temp.win-amd64-cpython-38\Release\cuda_rasterizer_C.cp38-win_amd64.lib 和对象 build\temp.win-amd64-cpython-38\Release\cuda_rasterizer_C.cp38-win_amd64.exp

正在生成代码

已完成代码的生成

LINK : fatal error LNK1158: 无法运行"rc.exe"

error: command 'F:\Program Files (x86)\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\bin\Hostx64\x64\link.exe' failed with exit code 1158

原因

LINK : fatal error LNK1158: 无法运行"rc.exe" 错误表示链接器找不到 资源编译器 rc.exe,它是生成 Windows 资源文件(.res)的工具,位于 Windows SDK 目录里。

解决

bash 复制代码
$env:PATH="$env:PATH;F:\Windows Kits\10\bin\10.0.22000.0\x64"

成功了

相关推荐
木心术18 小时前
Windows系统下MySQL与AI工具集成方案:数据存储与调用实践
人工智能·windows·mysql
beyond阿亮9 小时前
Hermes Agent快速接入 QQ 完整教程|QQ聊天使用AI智能体
人工智能·windows·ai·openclaw·hermes agent
DONSEE广东东信智能读卡器10 小时前
用PowerShell实现Windows 本地 WSS/HTTPS 自签名证书配置方法
windows·网络协议·https·powershell·身份证阅读器
DogDaoDao13 小时前
Windows 下 Git 报错:`touch` 无法识别 —— 原因分析与 7 种解决方案(从入门到精通)
windows·git·程序员·npm·powershell·cmd·touch
Ai.den13 小时前
Windows 安装 MinerU 3.x 实现本地批量解析 PDF
人工智能·windows·ai
xfddlm14 小时前
在Windows上配置Claude Code
windows
AI行业学习14 小时前
Notepad++ 下载+安装+插件集合 完整教程(Windows,安全无捆绑)
windows·notepad++
__zRainy__15 小时前
uni-app 全局容器实战系列(二):Vite 虚拟模块
windows·uni-app
Omics Pro15 小时前
前沿学科:量子生物学!
大数据·数据库·人工智能·windows·redis·量子计算
IceSugarJJ16 小时前
Windows下VSCode+ WSL项目启动流程
linux·windows·vscode·ubuntu·wsl