Skip to content

Ask AI

Powered by Blaze

Answers come from E2E Cloud documentation. AI can make mistakes.

Deploy Gemma with vLLM

View as Markdown

Deploy Google Gemma on vLLM and send it a chat request. The examples use the 2B instruction-tuned model, google/gemma-2b-it. The same steps work for google/gemma-2b, google/gemma-7b, and google/gemma-7b-it. The models whose names end in -it answer chat requests. The endpoint downloads the model from Hugging Face when it starts, so there is nothing to upload first.

Gemma is a gated model, so first accept Google’s terms on its Hugging Face page, google/gemma-2b-it, and wait until access is granted. The endpoint reads the model with a Hugging Face access token with Read scope from that account, saved as a Hugging Face integration.

Then create a vLLM endpoint that downloads the model from Hugging Face, with these values. Leave every other setting at its default. For what each setting does, see Deploy a model from Hugging Face.

Field Value
Framework on Choose Framework vLLM
Endpoint Name gemma-2b-it, or a name of your own
Download Type Download from Huggingface
HuggingFace Model google/gemma-2b-it
HF Token Integration Your Hugging Face integration
Model Cache Storage Local drive, 100 GB
Select Computing Resource GPU tab, any card, and a size under Configuration. The 2B model needs about 5 GB of GPU memory; a 7B model needs about 17 GB.
Active Worker and Max Workers 1 and 1

Select Deploy Endpoint. The state reads Deploying while the worker downloads and loads the model, and Running once it can answer, usually within 10 to 15 minutes.

On the endpoint’s details page, select API Request. In Sample API Request, choose a token under Auth token, or select Generate Token to make one, and copy the Root Endpoint. Set both as variables in your terminal, where <root-endpoint> is the address you copied and <auth-token> is the token:

export ROOT_ENDPOINT="<root-endpoint>"
export AUTH_TOKEN="<auth-token>"

The model name is the Hugging Face ID you deployed:

curl -X POST "$ROOT_ENDPOINT/v1/chat/completions" \
-H "Authorization: Bearer $AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"model": "google/gemma-2b-it",
"messages": [
{"role": "user", "content": "What is artificial intelligence?"}
],
"max_tokens": 100,
"temperature": 0.7,
"top_p": 0.9
}'

The reply is a JSON document in the OpenAI chat format, with the answer in choices[0].message.content. For google/gemma-2b and google/gemma-7b, send a prompt to /v1/completions instead, and read the text in choices[0].text. If the endpoint stays in Deploying, read Worker Logs on the Events & Logs tab.

For fine-tuned weights, or to load the model from storage you control, upload the files to a Model Repository. Then create the endpoint the same way with two changes: set Download Type to Link with Model Repository and choose your repository, and set Model Type to Full Model (for standard inference). Requests then name the model /mnt/models. See Upload model files and Deploy a model from Model Repository.

Gemma 2B is small enough to run on any GPU card. That makes it a cheap model for trying out autoscaling and scale to zero before you move a larger model onto the same settings.

Was this page helpful?