未验证 提交 27fa9c10 编写于 作者: C Chen Weihang 提交者: GitHub

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

上级 8f659d43
......@@ -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 **/
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册