mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
Expand Kineto platform support (ci-all) (#56323)
Summary: Expanding support to all builds Pull Request resolved: https://github.com/pytorch/pytorch/pull/56323 Test Plan: CI Reviewed By: malfet Differential Revision: D28171478 Pulled By: ilia-cher fbshipit-source-id: 16bc752d1be3cbaeda5316f5d8a687ae05a83d22
This commit is contained in:
parent
30c96c9419
commit
65fad0ebd2
|
|
@ -1824,14 +1824,6 @@ if(USE_KINETO AND INTERN_BUILD_MOBILE)
|
||||||
message(STATUS "Not using libkineto in a mobile build.")
|
message(STATUS "Not using libkineto in a mobile build.")
|
||||||
set(USE_KINETO OFF)
|
set(USE_KINETO OFF)
|
||||||
endif()
|
endif()
|
||||||
if(USE_KINETO AND MSVC)
|
|
||||||
message(STATUS "Not using libkineto in a Windows build.")
|
|
||||||
set(USE_KINETO OFF)
|
|
||||||
endif()
|
|
||||||
if(USE_KINETO AND APPLE)
|
|
||||||
message(STATUS "Not using libkineto in a Mac build.")
|
|
||||||
set(USE_KINETO OFF)
|
|
||||||
endif()
|
|
||||||
if(USE_KINETO AND (NOT USE_CUDA))
|
if(USE_KINETO AND (NOT USE_CUDA))
|
||||||
set(LIBKINETO_NOCUPTI ON CACHE STRING "")
|
set(LIBKINETO_NOCUPTI ON CACHE STRING "")
|
||||||
message(STATUS "Using CPU-only Kineto in the non-CUDA build.")
|
message(STATUS "Using CPU-only Kineto in the non-CUDA build.")
|
||||||
|
|
|
||||||
|
|
@ -123,6 +123,10 @@ else()
|
||||||
append_torchlib_if_found(sleef asmjit)
|
append_torchlib_if_found(sleef asmjit)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(@USE_KINETO@)
|
||||||
|
append_torchlib_if_found(kineto)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(@USE_CUDA@)
|
if(@USE_CUDA@)
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
if(NOT NVTOOLEXT_HOME)
|
if(NOT NVTOOLEXT_HOME)
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ end
|
||||||
|
|
||||||
# link static libraries
|
# link static libraries
|
||||||
target.frameworks_build_phases.clear
|
target.frameworks_build_phases.clear
|
||||||
libs = ['libc10.a', 'libclog.a', 'libpthreadpool.a', 'libXNNPACK.a', 'libeigen_blas.a', 'libcpuinfo.a', 'libpytorch_qnnpack.a', 'libtorch_cpu.a', 'libtorch.a']
|
libs = ['libc10.a', 'libclog.a', 'libpthreadpool.a', 'libXNNPACK.a', 'libeigen_blas.a', 'libcpuinfo.a', 'libpytorch_qnnpack.a', 'libtorch_cpu.a', 'libtorch.a', 'libkineto.a']
|
||||||
for lib in libs do
|
for lib in libs do
|
||||||
path = "#{install_path}/lib/#{lib}"
|
path = "#{install_path}/lib/#{lib}"
|
||||||
if File.exist?(path)
|
if File.exist?(path)
|
||||||
|
|
|
||||||
|
|
@ -482,6 +482,7 @@ class TestProfiler(TestCase):
|
||||||
assert is_int, "Invalid stacks record"
|
assert is_int, "Invalid stacks record"
|
||||||
|
|
||||||
@unittest.skipIf(not kineto_available(), "Kineto is required")
|
@unittest.skipIf(not kineto_available(), "Kineto is required")
|
||||||
|
@unittest.skipIf(IS_WINDOWS, "Test is flaky on Windows")
|
||||||
def test_tensorboard_trace_handler(self):
|
def test_tensorboard_trace_handler(self):
|
||||||
use_cuda = torch.cuda.is_available()
|
use_cuda = torch.cuda.is_available()
|
||||||
with _profile(use_cuda=use_cuda, use_kineto=True):
|
with _profile(use_cuda=use_cuda, use_kineto=True):
|
||||||
|
|
|
||||||
2
third_party/kineto
vendored
2
third_party/kineto
vendored
|
|
@ -1 +1 @@
|
||||||
Subproject commit 5bc9386b6d60c3b34b77961ea2900947103304b9
|
Subproject commit 07344e6d29fb17283fbc909d7631b5256b98537d
|
||||||
|
|
@ -9,12 +9,6 @@
|
||||||
#ifdef USE_KINETO
|
#ifdef USE_KINETO
|
||||||
#include <libkineto.h>
|
#include <libkineto.h>
|
||||||
|
|
||||||
#ifndef USE_KINETO_UPDATED
|
|
||||||
#include <pthread.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/syscall.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
// TODO: TO be removed, once this properly works from libkineto
|
// TODO: TO be removed, once this properly works from libkineto
|
||||||
// Literal copy-n-paste from third_party/kineto/libkineto/src/WeakSymbols.cpp
|
// Literal copy-n-paste from third_party/kineto/libkineto/src/WeakSymbols.cpp
|
||||||
|
|
@ -41,14 +35,6 @@ inline int64_t getTimeUs() {
|
||||||
return duration_cast<microseconds>(high_resolution_clock::now().time_since_epoch()).count();
|
return duration_cast<microseconds>(high_resolution_clock::now().time_since_epoch()).count();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef USE_KINETO_UPDATED
|
|
||||||
// Getting the linux tid is expensive, so cache it.
|
|
||||||
// Caching linux pids and tids is not advisable in the general case,
|
|
||||||
// but this is only for profiling purposes and we don't need to handle
|
|
||||||
// special cases during fork, clone etc.
|
|
||||||
static thread_local pid_t cachedTid;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
std::string shapesToStr(const std::vector<std::vector<int64_t>>& shapes);
|
std::string shapesToStr(const std::vector<std::vector<int64_t>>& shapes);
|
||||||
std::string stacksToStr(const std::vector<std::string>& stacks);
|
std::string stacksToStr(const std::vector<std::string>& stacks);
|
||||||
std::string dtypesToStr(const std::vector<std::string>& types);
|
std::string dtypesToStr(const std::vector<std::string>& types);
|
||||||
|
|
@ -64,14 +50,11 @@ struct KinetoThreadLocalState : public ProfilerThreadLocalState {
|
||||||
if (!ctx) {
|
if (!ctx) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifdef USE_KINETO_UPDATED
|
|
||||||
libkineto::GenericTraceActivity op;
|
libkineto::GenericTraceActivity op;
|
||||||
op.activityType = libkineto::ActivityType::CPU_OP;
|
op.activityType = libkineto::ActivityType::CPU_OP;
|
||||||
op.activityName = std::string(fn.name().str());
|
op.activityName = std::string(fn.name().str());
|
||||||
#else
|
|
||||||
libkineto::ClientTraceActivity op;
|
|
||||||
op.opType = std::string(fn.name().str());
|
|
||||||
#endif
|
|
||||||
op.startTime = ctx->startUs;
|
op.startTime = ctx->startUs;
|
||||||
op.endTime = getTimeUs();
|
op.endTime = getTimeUs();
|
||||||
op.device = 0;
|
op.device = 0;
|
||||||
|
|
@ -82,16 +65,8 @@ struct KinetoThreadLocalState : public ProfilerThreadLocalState {
|
||||||
// op.inputDims = shapesToStr(*ctx->shapes);
|
// op.inputDims = shapesToStr(*ctx->shapes);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
#ifdef USE_KINETO_UPDATED
|
|
||||||
libkineto::api().activityProfiler().recordThreadInfo();
|
libkineto::api().activityProfiler().recordThreadInfo();
|
||||||
op.sysThreadId = libkineto::systemThreadId();
|
op.sysThreadId = libkineto::systemThreadId();
|
||||||
#else
|
|
||||||
if (!cachedTid) {
|
|
||||||
cachedTid = (pid_t)syscall(SYS_gettid);
|
|
||||||
libkineto::api().activityProfiler().recordThreadInfo(cachedTid, pthread_self());
|
|
||||||
}
|
|
||||||
op.sysThreadId = cachedTid;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> guard(state_mutex_);
|
std::lock_guard<std::mutex> guard(state_mutex_);
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
#include <torch/csrc/autograd/profiler_legacy.h>
|
#include <torch/csrc/autograd/profiler_legacy.h>
|
||||||
|
|
||||||
// Kineto is currently available on Linux server-side
|
|
||||||
#ifdef USE_KINETO
|
#ifdef USE_KINETO
|
||||||
#if !defined(__linux__) || defined(_WIN32) || defined(C10_MOBILE) || defined(__APPLE__) || defined(DISABLE_KINETO)
|
// skip Kineto dependency on mobile
|
||||||
|
#ifdef C10_MOBILE
|
||||||
#undef USE_KINETO
|
#undef USE_KINETO
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user