[AUTOMATED] Model Memory Requirements

#12
by model-sizer-bot - opened

Model Memory Requirements

You will need about {'dtype': 'float16/bfloat16', 'Largest Layer or Residual Group': '2.72 GB', 'Total Size': '87.25 GB', 'Training using Adam': '348.99 GB'} VRAM to load this model for inference, and {'dtype': 'int4', 'Largest Layer or Residual Group': '696.02 MB', 'Total Size': '21.81 GB', 'Training using Adam': '87.25 GB'} VRAM to train it using Adam.

These calculations were measured from the Model Memory Utility Space on the Hub.

The minimum recommended vRAM needed for this model assumes using Accelerate or device_map="auto" and is denoted by the size of the "largest layer".
When performing inference, expect to add up to an additional 20% to this, as found by EleutherAI. More tests will be performed in the future to get a more accurate benchmark for each model.

When training with Adam, you can expect roughly 4x the reported results to be used. (1x for the model, 1x for the gradients, and 2x for the optimizer).

Results:

dtype Largest Layer or Residual Group Total Size Training using Adam
float32 5.44 GB 174.49 GB 697.97 GB
float16/bfloat16 2.72 GB 87.25 GB 348.99 GB
int8 1.36 GB 43.62 GB 174.49 GB
int4 696.02 MB 21.81 GB 87.25 GB

When I run this model using vllm and the following command - docker run --runtime nvidia --gpus all --restart always -p 8000:8000 -e HF_TOKEN='HUGGINGFACE_TOKEN' --ipc=host -d vllm/vllm-openai:latest --served-model-name mpt-7b-chat --model NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO --host 0.0.0.0 on a newly created GCP instance equipped with 4 NVIDIA A100 40GB GPUs, I am getting a torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 1.75 GiB. GPU 0 has a total capacty of 39.39 GiB of which 575.94 MiB is free. Process 45100 has 38.82 GiB memory in use. Of the allocated memory 38.18 GiB is allocated by PyTorch, and 14.34 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF error. I ran nvidia-smi and there are no processes currently running and the GPU/memory utilization is also currently 0. Has anybody else encountered this and is there a good fix for this?

Sign up or log in to comment