提交 ec65e1f9 编写于 作者: M Megvii Engine Team

fix(build/windows): fix windows build:

* compat clang-cl 11 build at windows env
* fix cuda/cudnn/trt copy env build failed on windows

GitOrigin-RevId: 7fe2d2c0dcaabf56df1725994a41a15dd09692b6
上级 8a918717
......@@ -182,9 +182,8 @@ if(MSVC OR WIN32)
endif()
add_compile_definitions(NOMINMAX=1 _USE_MATH_DEFINES=1 WIN32=1)
message(STATUS "into windows build...")
message(VERBOSE "CMAKE_C_COMPILER_ID: ${CMAKE_C_COMPILER_ID}")
if (${CMAKE_C_COMPILER_ID} STREQUAL "Clang-cl")
message(STATUS "into windows build CMAKE_C_COMPILER_ID: ${CMAKE_C_COMPILER_ID}")
if (NOT ${CMAKE_C_COMPILER_ID} STREQUAL "Clang" AND NOT ${CMAKE_C_COMPILER_ID} STREQUAL "Clang-cl")
message(FATAL_ERROR "only support clang-cl for windows build, pls check detail: scripts/cmake-build/BUILD_README.md")
endif()
# add flags for enable sse instruction optimize for X86, enable avx header to compile avx code
......@@ -397,7 +396,7 @@ if(MGE_WITH_CUDA)
set(CMAKE_CUDA_FLAGS_MINSIZEREL "-Os")
if(MSVC OR WIN32)
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xfatbin -compress-all")
set(CCBIN_FLAG "${CCBIN_FLAG} /wd4819 /wd4334 /wd4267 /wd4002 /wd4244 /wd4068")
set(CCBIN_FLAG "${CCBIN_FLAG} /wd4819 /wd4334 /wd4267 /wd4002 /wd4244 /wd4068 /std:c++14")
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
set(CCBIN_FLAG "${CCBIN_FLAG} -D_ITERATOR_DEBUG_LEVEL=2 -MTd")
endif()
......
......@@ -16,6 +16,9 @@ if(MSVC OR WIN32)
set(FLATC_FLAGS "${FLATC_FLAGS} -Wno-error=missing-variable-declarations -Wno-error=nonportable-system-include-path")
set(FLATC_FLAGS "${FLATC_FLAGS} -Wno-error=exit-time-destructors -Wno-error=unused-macros -Wno-error=global-constructors")
set(FLATC_FLAGS "${FLATC_FLAGS} -Wno-error=switch-enum -Wno-error=missing-noreturn -Wno-error=float-equal")
if (${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL "11.0.0")
set(FLATC_FLAGS "${FLATC_FLAGS} -Wno-error=suggest-override -Wno-error=suggest-destructor-override")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLATC_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLATC_FLAGS}")
......
......@@ -18,7 +18,7 @@
### Windows host build
* commands:
```
1: installl Visual Studio (need support LLVM/clang-cl), eg 2019. Please install LLVM-10, VS LLVM linker have issue, please replace lld-link.exe, which can be download from https://releases.llvm.org/download.html#10.0.0
1: installl Visual Studio (need support LLVM/clang-cl), eg 2019. Please install LLVM-10/11, VS LLVM linker have issue, please replace lld-link.exe, which can be download from https://releases.llvm.org/download.html#10.0.0, what`s more, Visual Studio cl.exe version >=14.28.29910 do not compat with cuda 10.1, please do not use this issue version!
2: install extension of VS: Python/Cmake/LLVM/Ninja
3: now we support cuda10.1+cudnn7.6+TensorRT6.0 on Windows, as Windows can only use DLL in fact with cudnn/TensorRT, so please install the same version;
3a: install cuda10.1 to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1
......
......@@ -203,6 +203,8 @@ function prepare_env_for_windows_build() {
export CPATH=$CPATH:$NIVIDA_INSTALL_PRE/${TRT_V}/include:$NIVIDA_INSTALL_PRE/CUDA/${CUDA_V}/include:$NIVIDA_INSTALL_PRE/CUDA/${CUDA_V}/include/nvtx3:$PC_CUDNN_INCLUDE_DIRS
export LIBRARY_PATH=$LIBRARY_PATH:$LD_LIBRARY_PATH
export INCLUDE=$INCLUDE:$CPATH
export CUDNN_ROOT_DIR=${NIVIDA_INSTALL_PRE}/${CUDNN_V}/cuda
export TRT_ROOT_DIR=${NIVIDA_INSTALL_PRE}/${TRT_V}
# python version will be config by whl build script or ci script, we need
# a DFT version for build success when we just call host_build.sh
......
......@@ -59,6 +59,16 @@ add_library(megbrain OBJECT ${SOURCES})
target_link_libraries(megbrain PUBLIC mgb_opr_param_defs)
if(MGE_WITH_CUDA)
target_include_directories(megbrain PUBLIC ${TRT_INCLUDE_DIR})
target_include_directories(megbrain PRIVATE ${CUDNN_INCLUDE_DIR})
find_path(NVTX3_INCLUDE
NAMES nvToolsExtCudaRt.h
HINTS $ENV{CUDA_ROOT_DIR} $ENV{CUDA_PATH} $ENV{CUDA_BIN_PATH}
PATH_SUFFIXES include/nvtx3
DOC "NVTX3_INCLUDE" )
if(NVTX3_INCLUDE STREQUAL "NVTX3_INCLUDE-NOTFOUND")
message(FATAL_ERROR "Can not find NVTX3 INCLUDE, please export cuda sdk path to CUDA_ROOT_DIR or CUDA_PATH or CUDA_BIN_PATH")
endif()
target_include_directories(megbrain PRIVATE ${NVTX3_INCLUDE})
endif()
target_include_directories(megbrain
PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册