Skip to content

Commit

Permalink
[CustomDevice] fix default stream allocator error (#56536)
Browse files Browse the repository at this point in the history
  • Loading branch information
ronny1996 authored Aug 23, 2023
1 parent b71e8ff commit 7e7e2b7
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <thread>

#include "paddle/fluid/platform/profiler/event_tracing.h"
#include "paddle/phi/backends/context_pool.h"

namespace paddle {
namespace memory {
Expand Down Expand Up @@ -179,7 +180,11 @@ void StreamSafeCustomDeviceAllocator::FreeImpl(phi::Allocation* allocation) {

VLOG(8) << "Try free allocation " << stream_safe_cuda_allocation->ptr();
if (!stream_safe_cuda_allocation->GetOwningStream()) {
stream_safe_cuda_allocation->SetOwningStream(default_stream_);
stream_safe_cuda_allocation->SetOwningStream(
default_stream_ ? default_stream_
: reinterpret_cast<phi::CustomContext*>(
phi::DeviceContextPool::Instance().Get(place_))
->stream());
}
stream_safe_cuda_allocation->MarkAsWillBeFreed();
if (stream_safe_cuda_allocation->CanBeFreed()) {
Expand Down

0 comments on commit 7e7e2b7

Please sign in to comment.