From b86ad055be3793518147076e82a997451e505951 Mon Sep 17 00:00:00 2001 From: Lixia Chen Date: Wed, 23 Dec 2020 11:18:48 -0500 Subject: [PATCH] Minor fix (requested by HQ) --- .../ccsrc/minddata/dataset/engine/cache/cache_service.cc | 6 ++++-- .../minddata/dataset/engine/datasetops/cache_base_op.cc | 1 + .../minddata/dataset/engine/ir/cache/dataset_cache_impl.h | 3 ++- mindspore/ccsrc/minddata/dataset/include/datasets.h | 3 ++- mindspore/dataset/engine/cache_client.py | 3 ++- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/mindspore/ccsrc/minddata/dataset/engine/cache/cache_service.cc b/mindspore/ccsrc/minddata/dataset/engine/cache/cache_service.cc index 4d746bcb2d7..4679ac214ec 100644 --- a/mindspore/ccsrc/minddata/dataset/engine/cache/cache_service.cc +++ b/mindspore/ccsrc/minddata/dataset/engine/cache/cache_service.cc @@ -39,8 +39,10 @@ Status CacheService::DoServiceStart() { if (cache_mem_sz_ > 0) { auto avail_mem = CacheServerHW::GetTotalSystemMemory(); if (cache_mem_sz_ > avail_mem) { - // Output a warning that we use more than recommended. If we fail to allocate, we will fail anyway. - MS_LOG(WARNING) << "Requesting cache size " << cache_mem_sz_ << " while available system memory " << avail_mem; + // Return an error if we use more than recommended memory. + std::string errMsg = "Requesting cache size " + std::to_string(cache_mem_sz_) + + " while available system memory " + std::to_string(avail_mem); + return Status(StatusCode::kOutOfMemory, __LINE__, __FILE__, errMsg); } memory_cap_ratio = static_cast(cache_mem_sz_) / avail_mem; } diff --git a/mindspore/ccsrc/minddata/dataset/engine/datasetops/cache_base_op.cc b/mindspore/ccsrc/minddata/dataset/engine/datasetops/cache_base_op.cc index 1bffd360cd4..8b914a780d7 100644 --- a/mindspore/ccsrc/minddata/dataset/engine/datasetops/cache_base_op.cc +++ b/mindspore/ccsrc/minddata/dataset/engine/datasetops/cache_base_op.cc @@ -308,6 +308,7 @@ Status CacheBase::Prefetcher(int32_t worker_id) { // If we get some network error, we will attempt some retries retry_count++; } else if (rc.IsError()) { + MS_LOG(WARNING) << rc.ToString(); return rc; } } while (rc.IsNetWorkError()); diff --git a/mindspore/ccsrc/minddata/dataset/engine/ir/cache/dataset_cache_impl.h b/mindspore/ccsrc/minddata/dataset/engine/ir/cache/dataset_cache_impl.h index b1550009333..60dc11b5872 100644 --- a/mindspore/ccsrc/minddata/dataset/engine/ir/cache/dataset_cache_impl.h +++ b/mindspore/ccsrc/minddata/dataset/engine/ir/cache/dataset_cache_impl.h @@ -32,7 +32,8 @@ class DatasetCacheImpl : public DatasetCache { /// /// \brief Constructor /// \param id A user assigned session id for the current pipeline. - /// \param mem_sz Size of the memory set aside for the row caching (default=0 which means unlimited). + /// \param mem_sz Size of the memory set aside for the row caching (default=0 which means unlimited, + /// note that it might bring in the risk of running out of memory on the machine). /// \param spill Spill to disk if out of memory (default=False). /// \param hostname optional host name (default="127.0.0.1"). /// \param port optional port (default=50052). diff --git a/mindspore/ccsrc/minddata/dataset/include/datasets.h b/mindspore/ccsrc/minddata/dataset/include/datasets.h index cad905039d4..4bd06b968d4 100644 --- a/mindspore/ccsrc/minddata/dataset/include/datasets.h +++ b/mindspore/ccsrc/minddata/dataset/include/datasets.h @@ -1011,7 +1011,8 @@ std::shared_ptr VOC(const std::string &dataset_dir, const std::strin /// \brief Function the create a cache to be attached to a dataset /// \param id A user assigned session id for the current pipeline. -/// \param mem_sz Size of the memory set aside for the row caching (default=0 which means unlimited). +/// \param mem_sz Size of the memory set aside for the row caching (default=0 which means unlimited, +/// note that it might bring in the risk of running out of memory on the machine). /// \param spill Spill to disk if out of memory (default=False). /// \param hostname optional host name (default="127.0.0.1"). /// \param port optional port (default=50052). diff --git a/mindspore/dataset/engine/cache_client.py b/mindspore/dataset/engine/cache_client.py index 49aed36da29..84edecc0ed1 100644 --- a/mindspore/dataset/engine/cache_client.py +++ b/mindspore/dataset/engine/cache_client.py @@ -30,7 +30,8 @@ class DatasetCache: Args: session_id (int): A user assigned session id for the current pipeline. - size (int, optional): Size of the memory set aside for the row caching (default=0 which means unlimited). + size (int, optional): Size of the memory set aside for the row caching (default=0 which means unlimited, + note that it might bring in the risk of running out of memory on the machine). spilling (bool, optional): Whether or not spilling to disk if out of memory (default=False). hostname (str, optional): Host name (default="127.0.0.1"). port (int, optional): Port to connect to server (default=50052).