【发布时间】:2020-04-13 03:31:16
【问题描述】:
您好,最近我安装了 Libtorch,并且可以在我的新 Visual Studio 项目中使用它而没有问题。目前我正在尝试在现有的 CUDA 项目中使用 Libtorch。但是当我包含火炬头时我遇到了这些奇怪的错误,并且我在互联网上找不到任何关于我的问题的解决方案。有谁知道这些错误的原因可能是什么?
Severity Code Description Project File Line Suppression State
Error C2833 'operator {' is not a recognized operator or type DepthSensing e:\research\libtorch\include\c10\util\flat_hash_map.h 1433
Error C2059 syntax error: 'newline' DepthSensing e:\research\libtorch\include\c10\util\flat_hash_map.h 1433
Error C2238 unexpected token(s) preceding ';' DepthSensing e:\research\libtorch\include\c10\util\flat_hash_map.h 1433
Error C2143 syntax error: missing ';' before 'const' DepthSensing e:\research\libtorch\include\c10\util\flat_hash_map.h 1433
Error C2833 'operator {' is not a recognized operator or type DepthSensing e:\research\libtorch\include\c10\util\order_preserving_flat_hash_map.h 1552
Error C2059 syntax error: 'newline' DepthSensing e:\research\libtorch\include\c10\util\order_preserving_flat_hash_map.h 1552
Error C2238 unexpected token(s) preceding ';' DepthSensing e:\research\libtorch\include\c10\util\order_preserving_flat_hash_map.h 1552
Error C2143 syntax error: missing ';' before 'const' DepthSensing e:\research\libtorch\include\c10\util\order_preserving_flat_hash_map.h 1552
环境
- Windows 10
- CUDA 10.1
- Visual Studio 2017
- C++14
【问题讨论】:
-
您是否定义了任何可能影响 libtorch 头文件编译的宏?如果您将 libtorch 引头作为代码中的第一个标头包含会发生什么?
-
你是对的@john!另一个库中有一个宏与 Libtorch 库中的类型名同名,这就是为什么它在编译时会混淆。这种方法适合我的情况吗?我已经尝试过了,它现在可以工作,但我不确定这是否是正确的方法。 stackoverflow.com/questions/6884093/…
-
这里没有完美的解决方案,这两个表头基本不兼容。如果你正在做的事情对你有用,那就去做吧。只要记住在你的代码中添加一些 cmets 来解释你为什么做了你所做的事情。
标签: c++ visual-studio pytorch libtorch