您好,我正在从源代码构建 Libtorch。我正在使用柯南,这样我就可以在我的项目和 Libtorch 中拥有相同版本的依赖项。 Build 工作得很好,但在我的项目中包含 Libtorch 之后,我立即得到异常,甚至在程序进入 main() 函数之前。
我创建了最小的示例,以便于复制。如果有人能告诉我问题出在哪里,我会很高兴。我在堆栈上发现了非常相同的问题:libtorch throws c10::error after build on Windows 10 (VS2019) 但未解决。
这里是转载来源: https://github.com/TheMejky/reproduceLibtorchBug.git
步骤:
打开powershell并安装Conan包管理器:
pip install conan
将这些设置放到 C:/Users/
[settings]
arch=x86_64
arch_build=x86_64
build_type=Debug
compiler=Visual Studio
compiler.runtime=MD
compiler.toolset=v143
compiler.version=17
os=Windows
os_build=Windows
[options]
[build_requires]
[env]
CONAN_DISABLE_STRICT_MODE=1
git clone https://github.com/TheMejky/reproduceLibtorchBug.git
cd reproduceLibtorchBug
conan create . -b -s build_type=Debug
这可能需要一段时间 - 在 AMD Ryzen 7 5800x 上大约需要一个小时
然后导航到最小项目文件夹并运行命令:
cd minimal_project
conan install . --install-folder=install_folder -s build_type=Debug
conan build . -sf=source_folder -bf=build_folder -if=install_folder
现在你去 build_folder 并打开 MinimalExampleProject.sln 并启动它,然后当程序启动时你会立即得到异常
这里是调用栈:
我尝试过不同的版本——1.13.0、1.13.1 和当前的主版本。我还尝试了 Libtorch CMake 的选项,但没有任何东西可以成功运行我的测试项目。