You are trying to offload the whole model to the disk. Please use the disk_offload
function instead.
#2726
Closed
2 of 4 tasks
System Info
Information
Tasks
no_trainer
script in theexamples
folder of thetransformers
repo (such asrun_no_trainer_glue.py
)Reproduction
import transformers
from transformers import AutoModelForCausalLM
import torch
model_id = "meta-llama/Meta-Llama-3-8B-Instruct"
model = AutoModelForCausalLM.from_pretrained("meta-llama/Meta-Llama-3-8B-Instruct", torch_dtype=torch.float16, low_cpu_mem_usage = True).cpu()
from accelerate import disk_offload
disk_offload(model=model, offload_dir="alpha")
pipeline = transformers.pipeline(
"text-generation",
model=model_id,
model_kwargs={"torch_dtype": torch.bfloat16},
device_map="auto",
)
messages = [
{"role": "system", "content": "You are a pirate chatbot who always responds in pirate speak!"},
{"role": "user", "content": "Who are you?"},
]
prompt = pipeline.tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True
)
terminators = [
pipeline.tokenizer.eos_token_id,
pipeline.tokenizer.convert_tokens_to_ids("<|eot_id|>")
]
outputs = pipeline(
prompt,
max_new_tokens=256,
eos_token_id=terminators,
do_sample=True,
temperature=0.6,
top_p=0.9,
)
print(outputs[0]["generated_text"][len(prompt):])
Expected behavior
I am running the following code and it gives the following error:
""You are trying to offload the whole model to the disk. Please use the
disk_offload
function instead.""for solving the error i added the following code (so the above given code is after the addition to solve the previous issue):
model = AutoModelForCausalLM.from_pretrained("meta-llama/Meta-Llama-3-8B-Instruct", torch_dtype=torch.float16, low_cpu_mem_usage = True).cpu()
from accelerate import disk_offload
disk_offload(model=model, offload_dir="alpha")
but when i add this code in the my original one and try to run it that after some time of running then the jupyter kernel crashes. can you please also tell me that what is this ""offload_dir="alpha"". Can you please explain it to me
The text was updated successfully, but these errors were encountered: