Skip to content

Instantly share code, notes, and snippets.

@S1ro1
Created May 2, 2025 17:22
Show Gist options
  • Save S1ro1/5f53cf5befba4efdbd072fc59eba7b2a to your computer and use it in GitHub Desktop.
Save S1ro1/5f53cf5befba4efdbd072fc59eba7b2a to your computer and use it in GitHub Desktop.
from transformers import AutoModelForCausalLM
from accelerate import Accelerator
import torch
torch.cuda.memory._record_memory_history()
model_id = "meta-llama/Meta-Llama-3-8B-Instruct"
accelerator = Accelerator()
model = AutoModelForCausalLM.from_pretrained(model_id)
optimizer = torch.optim.AdamW(model.parameters(), lr=1e-5)
model, optimizer = accelerator.prepare(model, optimizer)
print(model)
torch.cuda.memory._dump_snapshot("pre-patch.pkl")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment