Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to run fnlp/moss-base-7b in multi gpus #369

Open
FakerYFX opened this issue Sep 4, 2023 · 0 comments
Open

how to run fnlp/moss-base-7b in multi gpus #369

FakerYFX opened this issue Sep 4, 2023 · 0 comments

Comments

@FakerYFX
Copy link

FakerYFX commented Sep 4, 2023

how to run fnlp/moss-base-7b in multi gpus, i use this way:

from transformers import AutoTokenizer, AutoModelForCausalLM
os.environ['CUDA_VISIBLE_DEVICES'] = "0,1"
tokenizer = AutoTokenizer.from_pretrained("fnlp/moss-base-7b", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("fnlp/moss-base-7b", trust_remote_code=True).cuda()
model = model.eval()
inputs = tokenizer(["流浪地球的导演是"], return_tensors="pt")
for k,v in inputs.items():
inputs[k] = v.cuda()
outputs = model.generate(**inputs, do_sample=True, temperature=0.8, top_p=0.8, repetition_penalty=1.1, max_new_tokens=256)
response = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
print(response)

however it didn't use. Could you please give me some advice?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant