Get started with Google Cloud Platform as your CooperBench execution backend.
# Prerequisites: Install gcloud CLI first
# macOS: brew install google-cloud-sdk
# Linux: curl https://sdk.cloud.google.com | bash
# 1. Install GCP support
pip install 'cooperbench[gcp]'
# 2. Run configuration wizard
cooperbench config gcp
# 3. Run experiments
cooperbench run --backend gcp -s lite
cooperbench eval --backend gcp -n my-experimentThat's it! The wizard handles authentication, project setup, and validation automatically.
GCP provides several advantages over the default Modal backend:
- Scalability: Run hundreds of parallel evaluations using GCP Batch
- Cost Control: Use your own GCP credits and quotas
- Data Locality: Keep data in your GCP project
- Customization: Use custom VM images with pre-pulled Docker images
- No External Dependencies: No need for Modal account
Before running the configuration wizard, you need:
Sign up at cloud.google.com
- Free tier includes $300 credit
- Create a project at console.cloud.google.com/projectcreate
- Enable billing at console.cloud.google.com/billing
Install the Google Cloud SDK:
macOS:
brew install google-cloud-sdkLinux:
curl https://sdk.cloud.google.com | bashWindows: Download from cloud.google.com/sdk/docs/install
Verify installation:
gcloud versionRun the interactive setup wizard:
cooperbench config gcpThe wizard will:
- Check if gcloud CLI is installed
- Verify GCP Python dependencies
- Authenticate with your Google account (opens browser)
- Help you select project, region, and zone
- Validate API access
Your configuration is saved to:
- macOS:
~/Library/Application Support/cooperbench/config.json - Linux:
~/.config/cooperbench/config.json - Windows:
%APPDATA%\cooperbench\config.json
For faster setup without API validation:
cooperbench config gcp --skip-testsIf you prefer manual setup:
# Authenticate
gcloud auth login
gcloud auth application-default login
# Set project
export GOOGLE_CLOUD_PROJECT="your-project-id"
gcloud config set project your-project-idThe wizard will test access to these APIs and provide links if they need to be enabled:
-
Compute Engine API: For running VMs
-
Cloud Batch API: For parallel evaluation
-
Cloud Storage API: For storing results
Or enable all at once:
gcloud services enable compute.googleapis.com batch.googleapis.com storage.googleapis.com# Run with GCP backend
cooperbench run --backend gcp -s lite
# Run cooperative agents
cooperbench run \
--backend gcp \
--setting coop \
-s lite \
-m gemini/gemini-3-flash-preview \
--concurrency 10# Evaluate with GCP Batch
cooperbench eval --backend gcp -n my-experiment
# Large-scale evaluation with high parallelism
cooperbench eval \
--backend gcp \
-n my-experiment \
-r llama_index_task \
--concurrency 50# One-time setup
pip install 'cooperbench[gcp]'
cooperbench config gcp
# Run experiment
cooperbench run \
--backend gcp \
--setting coop \
-s lite \
-m gemini/gemini-3-flash-preview
# Evaluate results
cooperbench eval \
--backend gcp \
-n coop-lite-gemini-3-flash \
--concurrency 50
# Results saved to logs/This is optional and only useful for large-scale evaluations (100+ tasks).
By default, each evaluation VM pulls Docker images on-demand (~2-5 minutes startup). For large-scale runs, you can pre-build a VM image with all images cached.
When to use:
- Large evaluation runs (100+ tasks)
- Repeated evaluations where startup time matters
- When you want to minimize per-task costs
When NOT to use:
- Small runs (< 100 tasks) - not worth the build time
- First-time setup - stick with defaults
Build custom image:
# Set your project
export GOOGLE_CLOUD_PROJECT="your-project-id"
# Run the build script (takes ~30-60 minutes)
./scripts/build_gcp_vm_image.shThe script will:
- Create a temporary VM with Container-Optimized OS
- Pull all CooperBench Docker images
- Create a VM image snapshot (family:
cooperbench-eval) - Delete the temporary VM
Use the custom image:
from cooperbench.eval.backends.gcp import GCPBatchEvaluator
evaluator = GCPBatchEvaluator(
vm_image="cooperbench-eval" # Image family from build script
)Or via environment variable:
export COOPERBENCH_VM_IMAGE="cooperbench-eval"For multi-agent git collaboration, you can use a custom VPC network:
from cooperbench.agents.mini_swe_agent.environments.gcp import GCPEnvironment
env = GCPEnvironment(
image="python:3.11",
network="cooperbench-vpc" # Optional: Your VPC network
)Note: VPC networking is only required for git-based collaboration. For solo runs or Redis-based messaging, the default network works fine.
Choose regions based on your location for lower latency:
- US:
us-central1(Iowa),us-east1(South Carolina) - Europe:
europe-west1(Belgium),europe-west4(Netherlands) - Asia:
asia-east1(Taiwan),asia-southeast1(Singapore)
┌──────────────────────────────────────┐
│ CooperBench (Local) │
│ ↓ SSH via gcloud compute ssh │
├──────────────────────────────────────┤
│ GCP VM (Container-Optimized OS) │
│ ├─ Docker Container (Agent) │
│ │ └─ Agent code execution │
│ └─ Commands via docker exec │
└──────────────────────────────────────┘
Each agent runs in its own isolated GCP VM:
- Default: e2-medium (2 vCPU, 4GB RAM)
- Container-Optimized OS
- Docker container with task environment
- SSH access via gcloud CLI
┌────────────────────────────────────────┐
│ CooperBench (Local) │
│ ↓ Submit Batch job │
├────────────────────────────────────────┤
│ GCP Batch (Managed) │
│ ├─ Task 1 (VM 1) │
│ ├─ Task 2 (VM 1) │
│ ├─ Task 3 (VM 2) │
│ ├─ ... │
│ └─ Task N (VM M) │
│ ↓ Results │
├────────────────────────────────────────┤
│ GCS Bucket (cooperbench-eval-PROJECT) │
│ ├─ Job manifests │
│ ├─ Patches │
│ └─ Results │
└────────────────────────────────────────┘
GCP Batch automatically:
- Schedules tasks across VMs
- Handles VM lifecycle
- Stores results in GCS
- Cleans up resources
┌─────────────────────────────────────┐
│ Git Server VM (Debian) │
│ └─ git-daemon (port 9418) │
│ ↓ git:// protocol │
├─────────────────────────────────────┤
│ VPC Network or External IP │
│ ├→ Agent 1 (git push/pull/merge) │
│ ├→ Agent 2 (git push/pull/merge) │
│ └→ Agent N (git push/pull/merge) │
└─────────────────────────────────────┘
Optional git server for multi-agent collaboration (enabled with --git flag).
Using default settings in us-central1:
- VM Type: e2-medium (2 vCPU, 4GB RAM)
- Cost: ~$0.03/hour
- Typical Task: 5-30 minutes
- Per Task: $0.0025 - $0.015
- VM Type: 4 vCPU, 16GB RAM
- Cost: ~$0.15/hour per VM
- Parallelism: 50 VMs = ~$7.50/hour
- Typical Job: 10-30 minutes for 500 tasks
- Storage: ~$0.02/GB/month
- Operations: ~$0.005 per 10,000 operations
- Lifecycle: Auto-delete after 7 days
- Small run (10 tasks): $0.05 - $0.15
- Medium run (100 tasks): $0.50 - $1.50
- Large run (1000 tasks): $5.00 - $10.00
Note: GCP free tier includes $300 credit for new users.
Error: gcloud: command not found
Solution:
# macOS
brew install google-cloud-sdk
# Linux
curl https://sdk.cloud.google.com | bash
# Verify
gcloud versionError: Your default credentials were not found
Error: Could not automatically determine credentials
Solution:
You need both types of authentication:
# 1. Authenticate gcloud CLI
gcloud auth login
# 2. Set up Application Default Credentials (REQUIRED for Python SDK)
gcloud auth application-default loginWhy both?
gcloud auth login: For gcloud CLI commandsgcloud auth application-default login: For GCP Python libraries
The configuration wizard handles both automatically.
Error: API [compute.googleapis.com] not enabled
Solution:
Enable required APIs:
gcloud services enable \
compute.googleapis.com \
batch.googleapis.com \
storage.googleapis.comOr enable via console:
- https://console.cloud.google.com/apis/library/compute.googleapis.com
- https://console.cloud.google.com/apis/library/batch.googleapis.com
- https://console.cloud.google.com/apis/library/storage.googleapis.com
Error: The caller does not have permission
Solution:
- Ensure billing is enabled: https://console.cloud.google.com/billing
- Check IAM permissions: https://console.cloud.google.com/iam-admin/iam
- Required roles:
roles/compute.instanceAdmin.v1(Compute Instance Admin)roles/batch.jobsEditor(Batch Job Editor)roles/storage.admin(Storage Admin)
Error: Quota exceeded for quota metric 'cpus'
Solution:
- Check quotas: https://console.cloud.google.com/iam-admin/quotas
- Request quota increase (usually approved within hours)
- Reduce
--concurrencyparameter to use fewer VMs
Error: No module named 'google.cloud.compute'
Solution:
pip install 'cooperbench[gcp]'Or install packages individually:
pip install google-cloud-batch google-cloud-compute google-cloud-storageTo migrate from Modal to GCP:
# 1. Install GCP dependencies
pip install 'cooperbench[gcp]'
# 2. Configure GCP
cooperbench config gcp
# 3. Use --backend gcp instead of default modal
cooperbench run --backend gcp -s lite
cooperbench eval --backend gcp -n experiment-nameAll other commands and options remain the same!
| Feature | Modal (Default) | GCP |
|---|---|---|
| Setup | modal setup |
cooperbench config gcp |
| Account | Modal account | GCP account |
| Cost | Modal credits | Pay-as-you-go |
| Scale | Auto-scaling | Up to quotas |
| Free tier | Limited | $300 credit |
| Data location | External service | Your GCP project |
| Customization | Limited | Full control (VMs, networks, images) |
For issues or questions:
- GitHub Issues: https://github.com/cooperbench/CooperBench/issues
- GCP Documentation: https://cloud.google.com/docs
- CooperBench Docs: https://cooperbench.com