Use shared CUPTI by default (#65401)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/65401

Per https://github.com/pytorch/pytorch/issues/57744 statically linked CUPTI
causes exception handling to break on certain compiler configurations, likely
because CUPTI comes with incompatible libstdc++ symbols.  Rather than pray that
something reasonable happens, use the safer configuration (dynamic linking) by
default and give a warning if the user inverts the setting.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

Test Plan: Imported from OSS

Reviewed By: gdankel

Differential Revision: D31082208

Pulled By: ezyang

fbshipit-source-id: 14f66af920847e158436b5801c43f3124b109b34
This commit is contained in:
Edward Yang
2021-10-12 10:59:36 -07:00
committed by Facebook GitHub Bot
parent c6216b2a43
commit 8b0eae5aa8
2 changed files with 19 additions and 1 deletions

View File

@ -206,7 +206,7 @@ cmake_dependent_option(
option(USE_FBGEMM "Use FBGEMM (quantized 8-bit server operators)" ON)
option(USE_KINETO "Use Kineto profiling library" ON)
option(USE_BREAKPAD "Use breakpad crash dump library" ON)
option(USE_CUPTI_SO "Use CUPTI as a shared library" OFF)
option(USE_CUPTI_SO "Use CUPTI as a shared library" ON)
option(USE_FAKELOWP "Use FakeLowp operators" OFF)
option(USE_FFMPEG "Use ffmpeg" OFF)
option(USE_GFLAGS "Use GFLAGS" OFF)

View File

@ -1960,6 +1960,24 @@ if(USE_KINETO)
message(STATUS " CUDA_cupti_LIBRARY = ${CUDA_cupti_LIBRARY}")
message(STATUS "Found CUPTI")
set(LIBKINETO_NOCUPTI OFF CACHE STRING "" FORCE)
include(CheckCXXSourceRuns)
unset(EXCEPTIONS_WORK CACHE)
set(CMAKE_REQUIRED_LINK_OPTIONS "-Wl,--whole-archive,${CUPTI_LIBRARY_PATH},--no-whole-archive")
check_cxx_source_runs("#include <stdexcept>
int main() {
try {
throw std::runtime_error(\"error\");
} catch (...) {
return 0;
}
return 1;
}" EXCEPTIONS_WORK)
set(CMAKE_REQUIRED_LINK_OPTIONS "")
if(NOT EXCEPTIONS_WORK)
message(FATAL_ERROR "Detected that statically linking against CUPTI causes exceptions to stop working. See https://github.com/pytorch/pytorch/issues/57744 for more details. Perhaps try: USE_CUPTI_SO=1 python setup.py develop --cmake")
endif()
else()
message(STATUS "Could not find CUPTI library, using CPU-only Kineto build")
set(LIBKINETO_NOCUPTI ON CACHE STRING "" FORCE)