File tree Expand file tree Collapse file tree 3 files changed +9
-5
lines changed
paddle/fluid/memory/allocation Expand file tree Collapse file tree 3 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -897,9 +897,11 @@ class AllocatorFacadePrivate {
897
897
}
898
898
899
899
void InitCUDAMallocAsyncAllocator (phi::GPUPlace p, gpuStream_t stream) {
900
+ #ifdef PADDLE_WITH_CUDA
900
901
std::shared_ptr<Allocator>& allocator = cuda_allocators_[p][stream];
901
902
cuda_allocators_[p][stream] =
902
903
std::make_shared<CUDAMallocAsyncAllocator>(allocator, p, stream);
904
+ #endif
903
905
}
904
906
905
907
void InitAutoGrowthCUDAAllocator (phi::GPUPlace p, gpuStream_t stream) {
@@ -1169,6 +1171,7 @@ class AllocatorFacadePrivate {
1169
1171
}
1170
1172
1171
1173
void WrapCUDAMallocAsyncAllocatorForDefault () {
1174
+ #ifdef PADDLE_WITH_CUDA
1172
1175
for (auto & pair : allocators_) {
1173
1176
auto & place = pair.first ;
1174
1177
if (platform::is_gpu_place (place)) {
@@ -1188,6 +1191,7 @@ class AllocatorFacadePrivate {
1188
1191
<< " , allocator address = " << pair.second .get ();
1189
1192
}
1190
1193
}
1194
+ #endif
1191
1195
}
1192
1196
1193
1197
void WrapCUDARetryAllocator (phi::GPUPlace p,
Original file line number Diff line number Diff line change 24
24
#ifdef PADDLE_WITH_CUDA
25
25
#include < cuda.h>
26
26
#include < cuda_runtime.h>
27
+ #include " paddle/phi/backends/gpu/cuda/cuda_graph.h"
27
28
#endif
28
29
29
30
#include < string>
30
31
31
32
#include " paddle/fluid/platform/cuda_device_guard.h"
32
33
#include " paddle/fluid/platform/device/gpu/gpu_info.h"
33
34
#include " paddle/fluid/platform/enforce.h"
34
- #if defined(PADDLE_WITH_CUDA)
35
- #include " paddle/phi/backends/gpu/cuda/cuda_graph.h"
36
- #elif defined(PADDLE_WITH_HIP)
37
- #include " paddle/phi/backends/gpu/rocm/hip_graph.h"
38
- #endif
39
35
40
36
#include " paddle/utils/optional.h"
41
37
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ namespace allocation {
37
37
// managing memory allocations with CUDA async malloc. It includes methods to
38
38
// handle stream associations and to query the owning stream of the allocation.
39
39
class CUDAMallocAsyncAllocation : public Allocation {
40
+ #ifdef PADDLE_WITH_CUDA
40
41
public:
41
42
CUDAMallocAsyncAllocation (void * ptr,
42
43
size_t size,
@@ -60,12 +61,14 @@ class CUDAMallocAsyncAllocation : public Allocation {
60
61
61
62
SpinLock recorded_streams_lock_;
62
63
std::unordered_set<gpuStream_t> recorded_streams_;
64
+ #endif
63
65
};
64
66
65
67
// The `CUDAMallocAsyncAllocator` class extends `Allocator` and is specialized
66
68
// for asynchronous memory allocation in CUDA. It offers thread-safe allocation
67
69
// and incorporates a default stream for memory operations.
68
70
class CUDAMallocAsyncAllocator : public Allocator {
71
+ #ifdef PADDLE_WITH_CUDA
69
72
public:
70
73
explicit CUDAMallocAsyncAllocator (
71
74
std::shared_ptr<Allocator> underlying_allocator,
@@ -128,6 +131,7 @@ class CUDAMallocAsyncAllocator : public Allocator {
128
131
std::unordered_map<CUDAMallocAsyncAllocation*, CUDAGraphID>
129
132
graph_owned_allocations_;
130
133
SpinLock graph_owned_allocations_lock_;
134
+ #endif
131
135
};
132
136
133
137
} // namespace allocation
You can’t perform that action at this time.
0 commit comments