Out of memory error with anemoi
I try to run this code: https://huggingface.co/ecmwf/aifs-single-1.0/blob/main/run_AIFS_v1.ipynb
I got out of memory error and I tried many fixes including this:
import os
os.environ['PYTORCH_CUDA_ALLOC_CONF']='expandable_segments:True' (This one is not supported by the GPU so I did not use it)
os.environ['ANEMOI_INFERENCE_NUM_CHUNKS']='16' (for this one I used 10 because it gave the best memory output).
I still get this error message. how can I fix it?
torch.OutOfMemoryError: CUDA out of memory. Tried to allocate 636.00 MiB. GPU 0 has a total capacity of 20.00 GiB of which 656.50 MiB is free. Including non-PyTorch memory, this process has 17.33 GiB memory in use. Of the allocated memory 16.25 GiB is allocated by PyTorch, and 943.19 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True to avoid fragmentation. See documentation for Memory Management (https://pytorch.org/docs/stable/notes/cuda.html#environment-variables)
I tried this as well and it still does not work. This is the bit where the code crashes:
for lead in [1,2,3,4,5,6]:
with torch.no_grad():
torch.cuda.empty_cache()
for state in runner.run(input_state=input_state, lead_time=lead):
torch.cuda.empty_cache()
print_state(state)
Hi,
The AIFS-v1 can be quite a memory intensive model, we have found that 24Gb is the absolute lowest we can push it.
By the looks of the error, you do not have enough GPU memory to fit the model.