-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix cmake for building with cuda in msvc #1437
Conversation
CMakeLists.txt
Outdated
@@ -163,7 +163,11 @@ include(cmake/modules/contrib/NNPack.cmake) | |||
|
|||
add_library(tvm SHARED ${COMPILER_SRCS} ${RUNTIME_SRCS}) | |||
add_library(tvm_topi SHARED ${TOPI_SRCS}) | |||
add_library(tvm_runtime SHARED ${RUNTIME_SRCS}) | |||
if (USE_CUDA AND MSVC) | |||
add_library(tvm_runtime SHARED ${HALIDEIR_SRCS} ${RUNTIME_SRCS}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
runtime should never link HalideIR_SRCs, if there is anything wrong in link error, please report what is the specific error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tqchen thank you for the comment.
I got following linker errors when I built tvm with use_cuda on Visual Studio 2017 without adding HALIDEIR_SRCS
.
cmake command
cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Release -DCMAKE_CONFIGURATION_TYPES="Rel
ease" ..
error message
Severity | Code | Description | Project | File | Line | Suppression State |
---|---|---|---|---|---|---|
Error | LNK1120 | 20 unresolved externals | tvm_runtime | C:\work\tvm\build\Release\tvm_runtime.dll | 1 | |
Error | LNK2019 | unresolved external symbol "public: bool __cdecl HalideIR::float16_t::operator<(struct HalideIR::float16_t)const " (??Mfloat16_t@HalideIR@@QEBA_NU01@@z) referenced in function "public: bool __cdecl HalideIR::float16_t::operator<=(struct HalideIR::float16_t)const " (??Nfloat16_t@HalideIR@@QEBA_NU01@@z) | tvm_runtime | C:\work\tvm\build\cuda_device_api.obj | 1 | |
Error | LNK2019 | unresolved external symbol "public: bool __cdecl HalideIR::float16_t::operator==(struct HalideIR::float16_t)const " (??8float16_t@HalideIR@@QEBA_NU01@@z) referenced in function "public: bool __cdecl HalideIR::float16_t::operator!=(struct HalideIR::float16_t)const " (??9float16_t@HalideIR@@QEBA_NU01@@z) | tvm_runtime | C:\work\tvm\build\cuda_device_api.obj | 1 | |
Error | LNK2019 | unresolved external symbol "public: bool __cdecl HalideIR::float16_t::operator>(struct HalideIR::float16_t)const " (??Ofloat16_t@HalideIR@@QEBA_NU01@@z) referenced in function "public: bool __cdecl HalideIR::float16_t::operator>=(struct HalideIR::float16_t)const " (??Pfloat16_t@HalideIR@@QEBA_NU01@@z) | tvm_runtime | C:\work\tvm\build\cuda_device_api.obj | 1 | |
Error | LNK2019 | unresolved external symbol "public: bool __cdecl HalideIR::Type::same_handle_type(struct HalideIR::Type const &)const " (?same_handle_type@Type@HalideIR@@QEBA_NAEBU12@@z) referenced in function "public: static struct HalideIR::Expr __cdecl HalideIR::Internal::BinaryOpNode::make(struct HalideIR::Expr,struct HalideIR::Expr)" (?make@?$BinaryOpNode@UAdd@Internal@HalideIR@@@internal@HalideIR@@sa?AUExpr@3@U43@0@Z) | tvm_runtime | C:\work\tvm\build\cuda_device_api.obj | 1 | |
Error | LNK2019 | unresolved external symbol "public: static unsigned int __cdecl tvm::Node::TypeKey2Index(char const *)" (?TypeKey2Index@Node@tvm@@SAIPEBD@Z) referenced in function "public: virtual bool const __cdecl HalideIR::Internal::ExprNode::_DerivedFrom(unsigned int)const " (?_DerivedFrom@?$ExprNode@UAdd@Internal@HalideIR@@@internal@HalideIR@@ueba?B_NI@Z) | tvm_runtime | C:\work\tvm\build\cuda_device_api.obj | 1 | |
Error | LNK2019 | unresolved external symbol "public: virtual bool const __cdecl tvm::Node::_DerivedFrom(unsigned int)const " (?_DerivedFrom@Node@tvm@@ueba?B_NI@Z) referenced in function "public: virtual bool const __cdecl HalideIR::Internal::BaseExprNode::_DerivedFrom(unsigned int)const " (?_DerivedFrom@BaseExprNode@Internal@HalideIR@@ueba?B_NI@Z) | tvm_runtime | C:\work\tvm\build\cuda_device_api.obj | 1 | |
Error | LNK2001 | unresolved external symbol "public: virtual void __cdecl HalideIR::Internal::ExprNode::accept(class HalideIR::Internal::IRVisitor *,struct HalideIR::Expr const &)const " (?accept@?$ExprNode@UAdd@Internal@HalideIR@@@internal@HalideIR@@UEBAXPEAVIRVisitor@23@AEBUExpr@3@@z) | tvm_runtime | C:\work\tvm\build\cuda_device_api.obj | 1 | |
Error | LNK2001 | unresolved external symbol "public: virtual void __cdecl HalideIR::Internal::ExprNode::accept(class HalideIR::Internal::IRVisitor *,struct HalideIR::Expr const &)const " (?accept@?$ExprNode@UDiv@Internal@HalideIR@@@internal@HalideIR@@UEBAXPEAVIRVisitor@23@AEBUExpr@3@@z) | tvm_runtime | C:\work\tvm\build\cuda_device_api.obj | 1 | |
Error | LNK2001 | unresolved external symbol "public: virtual void __cdecl HalideIR::Internal::ExprNode::accept(class HalideIR::Internal::IRVisitor *,struct HalideIR::Expr const &)const " (?accept@?$ExprNode@UEQ@Internal@HalideIR@@@internal@HalideIR@@UEBAXPEAVIRVisitor@23@AEBUExpr@3@@z) | tvm_runtime | C:\work\tvm\build\cuda_device_api.obj | 1 | |
Error | LNK2001 | unresolved external symbol "public: virtual void __cdecl HalideIR::Internal::ExprNode::accept(class HalideIR::Internal::IRVisitor *,struct HalideIR::Expr const &)const " (?accept@?$ExprNode@UGE@Internal@HalideIR@@@internal@HalideIR@@UEBAXPEAVIRVisitor@23@AEBUExpr@3@@z) | tvm_runtime | C:\work\tvm\build\cuda_device_api.obj | 1 | |
Error | LNK2001 | unresolved external symbol "public: virtual void __cdecl HalideIR::Internal::ExprNode::accept(class HalideIR::Internal::IRVisitor *,struct HalideIR::Expr const &)const " (?accept@?$ExprNode@UGT@Internal@HalideIR@@@internal@HalideIR@@UEBAXPEAVIRVisitor@23@AEBUExpr@3@@z) | tvm_runtime | C:\work\tvm\build\cuda_device_api.obj | 1 | |
Error | LNK2001 | unresolved external symbol "public: virtual void __cdecl HalideIR::Internal::ExprNode::accept(class HalideIR::Internal::IRVisitor *,struct HalideIR::Expr const &)const " (?accept@?$ExprNode@ULE@Internal@HalideIR@@@internal@HalideIR@@UEBAXPEAVIRVisitor@23@AEBUExpr@3@@z) | tvm_runtime | C:\work\tvm\build\cuda_device_api.obj | 1 | |
Error | LNK2001 | unresolved external symbol "public: virtual void __cdecl HalideIR::Internal::ExprNode::accept(class HalideIR::Internal::IRVisitor *,struct HalideIR::Expr const &)const " (?accept@?$ExprNode@ULT@Internal@HalideIR@@@internal@HalideIR@@UEBAXPEAVIRVisitor@23@AEBUExpr@3@@z) | tvm_runtime | C:\work\tvm\build\cuda_device_api.obj | 1 | |
Error | LNK2001 | unresolved external symbol "public: virtual void __cdecl HalideIR::Internal::ExprNode::accept(class HalideIR::Internal::IRVisitor *,struct HalideIR::Expr const &)const " (?accept@?$ExprNode@UMax@Internal@HalideIR@@@internal@HalideIR@@UEBAXPEAVIRVisitor@23@AEBUExpr@3@@z) | tvm_runtime | C:\work\tvm\build\cuda_device_api.obj | 1 | |
Error | LNK2001 | unresolved external symbol "public: virtual void __cdecl HalideIR::Internal::ExprNode::accept(class HalideIR::Internal::IRVisitor *,struct HalideIR::Expr const &)const " (?accept@?$ExprNode@UMin@Internal@HalideIR@@@internal@HalideIR@@UEBAXPEAVIRVisitor@23@AEBUExpr@3@@z) | tvm_runtime | C:\work\tvm\build\cuda_device_api.obj | 1 | |
Error | LNK2001 | unresolved external symbol "public: virtual void __cdecl HalideIR::Internal::ExprNode::accept(class HalideIR::Internal::IRVisitor *,struct HalideIR::Expr const &)const " (?accept@?$ExprNode@UMod@Internal@HalideIR@@@internal@HalideIR@@UEBAXPEAVIRVisitor@23@AEBUExpr@3@@z) | tvm_runtime | C:\work\tvm\build\cuda_device_api.obj | 1 | |
Error | LNK2001 | unresolved external symbol "public: virtual void __cdecl HalideIR::Internal::ExprNode::accept(class HalideIR::Internal::IRVisitor *,struct HalideIR::Expr const &)const " (?accept@?$ExprNode@UMul@Internal@HalideIR@@@internal@HalideIR@@UEBAXPEAVIRVisitor@23@AEBUExpr@3@@z) | tvm_runtime | C:\work\tvm\build\cuda_device_api.obj | 1 | |
Error | LNK2001 | unresolved external symbol "public: virtual void __cdecl HalideIR::Internal::ExprNode::accept(class HalideIR::Internal::IRVisitor *,struct HalideIR::Expr const &)const " (?accept@?$ExprNode@UNE@Internal@HalideIR@@@internal@HalideIR@@UEBAXPEAVIRVisitor@23@AEBUExpr@3@@z) | tvm_runtime | C:\work\tvm\build\cuda_device_api.obj | 1 | |
Error | LNK2001 | unresolved external symbol "public: virtual void __cdecl HalideIR::Internal::ExprNode::accept(class HalideIR::Internal::IRVisitor *,struct HalideIR::Expr const &)const " (?accept@?$ExprNode@USub@Internal@HalideIR@@@internal@HalideIR@@UEBAXPEAVIRVisitor@23@AEBUExpr@3@@z) | tvm_runtime | C:\work\tvm\build\cuda_device_api.obj | 1 | |
Error | LNK2019 | unresolved external symbol "public: __cdecl HalideIR::VarExpr::VarExpr(class std::basic_string<char,struct std::char_traits,class std::allocator > const &,struct HalideIR::Type)" (??0VarExpr@HalideIR@@qeaa@AEBV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@utype@1@@z) referenced in function "public: __cdecl tvm::Var::Var(class std::basic_string<char,struct std::char_traits,class std::allocator > const &,struct HalideIR::Type)" (??0Var@tvm@@qeaa@AEBV?$basic_string@DU?$char_traits@D@std@@v?$allocator@D@2@@std@@utype@HalideIR@@@z) | tvm_runtime | C:\work\tvm\build\cuda_device_api.obj | 1 |
Hmm, this must due to some update in tvm runtime mistakenly included halide ir headers. We need to remove these include. The basic rule is that runtime source can only include files in include/runtime |
tvm/ir.h is included in cuda_device_api.cc, here. This looks fishy. tvm/container.h is also included. This header is part of HalideIR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Thanks for the catch!
This PR fixes cmake for building with cuda on windows.
@tqchen Please review