mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
Set USE_KINETO=1 (#49201)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/49201 This unblocks kineto profiler for 1.8 release. This PR supercedes https://github.com/pytorch/pytorch/pull/48391 Note: this will somewhat increase the size of linux server binaries, bc we add libkineto.a and libcupti_static.a: -rw-r--r-- 1 jenkins jenkins 1107502 Dec 10 21:16 build/lib/libkineto.a -rw-r--r-- 1 root root 13699658 Nov 13 2019 /usr/local/cuda/lib64/libcupti_static.a Test Plan: CI https://github.com/pytorch/pytorch/pull/48391 Imported from OSS Reviewed By: ngimel Differential Revision: D25480770 fbshipit-source-id: 037cd774f5547d9918d6055ef5cc952a54e48e4c
This commit is contained in:
parent
020c443fd1
commit
1a92802bde
|
|
@ -159,7 +159,8 @@ cmake_dependent_option(
|
||||||
USE_STATIC_CUDNN "Use cuDNN static libraries" OFF
|
USE_STATIC_CUDNN "Use cuDNN static libraries" OFF
|
||||||
"USE_CUDNN" OFF)
|
"USE_CUDNN" OFF)
|
||||||
option(USE_FBGEMM "Use FBGEMM (quantized 8-bit server operators)" ON)
|
option(USE_FBGEMM "Use FBGEMM (quantized 8-bit server operators)" ON)
|
||||||
option(USE_KINETO "Use Kineto profiling library" OFF)
|
option(USE_KINETO "Use Kineto profiling library" ON)
|
||||||
|
option(USE_CUPTI_SO "Use CUPTI as a shared library" OFF)
|
||||||
option(USE_FAKELOWP "Use FakeLowp operators" OFF)
|
option(USE_FAKELOWP "Use FakeLowp operators" OFF)
|
||||||
option(USE_FFMPEG "Use ffmpeg" OFF)
|
option(USE_FFMPEG "Use ffmpeg" OFF)
|
||||||
option(USE_GFLAGS "Use GFLAGS" OFF)
|
option(USE_GFLAGS "Use GFLAGS" OFF)
|
||||||
|
|
@ -515,31 +516,12 @@ if(USE_FBGEMM AND ((CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND CMAKE_SIZEOF_VO
|
||||||
set(USE_FBGEMM OFF)
|
set(USE_FBGEMM OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(USE_KINETO AND INTERN_BUILD_MOBILE)
|
|
||||||
message(STATUS "Not using libkineto in a mobile build.")
|
|
||||||
set(USE_KINETO OFF)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(USE_KINETO AND (NOT USE_CUDA))
|
|
||||||
message(STATUS "Not using libkineto in a non-CUDA build.")
|
|
||||||
set(USE_KINETO OFF)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(USE_KINETO AND MSVC)
|
|
||||||
message(STATUS "Not using libkineto in a Windows build.")
|
|
||||||
set(USE_KINETO OFF)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
include(cmake/Dependencies.cmake)
|
include(cmake/Dependencies.cmake)
|
||||||
|
|
||||||
if(USE_FBGEMM)
|
if(USE_FBGEMM)
|
||||||
string(APPEND CMAKE_CXX_FLAGS " -DUSE_FBGEMM")
|
string(APPEND CMAKE_CXX_FLAGS " -DUSE_FBGEMM")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(USE_KINETO)
|
|
||||||
string(APPEND CMAKE_CXX_FLAGS " -DUSE_KINETO")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(USE_QNNPACK)
|
if(USE_QNNPACK)
|
||||||
string(APPEND CMAKE_CXX_FLAGS " -DUSE_QNNPACK")
|
string(APPEND CMAKE_CXX_FLAGS " -DUSE_QNNPACK")
|
||||||
endif()
|
endif()
|
||||||
|
|
|
||||||
|
|
@ -1788,8 +1788,21 @@ list(APPEND Caffe2_DEPENDENCY_LIBS fmt::fmt-header-only)
|
||||||
set(BUILD_SHARED_LIBS ${TEMP_BUILD_SHARED_LIBS} CACHE BOOL "Build shared libs" FORCE)
|
set(BUILD_SHARED_LIBS ${TEMP_BUILD_SHARED_LIBS} CACHE BOOL "Build shared libs" FORCE)
|
||||||
|
|
||||||
# ---[ Kineto
|
# ---[ Kineto
|
||||||
|
if(USE_KINETO AND INTERN_BUILD_MOBILE)
|
||||||
|
message(STATUS "Not using libkineto in a mobile build.")
|
||||||
|
set(USE_KINETO OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(USE_KINETO AND (NOT USE_CUDA))
|
||||||
|
message(STATUS "Not using libkineto in a non-CUDA build.")
|
||||||
|
set(USE_KINETO OFF)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(USE_KINETO AND MSVC)
|
||||||
|
message(STATUS "Not using libkineto in a Windows build.")
|
||||||
|
set(USE_KINETO OFF)
|
||||||
|
endif()
|
||||||
if(USE_KINETO)
|
if(USE_KINETO)
|
||||||
if(USE_KINETO AND NOT TARGET kineto)
|
|
||||||
set(CAFFE2_THIRD_PARTY_ROOT "${PROJECT_SOURCE_DIR}/third_party" CACHE STRING "")
|
set(CAFFE2_THIRD_PARTY_ROOT "${PROJECT_SOURCE_DIR}/third_party" CACHE STRING "")
|
||||||
set(KINETO_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/kineto/libkineto" CACHE STRING "")
|
set(KINETO_SOURCE_DIR "${CAFFE2_THIRD_PARTY_ROOT}/kineto/libkineto" CACHE STRING "")
|
||||||
set(KINETO_BUILD_TESTS OFF CACHE BOOL "")
|
set(KINETO_BUILD_TESTS OFF CACHE BOOL "")
|
||||||
|
|
@ -1802,29 +1815,43 @@ if(USE_KINETO)
|
||||||
message(STATUS " KINETO_LIBRARY_TYPE = ${KINETO_LIBRARY_TYPE}")
|
message(STATUS " KINETO_LIBRARY_TYPE = ${KINETO_LIBRARY_TYPE}")
|
||||||
message(STATUS " CUDA_SOURCE_DIR = ${CUDA_SOURCE_DIR}")
|
message(STATUS " CUDA_SOURCE_DIR = ${CUDA_SOURCE_DIR}")
|
||||||
|
|
||||||
|
if(EXISTS ${CUDA_SOURCE_DIR}/extras/CUPTI/lib64/libcupti_static.a)
|
||||||
|
set(CUDA_cupti_LIBRARY "${CUDA_SOURCE_DIR}/extras/CUPTI/lib64/libcupti_static.a")
|
||||||
|
elseif(EXISTS ${CUDA_SOURCE_DIR}/lib64/libcupti_static.a)
|
||||||
|
set(CUDA_cupti_LIBRARY "${CUDA_SOURCE_DIR}/lib64/libcupti_static.a")
|
||||||
|
elseif(USE_CUPTI_SO)
|
||||||
|
if(EXISTS ${CUDA_SOURCE_DIR}/extras/CUPTI/lib64/libcupti.so)
|
||||||
|
set(CUDA_cupti_LIBRARY "${CUDA_SOURCE_DIR}/extras/CUPTI/lib64/libcupti.so")
|
||||||
|
elseif(EXISTS ${CUDA_SOURCE_DIR}/lib64/libcupti.so)
|
||||||
|
set(CUDA_cupti_LIBRARY "${CUDA_SOURCE_DIR}/lib64/libcupti.so")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
if(EXISTS ${CUDA_SOURCE_DIR}/extras/CUPTI/include)
|
if(EXISTS ${CUDA_SOURCE_DIR}/extras/CUPTI/include)
|
||||||
set(CUPTI_INCLUDE_DIR "${CUDA_SOURCE_DIR}/extras/CUPTI/include")
|
set(CUPTI_INCLUDE_DIR "${CUDA_SOURCE_DIR}/extras/CUPTI/include")
|
||||||
elseif(EXISTS ${CUDA_SOURCE_DIR}/include/cupti.h)
|
elseif(EXISTS ${CUDA_SOURCE_DIR}/include/cupti.h)
|
||||||
set(CUPTI_INCLUDE_DIR "${CUDA_SOURCE_DIR}/include")
|
set(CUPTI_INCLUDE_DIR "${CUDA_SOURCE_DIR}/include")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if((NOT DEFINED CUDA_cupti_LIBRARY) OR (${CUDA_cupti_LIBRARY} STREQUAL "CUDA_cupti_LIBRARY-NOTFOUND"))
|
set(FOUND_CUPTI FALSE)
|
||||||
if(EXISTS ${CUDA_SOURCE_DIR}/extras/CUPTI/lib64/libcupti_static.a)
|
if((DEFINED CUPTI_INCLUDE_DIR) AND (DEFINED CUDA_cupti_LIBRARY))
|
||||||
set(CUDA_cupti_LIBRARY "${CUDA_SOURCE_DIR}/extras/CUPTI/lib64/libcupti_static.a")
|
if((CUDA_cupti_LIBRARY MATCHES "libcupti_static.a") OR ((CUDA_cupti_LIBRARY MATCHES "libcupti.so") AND (USE_CUPTI_SO)))
|
||||||
elseif(EXISTS ${CUDA_SOURCE_DIR}/lib64/libcupti_static.a)
|
set(FOUND_CUPTI TRUE)
|
||||||
set(CUDA_cupti_LIBRARY "${CUDA_SOURCE_DIR}/lib64/libcupti_static.a")
|
|
||||||
elseif(EXISTS ${CUDA_SOURCE_DIR}/extras/CUPTI/lib64/libcupti.so)
|
|
||||||
set(CUDA_cupti_LIBRARY "${CUDA_SOURCE_DIR}/extras/CUPTI/lib64/libcupti.so")
|
|
||||||
elseif(EXISTS ${CUDA_SOURCE_DIR}/lib64/libcupti.so)
|
|
||||||
set(CUDA_cupti_LIBRARY "${CUDA_SOURCE_DIR}/lib64/libcupti.so")
|
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(FOUND_CUPTI)
|
||||||
message(STATUS " CUDA_cupti_LIBRARY = ${CUDA_cupti_LIBRARY}")
|
message(STATUS " CUDA_cupti_LIBRARY = ${CUDA_cupti_LIBRARY}")
|
||||||
message(STATUS " CUPTI_INCLUDE_DIR = ${CUPTI_INCLUDE_DIR}")
|
message(STATUS " CUPTI_INCLUDE_DIR = ${CUPTI_INCLUDE_DIR}")
|
||||||
|
if(NOT TARGET kineto)
|
||||||
add_subdirectory("${KINETO_SOURCE_DIR}")
|
add_subdirectory("${KINETO_SOURCE_DIR}")
|
||||||
message(STATUS "Configured Kineto as a dependency.")
|
message(STATUS "Configured Kineto as a dependency.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
string(APPEND CMAKE_CXX_FLAGS " -DUSE_KINETO")
|
||||||
list(APPEND Caffe2_DEPENDENCY_LIBS kineto)
|
list(APPEND Caffe2_DEPENDENCY_LIBS kineto)
|
||||||
|
else()
|
||||||
|
message(STATUS "Could not find CUPTI library, skipping Kineto build")
|
||||||
|
set(USE_KINETO OFF)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
|
||||||
4
setup.py
4
setup.py
|
|
@ -33,8 +33,8 @@
|
||||||
# USE_FBGEMM=0
|
# USE_FBGEMM=0
|
||||||
# disables the FBGEMM build
|
# disables the FBGEMM build
|
||||||
#
|
#
|
||||||
# USE_KINETO=1
|
# USE_KINETO=0
|
||||||
# enables experimental usage of libkineto
|
# disables usage of libkineto library for profiling
|
||||||
#
|
#
|
||||||
# USE_NUMPY=0
|
# USE_NUMPY=0
|
||||||
# disables the NumPy build
|
# disables the NumPy build
|
||||||
|
|
|
||||||
|
|
@ -360,7 +360,7 @@ void ProfilerResult::save(const std::string& path) {
|
||||||
|
|
||||||
bool kinetoAvailable() {
|
bool kinetoAvailable() {
|
||||||
#ifdef USE_KINETO
|
#ifdef USE_KINETO
|
||||||
return true;
|
return at::hasCUDA();
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user