Skip to content

Commit 689e75c

Browse files
authored
Merge pull request #2324 from transformerlab/add/runpod_amd
Add Runpod support for AMD GPUs and images
2 parents 3b91287 + f8ce9fb commit 689e75c

2 files changed

Lines changed: 53 additions & 2 deletions

File tree

api/test/compute_providers/test_runpod_image.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,25 @@ def test_default_image_when_no_override():
5656
config = ClusterConfig(accelerators="A100:1")
5757
provider.launch_cluster("clust-1", config)
5858
assert captured["pod_data"]["imageName"] == "runpod/pytorch:1.0.3-cu1281-torch290-ubuntu2204"
59+
60+
61+
def test_amd_gpu_defaults_to_rocm_image():
62+
provider = _provider()
63+
captured = _capture_pod_data(provider)
64+
# AMD/ROCm card resolves to a ROCm image, not the default CUDA image.
65+
provider._map_gpu_type_to_runpod = lambda _accel: "AMD Instinct MI300X OAM"
66+
config = ClusterConfig(accelerators="MI300X:1")
67+
provider.launch_cluster("clust-1", config)
68+
assert captured["pod_data"]["imageName"] == "rocm/pytorch:latest"
69+
70+
71+
def test_amd_gpu_image_name_override_still_honored():
72+
provider = _provider()
73+
captured = _capture_pod_data(provider)
74+
provider._map_gpu_type_to_runpod = lambda _accel: "AMD Instinct MI300X OAM"
75+
config = ClusterConfig(
76+
accelerators="MI300X:1",
77+
provider_config={"image_name": "my-org/rocm-custom:latest"},
78+
)
79+
provider.launch_cluster("clust-1", config)
80+
assert captured["pod_data"]["imageName"] == "my-org/rocm-custom:latest"

api/transformerlab/compute_providers/runpod.py

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,33 @@
6868
"RTX5000": "NVIDIA RTX 5000 Ada Generation",
6969
"RTX4000": "NVIDIA RTX 4000 Ada Generation",
7070
"RTX2000": "NVIDIA RTX 2000 Ada Generation",
71+
# AMD Instinct (ROCm). Launching these requires a ROCm container image, not
72+
# the default CUDA image — see _is_amd_gpu_id and the image selection in
73+
# launch_cluster().
74+
"MI300X": "AMD Instinct MI300X OAM",
7175
}
7276

77+
# Runpod GPU type IDs for AMD/ROCm cards. Used to pick a ROCm container image at
78+
# launch time instead of the default CUDA image.
79+
_RUNPOD_AMD_GPU_IDS: frozenset = frozenset(
80+
{
81+
"AMD Instinct MI300X OAM",
82+
}
83+
)
84+
85+
# Default ROCm container image for AMD pods. Overridable per-launch via the
86+
# provider config `image_name` (or legacy `template_id`).
87+
_RUNPOD_DEFAULT_ROCM_IMAGE = "rocm/pytorch:latest"
88+
# Default CUDA container image for NVIDIA pods.
89+
_RUNPOD_DEFAULT_CUDA_IMAGE = "runpod/pytorch:1.0.3-cu1281-torch290-ubuntu2204"
90+
91+
92+
def _is_amd_gpu_id(gpu_type_id: Optional[str]) -> bool:
93+
"""Return True if the resolved Runpod GPU type ID is an AMD/ROCm card."""
94+
if not gpu_type_id:
95+
return False
96+
return gpu_type_id in _RUNPOD_AMD_GPU_IDS or "AMD" in gpu_type_id
97+
7398

7499
async def fetch_runpod_provider_logs(
75100
provider_instance: ComputeProvider,
@@ -360,8 +385,12 @@ def launch_cluster(self, cluster_name: str, config: ClusterConfig) -> Dict[str,
360385
except ValueError:
361386
gpu_count = 1
362387

363-
# Use GPU-enabled image
364-
default_image = "runpod/pytorch:1.0.3-cu1281-torch290-ubuntu2204"
388+
# Use a GPU-enabled image. AMD/ROCm cards need a ROCm image; the
389+
# default CUDA image will not run on them.
390+
if _is_amd_gpu_id(gpu_type_id):
391+
default_image = _RUNPOD_DEFAULT_ROCM_IMAGE
392+
else:
393+
default_image = _RUNPOD_DEFAULT_CUDA_IMAGE
365394
else:
366395
# CPU pod
367396
compute_type = "CPU"

0 commit comments

Comments
 (0)