It really depends on what you want to do with it, how you load it and what else you add.
For inference at half-precision (16 bit per param) a 7B param models should be 7 billion * 2 bytes per param or 14GB. If you load it at full precision it will be a lot more. For training or tuning there are a lot of other states added for the optimizer and gradients. For a detailed discussion of what all is required for tuning and how to use approaches to train at scale please see the paper "ZeRO: Memory Optimizations Toward Training Trillion Parameter Models" (https://arxiv.org/abs/1910.02054). Deepspeed is an implementation of ZeRO.
Additionally, for training you can use "LoRA: Low-Rank Adaptation of Large Language Models" (https://arxiv.org/abs/1910.02054) to reduce the amount of trainable parameters. As an example, on a 7B parameter model I get a reduction of 6.5 billion param values to about 540,000. PEFT is an implementation of LoRA.
As a reference, when I execute:
import torch
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("decapoda-research/llama-7b-hf", torch_dtype=torch.bfloat16)
model.cuda()
And I used nvidia-smi
to check memory, my A100 is using 13845MiB.
NOTE: If I do not use the torch_dtype=torch.bfloat16
then the GPU utilization is 26729MiB. Most folks inference at 16 bit or even 8 bit quantization. For example: https://huggingface.co/blog/hf-bitsandbytes-integration/