From 2fabeff14537fa8ced834d319af1fa2858709262 Mon Sep 17 00:00:00 2001 From: Leroll Date: Fri, 27 Oct 2023 11:20:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=86=E5=88=86utils=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/clean_memory.py | 10 ++++++++++ utils/load_google_drive.py | 14 -------------- 2 files changed, 10 insertions(+), 14 deletions(-) create mode 100644 utils/clean_memory.py diff --git a/utils/clean_memory.py b/utils/clean_memory.py new file mode 100644 index 0000000..9604805 --- /dev/null +++ b/utils/clean_memory.py @@ -0,0 +1,10 @@ +#--------------------------------- +# Function to clean RAM & vRAM +#--------------------------------- +import gc +import ctypes +import torch +def clean_memory(): + gc.collect() + ctypes.CDLL("libc.so.6").malloc_trim(0) + torch.cuda.empty_cache() \ No newline at end of file diff --git a/utils/load_google_drive.py b/utils/load_google_drive.py index f955869..752fab6 100644 --- a/utils/load_google_drive.py +++ b/utils/load_google_drive.py @@ -1,5 +1,3 @@ - - #--------------------------------- # colab 加载 google drive #--------------------------------- @@ -16,15 +14,3 @@ def load_google_drive(path='/'): os.chdir(root_path + path) print(f"cwd: {os.getcwd()}") - - -#--------------------------------- -# Function to clean RAM & vRAM -#--------------------------------- -import gc -import ctypes -import torch -def clean_memory(): - gc.collect() - ctypes.CDLL("libc.so.6").malloc_trim(0) - torch.cuda.empty_cache() \ No newline at end of file