How to Clear CUDA cache for loaded models? #1371
-
Is there a convenient way to clear CUDA memory when you load a model? I can run it once, but if I rerun the command it seemingly doesn't replace the model in memory it tries to add on.. import whisper
model_size = "large-v2" # options are "tiny", "base", "small", "medium", "large-v1", "large-v2", "large"
model = whisper.load_model(model_size)
My thought was to try and empty cache but that doesn't seem to make a difference? import torch
torch.cuda.empty_cache()
torch.cuda.mem_get_info()
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 9 replies
-
Hey, have you tried rerunning the code, after emptying the cache? Ignoring the mem_get_info() |
Beta Was this translation helpful? Give feedback.
-
Thanks @Wholesomebruh, yes that is precisely my confusion is that I only get that error when I rerun the model_load.. as if it's not overwriting in CUDA memory or clearing cache, it's strange! |
Beta Was this translation helpful? Give feedback.
-
why do you want to reload the model? |
Beta Was this translation helpful? Give feedback.
-
maybe I'm just unclear on how much CUDA memory is really needed for the large + models.. I see the Required VRAM referenced here but no clear mention of CUDA https://github.com/openai/whisper#available-models-and-languages |
Beta Was this translation helpful? Give feedback.
in that case, follow #1313