Fly Machines API Deployments in home Region even when Specifying another Region

NOTE: The “region” key should be outside of the “config” object like so:

params = {
"region": "ord",
"config: {...}
}

When creating a new app + creating machines in that region.
It gives me an error when attaching a gpu:

Create Machine {‘error’: ‘GPU GPU_KIND_L40S not available in region jnb’}

But the code I wrote / requests I am making, do specify the region the machines + app volumes should be deployed in:

def create_machine(app_name, image_name, service_config):
    config = service_config
    app_name = app_name.lower()
    url = f"https://api.machines.dev/v1/apps/{app_name}/machines"

    image = image_name

    mounts = get_mounts(config, app_name)
    ports = get_fly_services(config)

    memory_str = config["memory"].lower()
    memory = 256
    if memory_str.endswith("gb"):
        memory = int(memory_str.replace("gb", "")) * 1024
    elif memory_str.endswith("mb"):
        memory = int(memory_str.replace("mb", ""))

    payload = {
        "config": {
            "region": "ord",  # Make the user be able to choose the region, as well as multi region deployments
            "init": {},
            "image": image,
            "auto_destroy": True,
            "restart": {"policy": "always"},
            "mounts": mounts,
            "services": ports,
            "guest": {
                "cpu_kind": config.get("cpu_mode", "shared"),
                "cpus": int(config.get("cpu", 1)),
                "memory_mb": memory,
            },
        }
    }

    if "gpu" in config:
        payload["config"]["guest"]["gpus"] = 1
        payload["config"]["guest"]["gpu_kind"] = config.get("gpu") or "a100-pcie-40gb"

    if schedule := config.get("schedule"):
        payload["config"]["schedule"] = schedule

    response = requests.post(url, json=payload, headers=headers)

    print(response.json())
    return response.json()

def create_app_volume(app_name, volume_name, size):
    url = f"https://api.machines.dev/v1/apps/{app_name}/volumes"
    payload = {
        "name": volume_name,
        "size_gb": size,
        "region": "ord",  # Make the user be able to choose the region, as well as multi region deployments
    }
    response = requests.post(url, json=payload, headers=headers)
    return response.json()["id"]

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.