From 3f6915ce1e5f4f56b5d9851e2695d539f54a511c Mon Sep 17 00:00:00 2001 From: ronnywang Date: Mon, 16 Oct 2023 15:09:14 +0800 Subject: [PATCH] [CustomDevice] Fix errors during event release (#58059) * [CustomDevice] Fix errors during event release * fix custom_tracer --- paddle/fluid/platform/profiler/custom_device/custom_tracer.cc | 4 ++++ paddle/phi/backends/device_manager.cc | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/platform/profiler/custom_device/custom_tracer.cc b/paddle/fluid/platform/profiler/custom_device/custom_tracer.cc index 2b8bcdf962649..795aab1e128fd 100644 --- a/paddle/fluid/platform/profiler/custom_device/custom_tracer.cc +++ b/paddle/fluid/platform/profiler/custom_device/custom_tracer.cc @@ -28,6 +28,10 @@ namespace platform { CustomTracer::CustomTracer(const std::string& dev_type) : dev_type_(dev_type) { #ifdef PADDLE_WITH_CUSTOM_DEVICE + auto selected_devices = phi::DeviceManager::GetSelectedDeviceList(dev_type_); + if (selected_devices.size()) { + phi::DeviceManager::SetDevice(dev_type_, selected_devices[0]); + } phi::DeviceManager::ProfilerInitialize(dev_type_, &collector_, &context_); #endif } diff --git a/paddle/phi/backends/device_manager.cc b/paddle/phi/backends/device_manager.cc index f9630b2d580cc..748c80c0859c5 100644 --- a/paddle/phi/backends/device_manager.cc +++ b/paddle/phi/backends/device_manager.cc @@ -697,8 +697,8 @@ DeviceManager& DeviceManager::Instance() { } void DeviceManager::Release() { - stream::Stream::ReleaseAll(); event::Event::ReleaseAll(); + stream::Stream::ReleaseAll(); Instance().device_map_.clear(); Instance().device_impl_map_.clear(); }