Appearance
Commands Reference
Here's a commands reference page for Vertex AI, formatted as markdown tables and code blocks:
Vertex AI Commands Reference
Vertex AI CLI Commands
| Command | Description |
|---|---|
gcloud ai-platform models list | List all models in your project |
gcloud ai-platform models create <model-name> --regions=<region> | Create a new model |
gcloud ai-platform versions create <version-name> --model=<model-name> --origin=<path-to-model> | Create a new version for a model |
gcloud ai-platform predict --model=<model-name> --version=<version-name> --json-instances=<path-to-json-file> | Make a prediction using a model |
gcloud ai-platform jobs submit training <job-name> --package-uris=<path-to-package> --region=<region> --python-version=<python-version> --runtime-version=<runtime-version> --job-dir=<job-dir> | Submit a training job |
gcloud ai-platform jobs list | List all training jobs in your project |
gcloud ai-platform datasets list | List all datasets in your project |
gcloud ai-platform datasets create <dataset-name> --description=<description> --metadata-schema-uri=<schema-uri> | Create a new dataset |
gcloud ai-platform datasets import --dataset=<dataset-name> --source-uri=<gcs-path> | Import data into a dataset |
Vertex AI Python SDK
python
from google.cloud import aiplatform
# Initialize the Vertex AI client
aiplatform.init(project="<your-project-id>", location="<region>")
# Create a dataset
dataset = aiplatform.Dataset.create(
display_name="<dataset-name>",
metadata_schema_uri="<schema-uri>",
gcs_source=["<gcs-path>"]
)
# Create a model
model = aiplatform.Model.upload(
display_name="<model-name>",
artifact_uri="<path-to-model-artifacts>",
serving_container_image_uri="<container-image>"
)
# Deploy a model
endpoint = model.deploy(
machine_type="<machine-type>",
min_replica_count=1,
max_replica_count=3
)
# Make a prediction
response = endpoint.predict(instances=[{"key": "value"}])Useful Snippets
Create a custom container image for model deployment
dockerfile
# Dockerfile
FROM tensorflow/serving:latest-gpu
COPY model/ /models/1Create a custom training container image
dockerfile
# Dockerfile
FROM gcr.io/cloud-aiplatform/training/tf-cpu.2-3:latest
COPY training_script.py /app/
ENTRYPOINT ["python", "/app/training_script.py"]Use Cloud Storage for model artifacts and training data
python
# Upload model artifacts to GCS
gcs_path = "gs://<your-bucket>/<path-to-model>"
model.upload(artifact_uri=gcs_path)
# Use GCS for training data
dataset.gcs_source = ["gs://<your-bucket>/<path-to-data>"]Monitor training jobs using the Vertex AI Dashboard
- Go to the Vertex AI Dashboard
- Select the training job you want to monitor
- View the job details, logs, and metrics
This reference covers the most common Vertex AI commands, SDK usage, and useful snippets. Remember to replace the placeholders (<...>) with your specific values.