From d6a07ee78ab83a423b6db208a616d75a2ae6fcfb Mon Sep 17 00:00:00 2001 From: eric80739 <68726577+eric80739@users.noreply.github.com> Date: Thu, 13 Feb 2025 12:38:56 +0800 Subject: [PATCH] Fix windows async np.save bug (#19218) Signed-off-by: eric80739 <68726577+eric80739@users.noreply.github.com> Signed-off-by: Glenn Jocher Co-authored-by: Glenn Jocher --- ultralytics/data/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ultralytics/data/utils.py b/ultralytics/data/utils.py index 3a75e5a1..20a7b98e 100644 --- a/ultralytics/data/utils.py +++ b/ultralytics/data/utils.py @@ -714,8 +714,8 @@ def save_dataset_cache_file(prefix, path, x, version): if is_dir_writeable(path.parent): if path.exists(): path.unlink() # remove *.cache file if exists - np.save(str(path), x) # save cache for next time - path.with_suffix(".cache.npy").rename(path) # remove .npy suffix + with open(str(path), "wb") as file: # context manager here fixes windows async np.save bug + np.save(file, x) LOGGER.info(f"{prefix}New cache created: {path}") else: LOGGER.warning(f"{prefix}WARNING ⚠️ Cache directory {path.parent} is not writeable, cache not saved.")