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 use gpu to accelerate inference? #77

Open
13990008036 opened this issue Aug 6, 2023 · 1 comment
Open

How to use gpu to accelerate inference? #77

13990008036 opened this issue Aug 6, 2023 · 1 comment

Comments

@13990008036
Copy link

How to use gpu to accelerate inference? I deployed it exactly according to howtouse on GitHub, but it was still very slow and did not use gpu for inference

@13990008036
Copy link
Author

import torch
from transformers import AutoTokenizer, AutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("Salesforce/codegen25-7b-mono", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("Salesforce/codegen25-7b-mono")
inputs = tokenizer("# this function prints hello world", return_tensors="pt")
sample = model.generate(**inputs, max_length=128)
print(tokenizer.decode(sample[0]))

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