mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Use shared CUPTI by default
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 <ezyangfb.com> Pull Request resolved: https://github.com/pytorch/pytorch/pull/74009 Approved by: https://github.com/malfet
This commit is contained in:
committed by
PyTorch MergeBot
parent
6f13024c8c
commit
493bbdc4fe
@ -209,7 +209,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)
|
||||
|
@ -1921,6 +1921,32 @@ if(USE_KINETO)
|
||||
message(STATUS " CUDA_cupti_LIBRARY = ${CUDA_cupti_LIBRARY}")
|
||||
message(STATUS "Found CUPTI")
|
||||
set(LIBKINETO_NOCUPTI OFF CACHE STRING "" FORCE)
|
||||
|
||||
# I've only tested this sanity check on Linux; if someone
|
||||
# runs into this bug on another platform feel free to
|
||||
# generalize it accordingly
|
||||
if(NOT USE_CUPTI_SO AND UNIX)
|
||||
include(CheckCXXSourceRuns)
|
||||
# rt is handled by the CMAKE_REQUIRED_LIBRARIES set above
|
||||
if(NOT APPLE)
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} "dl")
|
||||
endif()
|
||||
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()
|
||||
endif()
|
||||
|
||||
else()
|
||||
message(STATUS "Could not find CUPTI library, using CPU-only Kineto build")
|
||||
set(LIBKINETO_NOCUPTI ON CACHE STRING "" FORCE)
|
||||
|
Reference in New Issue
Block a user