peft icon indicating copy to clipboard operation
peft copied to clipboard

I trained bloom7b model but for inference they give me error

Open imrankh46 opened this issue 3 years ago • 4 comments

This is the code

batch = tokenizer("Two things are infinite: ", return_tensors="pt")

with torch.cuda.amp.autocast():
    output_tokens = model.generate(**batch, max_new_tokens=50)

print("\n\n", tokenizer.decode(output_tokens[0], skip_special_tokens=True))

The error is

AttributeError: 'NoneType' object has no attribute 'device'

imrankh46 avatar Mar 19 '23 11:03 imrankh46

Please see https://github.com/huggingface/peft/issues/115, it's probably the same thing.

In my case (using alpaca model) I had to add a device_map parameter:

model = PeftModel.from_pretrained(
    model,
    alpaca_path,
    torch_dtype=torch.float16,
    device_map={"": 0}
)

paolorechia avatar Mar 19 '23 18:03 paolorechia

Please see #115, it's probably the same thing.

In my case (using alpaca model) I had to add a device_map parameter:

model = LlamaForCausalLM.from_pretrained(
    model_path,
    load_in_8bit=True,
    torch_dtype=torch.float16,
    device_map="auto",
)
model = PeftModel.from_pretrained(
    model,
    alpaca_path,
    torch_dtype=torch.float16,
    device_map={"": 0}
)

Thank you.

Please I m confused about the second one. You load two model. Which one should need to follow. !!

imrankh46 avatar Mar 20 '23 02:03 imrankh46

Sorry, should be the second one, I’ll edit the original comment.

paolorechia avatar Mar 20 '23 06:03 paolorechia

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

github-actions[bot] avatar Apr 18 '23 15:04 github-actions[bot]