Skip to content

Commit

Permalink
[UX/Catalog] Add DEVICE_MEM info to GCP GPUs. (#3375)
Browse files Browse the repository at this point in the history
* [UX/Catalog] Add DEVICE_MEM info to GCP GPUs.

* Fix missing gpu info & P100
  • Loading branch information
concretevitamin authored Mar 29, 2024
1 parent b9c0103 commit a946ed7
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions sky/clouds/service_catalog/data_fetchers/fetch_gcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,16 +308,44 @@ def _get_gpus_for_zone(zone: str) -> pd.DataFrame:
continue
if gpu_name.startswith('TPU-'):
continue
gpu_info = _gpu_info_from_name(gpu_name)
if gpu_info is None:
# Prevent `show-gpus` from not showing GPUs without GPU info.
gpu_info = gpu_name
new_gpus.append({
'AcceleratorName': gpu_name,
'AcceleratorCount': count,
'GpuInfo': None,
'GpuInfo': gpu_info,
'Region': zone.rpartition('-')[0],
'AvailabilityZone': zone,
})
return pd.DataFrame(new_gpus).reset_index(drop=True)


def _gpu_info_from_name(name: str) -> Optional[Dict[str, List[Dict[str, Any]]]]:
"""Hard-codes the GPU memory info for certain GPUs.
Reference: https://cloud.google.com/compute/docs/gpus
"""
name_to_gpu_memory_in_mib = {
'L4': 24 * 1024,
'A100-80GB': 80 * 1024,
'A100': 40 * 1024,
'H100': 80 * 1024,
'P4': 8 * 1024,
'T4': 16 * 1024,
'V100': 16 * 1024,
'P100': 16 * 1024,
# End of life:
'K80': 12 * 1024,
}
gpu_memory_in_mib = name_to_gpu_memory_in_mib.get(name)
if gpu_memory_in_mib is not None:
return {'Gpus': [{'MemoryInfo': {'SizeInMiB': gpu_memory_in_mib}}]}
print('Warning: GPU memory info not found for', name)
return None


def _get_gpus(region_prefix: str) -> pd.DataFrame:
zones = _get_all_zones()
zones = [zone for zone in zones if zone.startswith(region_prefix)]
Expand Down Expand Up @@ -376,7 +404,6 @@ def get_gpu_price(row: pd.Series, spot: bool) -> Optional[float]:
df = df.reset_index(drop=True)
df = df.sort_values(
['AcceleratorName', 'AcceleratorCount', 'Region', 'AvailabilityZone'])
df['GpuInfo'] = df['AcceleratorName']
return df


Expand Down

0 comments on commit a946ed7

Please sign in to comment.