
Tech Tip: Check AWS GPU Quotas with boto3
Before running terraform apply for a GPU workload on AWS EC2, check your regional vCPU quotas first. On many AWS accounts, GPU instance buckets default to 0 vCPUs, which causes deployments to fail immediately at instance launch with VcpuLimitExceeded.
How AWS Counts GPU Quotas
AWS does not cap GPU instances by GPU count—it caps them by total running vCPUs per instance-family bucket and purchase option in each Region:
- Bucket grouping: Instances like
g5(NVIDIA A10G) andg6e(NVIDIA L40S) draw from the G and VT vCPU pool. For example, ag6e.xlargeuses 4 vCPUs, while ag6e.2xlargeuses 8 vCPUs. - On-Demand vs. Spot are separate: Having On-Demand quota does not grant Spot quota, and vice versa.
- Region-specific: Quotas apply per AWS Region. Checking
eu-central-1tells you nothing aboutus-west-2.
Check Your GPU Quotas with Python (boto3)
Instead of clicking through the Service Quotas console or memorising quota codes, query the service-quotas API directly with boto3 in your target Region:
Python
import boto3
client = boto3.client("service-quotas", region_name="us-west-2")
paginator = client.get_paginator("list_service_quotas")
for page in paginator.paginate(ServiceCode="ec2"):
for q in page.get("Quotas", []):
name = q.get("QuotaName", "")
if "G and VT" in name or "Spot G and VT" in name:
print(
f"{q['QuotaCode']} | {name} | "
f"Value={q['Value']} | Adjustable={q.get('Adjustable')}"
)
Example output:
Plain text
L-DB2E81BA | Running On-Demand G and VT instances | Value=768.0 | Adjustable=True
L-3819A6DF | All G and VT Spot Instance Requests | Value=0.0 | Adjustable=True
In this example:
- On-Demand (
L-DB2E81BA) has 768 vCPUs available—plenty for launchingg6einstances without waiting on a support ticket. - Spot (
L-3819A6DF) is at 0 vCPUs, meaning Spot requests will fail unless a quota increase is requested first.
Three Quick Takeaways
- Always match the Region: Run the check against the exact Region defined in your Terraform configuration.
- Verify On-Demand vs. Spot before choosing a pricing model: If Spot is
0.0, stick to On-Demand or submit a Spot quota request ahead of time. - Quota is not capacity: Even with enough vCPU quota, specific Availability Zones can still return
InsufficientInstanceCapacityduring peak demand—keep your subnet/AZ configuration flexible if you hit a zone bottleneck.