Google Cloud
NIM supports deployment on Google Cloud Platform (GCP) through two approaches:
- Google Kubernetes Engine (GKE): Self-managed Kubernetes deployment using Helm charts with complete control over infrastructure, GPU node pools, and persistent storage.
- Vertex AI: Fully managed ML platform with built-in load balancing, auto-scaling, and automatic authentication.
Both deployment strategies can use Google Cloud Storage (GCS) as the backend for model storage. The following table compares GKE and Vertex AI across common deployment considerations:
GKE Deployment
To deploy NIM LLM on Google Kubernetes Engine (GKE), create a GKE cluster with GPU-enabled node pools and prepare your Google Cloud environment for NIM LLM workloads. This section covers prerequisites, cluster creation, and initial setup.
Prerequisites
Before proceeding, ensure you have the following:
- Google Cloud Project: A GCP project with permissions for creating GKE clusters and GPU node pools
- GPU Quota: Sufficient GPU quota in your target region for your chosen GPU type (check in Cloud Console under Quotas)
- Required Tools:
- Google Cloud SDK
kubectl(install withgcloud components install kubectl)- Helm 3
gke-gcloud-auth-plugin
Initial Setup
Complete the following setup steps before you deploy NIM on GKE.
Authenticate and Enable APIs
Authenticate to Google Cloud, select your project, and enable the required services.
-
Authenticate with the Google Cloud CLI:
-
Set the active project:
-
Authenticate Application Default Credentials:
-
Enable the required APIs:
Set Environment Variables
Set environment variables for your GCP project, region, and NIM deployment. Update the placeholder values with your own:
Create GKE Cluster
Create the network and GKE control plane before you add a GPU node pool for NIM LLM workloads.
Create VPC Network
Create a dedicated VPC network for the GKE cluster:
Create Cluster
Create the GKE cluster in that network:
Add GPU Node Pool
NIM requires GPU nodes. First, check available GPU types in your zone:
Select a GPU type based on your model size:
Create the GPU node pool:
Setting gpu-driver-version=latest triggers automatic NVIDIA driver installation, eliminating the need for a separate DaemonSet.
Get Cluster Credentials
This command fetches the cluster endpoint and authentication credentials from GCP and writes them to your local kubeconfig file (~/.kube/config).
Afterward, kubectl commands target your new cluster.
Verify GPU Availability
You should observe at least one node with a GPU count of 1.
Create Secrets
Create the secrets that the deployment uses to pull the container image and access the model repository.
NGC Registry Secret
Create the NGC secrets for image pulls and model access:
-
Create the
ngc-secretregistry secret. -
Create the
ngc-apisecret that stores the NGC API key.
Hugging Face Token for Gated Models
Optional: If you are deploying a gated Hugging Face model, create an additional secret with your Hugging Face token. NGC models and ungated public Hugging Face models do not require a token.
Reference in Helm with model.hfTokenSecret: hf-token.
Helm Deployment
Create one of the following values files based on whether you are deploying a model-specific image, a generic image, or a model stored in GCS.
Model-Specific NIM
Use this option for NIM images built for a specific model, such as Llama 3.1 8B Instruct.
Create values-gke-prebuilt.yaml:
Model-Free NIM with GCS Storage
Use this option to serve custom or fine-tuned models stored in GCS with standard directory structure.
Create values-gke-model-free.yaml:
For NIM_MODEL_PATH with GCS, ensure your model is uploaded with standard directory structure, not percent-encoded keys. Refer to GCS Use Cases: Model-Free vs Repository Override for upload instructions.
GKE pods using Workload Identity or node service accounts with GCS access do not require explicit credentials. For local testing with a service account key, add:
The imagePullSecrets examples above list ngc-secret, which only authenticates to nvcr.io. When you deploy an image stored in Artifact Registry, the nodes also need pull access to ${GCP_REGION}-docker.pkg.dev. Use one of the following, in addition to ngc-secret:
-
Grant the node service account
roles/artifactregistry.reader(recommended for production, no token expiry). -
Create an
ar-pulldocker-registrysecret that uses a short-lived access token, then add it toimagePullSecrets:The access token is valid for about one hour, so prefer
roles/artifactregistry.readeron the node service account for long-running deployments.
Install the Helm Release
Set the release name and install the Helm release:
For the generic (model-free) image, use -f values-gke-model-free.yaml instead.
Monitor Deployment
Monitor the deployment:
Wait until the pod status is Running and ready.
Configure Network Access
GKE often blocks non-standard ports. Create a firewall rule:
GKE automatically provisions firewall rules for type: LoadBalancer services in most clusters, so this rule is usually not needed. Create allow-nim-8000 manually only if your environment prevents GKE from auto-creating load balancer firewall rules (for example, restricted IAM permissions, a shared VPC, or an org firewall policy). In that case, the LoadBalancer IP is assigned but traffic to port 8000 is dropped, so the health check and chat completion tests appear to hang. The integration-test script always creates this rule so runs work regardless of environment.
Test the GKE Deployment
Use the following steps to get the service endpoint and verify that the deployment responds to requests.
Get the Endpoint
For LoadBalancer service, wait for the external IP to be assigned:
For ClusterIP service, use port-forward:
Health Check
Confirm the NIM API is up and ready:
Test Chat Completions
Send a test chat completion request and verify inference is working:
The model field must match the served model name, which is the value of NIM_SERVED_MODEL_NAME or the image’s com.nvidia.nim.model label. Replace meta/llama3.1-8b-instruct with the name your image serves. A mismatched name returns a model not found error.
Run Helm Tests
Run the suite of Helm chart tests for your release:
View Logs
View real-time logs for your deployed NIM pods:
GKE Model Sourcing Options
NIM on GKE supports multiple model sources:
GKE Authentication
GKE supports multiple authentication methods for GCS access:
Workload Identity is the recommended approach for production GKE deployments. It eliminates the need for credential files in pods.
GKE Cleanup
Use these steps to remove the deployment and its GKE resources.
Uninstall Helm Release
Uninstall the Helm release:
Delete PVCs
Delete the persistent volume claims:
Delete GKE Cluster
Delete the GKE cluster:
Optional: Delete Firewall Rule
Delete the firewall rule if you created it earlier:
Delete VPC Network
Delete the VPC network:
Vertex AI Deployment
Vertex AI is a fully managed ML platform that eliminates the need for infrastructure management. It provides built-in load balancing, auto-scaling, and authentication through Application Default Credentials (ADC).
Key Constraints
Vertex AI has specific requirements that differ from GKE deployments:
Prerequisites
Before proceeding, ensure you have the following:
- GCP Project: A project with permissions for Vertex AI, Artifact Registry, and GCS
- GPU Quota: Sufficient GPU quota in your region for your chosen GPU type (check in Cloud Console under Quotas)
- Required Tools:
- Google Cloud SDK
- Docker (for pushing images to Artifact Registry)
- Optional:
pip install google-cloud-aiplatformfor Python SDK access
Initial Setup
Complete the following setup steps before you deploy NIM on Vertex AI.
Authenticate and Enable APIs
Authenticate to Google Cloud, select your project, and enable the required services.
-
Authenticate with the Google Cloud CLI:
-
Set the active project:
-
Authenticate Application Default Credentials:
-
Enable the required APIs:
The API must be enabled before proceeding. If you encounter errors indicating that the API is disabled, run the gcloud services enable commands and wait one to two minutes.
Set Environment Variables
Set the environment variables for your Google Cloud resources:
Create GCS Bucket and Grant Access
Create the GCS bucket and grant Vertex AI permission to read from it.
-
Create the bucket:
-
Create the Vertex AI service identity if this is your first Vertex AI deployment in the project:
-
Get the project number:
-
Grant the Vertex AI service agent access to the bucket:
If deployment fails with a permission error for custom-online-prediction@TENANT_ID-tp.iam.gserviceaccount.com, extract the TENANT_ID from the error and grant access:
Create Artifact Registry Repository
Create the Artifact Registry repository, grant Vertex AI access, and configure Docker authentication.
-
Create the repository:
-
Get the project number:
-
Grant the Vertex AI service agent read access to Artifact Registry:
-
Configure Docker authentication for Artifact Registry:
Push NIM Image to Artifact Registry
Vertex AI cannot pull images from external registries. You must re-tag and push the NIM image to Artifact Registry:
-
Log in to NGC:
-
Pull the NIM image from NGC:
-
Re-tag the image for Artifact Registry:
-
Push the image to Artifact Registry:
Upload Model to GCS
GCS is optional (required only for GCS-backed artifacts or used as a mirror). By default, NIM downloads model artifacts at runtime from the NGC or Hugging Face image manifest given outbound network access. Upload artifacts to GCS only when they are GCS-backed (NIM_REPOSITORY_OVERRIDE or NIM_MODEL_PATH=gs://) or used as an optional mirror. Refer to Model Storage Options for upload instructions.
Register Model in Vertex AI
Register the NIM container as a Vertex AI model and set the environment variables that tell the container how to load its model artifacts. By default, the NGC or Hugging Face image manifest downloads artifacts at runtime given outbound network access, so no GCS upload is required. Choose the command that matches your model source: the NGC or Hugging Face default, or a GCS-backed source you prepared earlier.
NIM downloads its own model artifacts at container startup; it does not use the Vertex AI managed model-artifact mechanism. As a result, a model-specific (NGC) image can serve without any GCS upload when the Vertex AI endpoint has outbound internet access. The image relies on the manifest baked into the image (set NGC_API_KEY for NGC pulls or HF_TOKEN for gated Hugging Face pulls). Use a GCS source (NIM_REPOSITORY_OVERRIDE=gs://... or NIM_MODEL_PATH=gs://...) for air-gapped endpoints, latency, or to avoid runtime NGC dependence. The NIM_SERVED_MODEL_NAME value (and the "model" field in requests) must match the name baked into the image (com.nvidia.nim.model docker label) for model-specific images.
For an NGC or Hugging Face Image (Default)
Use this option for a model-specific image that downloads its artifacts at startup from NGC or Hugging Face. The endpoint needs outbound internet access, and no GCS bucket is required. Pass NGC_API_KEY for NGC pulls (add HF_TOKEN for gated Hugging Face models) and set NIM_SERVED_MODEL_NAME to the name the image serves:
Append optional variables to --container-env-vars as a comma-separated list when you need them, for example NIM_MODEL_PATH=... for a model-free image, NIM_REPOSITORY_OVERRIDE=gs://... for an NGC GCS mirror, or HF_TOKEN=... for gated Hugging Face models.
For NIM_REPOSITORY_OVERRIDE
Use this option if you mirrored an NGC model to GCS with percent-encoded object keys and want NIM to rewrite the built-in manifest to gs:// paths at runtime:
For NIM_MODEL_PATH
Use this option if you uploaded the model to GCS with its standard directory structure and want NIM to load it directly from that path:
For NIM_MODEL_PATH, use a generic model-free image. Model-specific images might fail with “Model URI missing version suffix”.
Create Endpoint and Deploy
NIM LLM requires a GPU driver that supports CUDA 13.0 or later. If the default GPU driver on Vertex AI is too old for your deployment, startup can fail with RuntimeError: The NVIDIA driver on your system is too old.
For this reason, the recommended default is to deploy with gcloud beta ai endpoints deploy-model and pin --min-gpu-driver-version=580.65.06. The GA gcloud ai endpoints deploy-model command does not support this flag, so use it only when you have confirmed the default Vertex AI driver is new enough.
To create a Vertex AI endpoint and deploy your NIM model, complete the following steps in the same shell session:
-
Create the endpoint:
-
Get the endpoint and model IDs:
-
Deploy the model to the endpoint. The recommended command uses the beta track with
--min-gpu-driver-version=580.65.06because NIM LLM requires a driver that supports CUDA 13.0 or later. The default Vertex AI driver is often too old:If you have confirmed that the default Vertex AI GPU driver already supports CUDA 13.0 or later, you can use the GA command, which does not accept
--min-gpu-driver-version:
Test the Vertex AI Endpoint
Vertex AI endpoints are accessed through the Vertex AI REST API using rawPredict:
The model field must match the served model name, which is the value of NIM_SERVED_MODEL_NAME or the image’s com.nvidia.nim.model label. Replace meta/llama3.1-8b-instruct with the name your image serves.
Vertex AI Cleanup
Use this section to remove the deployed Vertex AI resources and related artifacts.
Undeploy and Delete Resources
To programmatically clean up your deployed Vertex AI resources and remove related artifacts, you can use the following commands:
Delete Infrastructure
Optional: To fully clean up your project resources—including removing the Artifact Registry repository and deleting all objects and the bucket itself from Google Cloud Storage—run the following commands:
GCS Use Cases: Model-Free vs Repository Override
There are two distinct ways to serve models from GCS. They use different GCS key formats, different upload workflows, and serve fundamentally different purposes.
NIM_REPOSITORY_OVERRIDE (NGC Mirror)
Scenario: You have an NGC model with a built-in manifest containing BLAKE3 checksums, and you want to serve it from GCS instead of NGC at runtime. This is not model-free mode. The container ships with a model-specific manifest.
-
Upload: Use the
upload-to-gcs.shscript. The script percent-encodes each NGC URI (without thengc://scheme) into a flat GCS key, and uploads the files by usinggsutil. -
GCS key format: Flat percent-encoded keys. Each file becomes a single object with no directory structure:
-
Download: At runtime, NIM LLM reads the built-in manifest (still has
ngc://URIs), seesNIM_REPOSITORY_OVERRIDE=gs://bucket, percent-encodes each URI, rewrites it togs://bucket/<encoded-key>, downloads from GCS, and verifies BLAKE3 checksums from the original manifest. -
When to use: Air-gapped environments with no NGC access at runtime, enterprise GCS mirrors of NGC models, and latency-sensitive deployments where GCS is closer than NGC.
Step 1: Download model to local cache
First, download the model files from NGC to your local cache:
Step 2: Upload with percent encoding
Create an upload-to-gcs.sh script that handles percent-encoding:
Run the script:
The MODEL_PREFIX must not include the ngc:// scheme. nim-sdk strips the scheme
internally when computing GCS keys, so including it in the upload produces keys that
do not match what the download expects. To find the correct prefix, check the file URIs
in the container’s built-in manifest and strip ngc:// from the front.
Run NIM:
For production deployments, use Workload Identity (GKE) or Application Default Credentials (ADC) instead of mounting service account key files. The example below uses a mounted key for local testing only.
NIM_MODEL_PATH (Model-Free)
Scenario: You have your own fine-tuned model already in GCS with normal directory structure. The model was never on NGC. This is model-free mode. The container is generic and serves whatever model you point it to.
This approach has the following characteristics:
-
Upload: Use any GCS tool with no special encoding:
-
GCS key format: Standard directory-style keys, exactly as uploaded:
-
Manifest generation: At startup, NIM LLM dynamically generates a model manifest based on the specified model.
-
When to use: Customer fine-tuned models in GCS, no NGC involvement, models uploaded with standard directory structure.
URI Format: gs://{bucket}/{path}/{model-name}
Example URI: gs://my-bucket/my-org/my-fine-tuned-model
Upload your model:
Run NIM:
For GKE or Vertex AI (using ADC, no credentials file needed):
Comparison
The following table compares the two GCS-based model-loading approaches and highlights when to use each one.
These two approaches use incompatible key formats. Files uploaded with percent-encoding cannot be consumed by NIM_MODEL_PATH=gs:// (expects directory structure), and vice versa.
Authentication
GCS supports Application Default Credentials (ADC). Authentication is resolved in the following order:
GOOGLE_APPLICATION_CREDENTIALSenvironment variable pointing to a service account key file- Vertex AI managed environment credentials
- Google Compute Engine (GCE) metadata service
- Cloud Run environment
- gcloud CLI user credentials
Troubleshooting
Use the following troubleshooting tables to diagnose common deployment issues on GKE and Vertex AI.
GKE Issues
The following table lists common GKE deployment issues and recommended resolutions.
Vertex AI Issues
The following table lists common Vertex AI deployment issues and recommended resolutions.
For additional troubleshooting, refer to Support and FAQ.
References
Refer to the following Google Cloud documentation for more information: