add examples for resource exhausted error, test=develop (#21140)

custom_op_abi
Chen Weihang 6 years ago committed by GitHub
parent 8f659d4345
commit 27fa9c100b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -47,7 +47,7 @@ Allocation* CUDAAllocator::AllocateImpl(size_t size) {
if (result != cudaSuccess) avail = 0;
platform::RaiseNonOutOfMemoryError(&result);
PADDLE_THROW_BAD_ALLOC(
PADDLE_THROW_BAD_ALLOC(platform::errors::ResourceExhausted(
"\n\nOut of memory error on GPU %d. "
"Cannot allocate %s memory on GPU %d, "
"available memory is only %s.\n\n"
@ -55,7 +55,7 @@ Allocation* CUDAAllocator::AllocateImpl(size_t size) {
"1. If yes, please stop them, or start PaddlePaddle on another GPU.\n"
"2. If no, please decrease the batch size of your model.\n",
place_.device, string::HumanReadableSize(size), place_.device,
string::HumanReadableSize(avail), place_.device);
string::HumanReadableSize(avail), place_.device));
}
} // namespace allocation

@ -134,7 +134,7 @@ void* GPUAllocator::Alloc(size_t* index, size_t size) {
if (result != cudaSuccess) avail = 0;
platform::RaiseNonOutOfMemoryError(&result);
PADDLE_THROW_BAD_ALLOC(
PADDLE_THROW_BAD_ALLOC(platform::errors::ResourceExhausted(
"\n\nOut of memory error on GPU %d. "
"Cannot allocate %s memory on GPU %d, "
"available memory is only %s.\n\n"
@ -148,7 +148,7 @@ void* GPUAllocator::Alloc(size_t* index, size_t size) {
"`export FLAGS_fraction_of_gpu_memory_to_use=xxx`.\n\n",
gpu_id_, string::HumanReadableSize(size), gpu_id_,
string::HumanReadableSize(avail), gpu_id_,
FLAGS_fraction_of_gpu_memory_to_use);
FLAGS_fraction_of_gpu_memory_to_use));
}
}

@ -360,10 +360,11 @@ struct EOFException : public std::exception {
__LINE__); \
} while (0)
#define PADDLE_THROW_BAD_ALLOC(...) \
do { \
throw ::paddle::memory::allocation::BadAlloc( \
::paddle::string::Sprintf(__VA_ARGS__), __FILE__, __LINE__); \
#define PADDLE_THROW_BAD_ALLOC(...) \
do { \
throw ::paddle::memory::allocation::BadAlloc( \
::paddle::platform::ErrorSummary(__VA_ARGS__).ToString(), __FILE__, \
__LINE__); \
} while (0)
/** CUDA PADDLE ENFORCE FUNCTIONS AND MACROS **/

Loading…
Cancel
Save