From 04dc29e48bb3b9a2a7c0cff8ba1047cb13acd5cc Mon Sep 17 00:00:00 2001 From: Megvii Engine Team Date: Mon, 22 May 2023 17:37:07 +0800 Subject: [PATCH] fix(imperative/data): fix dataloader memory check warning GitOrigin-RevId: e0f62f83b86b47ba7bdef9ac102e777a4fc3faa2 --- imperative/python/megengine/data/dataloader.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/imperative/python/megengine/data/dataloader.py b/imperative/python/megengine/data/dataloader.py index 70aea9e75..766342198 100644 --- a/imperative/python/megengine/data/dataloader.py +++ b/imperative/python/megengine/data/dataloader.py @@ -178,12 +178,9 @@ class DataLoader: main_memory = psutil.Process(os.getpid()).memory_info().rss / 1024 / 1024 / 1024 total_memory = (self.num_workers + 1) * main_memory - current_memory = ( - int(os.popen("cat /sys/fs/cgroup/memory/memory.limit_in_bytes").read()) - / 1024 - / 1024 - / 1024 - ) + limit_in_bytes = os.popen("cat /sys/fs/cgroup/memory/memory.limit_in_bytes") + current_memory = int(limit_in_bytes.read()) / 1024 / 1024 / 1024 + limit_in_bytes.close() if current_memory < total_memory: logger.warning( "Each worker need to read the shared meta-data, which will be increasing the reference count." -- GitLab