If you are using the Hugging Face transformers library, you can leverage Accelerate's Big Model Inference directly within the from_pretrained constructor.
To enable it, pass device_map="auto". You can also pass torch_dtype (e.g., torch.float16) to reduce memory usage by loading the model in lower precision.
from transformers import AutoModelForSeq2SeqLM
import torch
# Basic Big Model Inference
model = AutoModelForSeq2SeqLM.from_pretrained("bigscience/T0pp", device_map="auto")
# Big Model Inference with lower precision to save more memory
model = AutoModelForSeq2SeqLM.from_pretrained(
"bigscience/T0pp",
device_map="auto",
torch_dtype=torch.float16
)