alpaca-lora
alpaca-lora copied to clipboard
RuntimeError:expected scalar type Half but found Float
I have ran the script of finetune.py on my device, which has two V100 16G gpus, but encounter the problem of RuntimeError: expected scalar type Half but found Float. Does anyone meet the similar problem? Could anyone help me with this? Thanks a lot.
Here are my pacakage version: transformers: 4.28.0.dev0 peft: 0.2.0 bitsandbtyes: 0.37.1 torch: 1.13.1
I am also getting same exception. Did you get how to resolve this?
add with torch.autocast("cuda"): and it will work.
with torch.autocast("cuda"):
inputs = tokenizer(prompt, return_tensors="pt")
input_ids = inputs["input_ids"].to("cuda")
with torch.no_grad():
generation_output = model.generate(
input_ids=input_ids,
generation_config=generation_config,
return_dict_in_generate=True,
output_scores=True,
max_new_tokens=100
)
for s in generation_output.sequences:
output = tokenizer.decode(s)
print("Response:", output.split("### Response:")[1].strip())
return output.split("### Response:")[1].strip()
the same issue too
add with torch.autocast("cuda"): and it will work.
with torch.autocast("cuda"): inputs = tokenizer(prompt, return_tensors="pt") input_ids = inputs["input_ids"].to("cuda") with torch.no_grad(): generation_output = model.generate( input_ids=input_ids, generation_config=generation_config, return_dict_in_generate=True, output_scores=True, max_new_tokens=100 ) for s in generation_output.sequences: output = tokenizer.decode(s) print("Response:", output.split("### Response:")[1].strip()) return output.split("### Response:")[1].strip()
where do these code to place? please
I have solved the problem by add "with torch.autocast("cuda"): " before trainer.train(***) in fineturne.py. Good luck!
these solutions not working for me
Traceback (most recent call last):
File "alpaca_fine_tuning.py", line 259, in
with torch.autocast("cuda"): trainer.train() @xllau do you mean like this?