python/ray/autoscaler/_private/kuberay/autoscaling_config.py
def _get_num_gpus(
    ray_start_params: Dict[str, str],
    k8s_resource_limits: Dict[str, Any],
    group_name: str,
) -> Optional[int]:
    """Read the number of GPUs from the Ray start params.

    Potential TODO: Read GPU info from the container spec, here and in the
    Ray Operator.
    """

    if "num-gpus" in ray_start_params:
        return int(ray_start_params["num-gpus"])

    # Issue a warning if GPUs are present in the container spec but not in the
    # ray start params.
    # TODO: Consider reading GPU info from container spec.
    for key in k8s_resource_limits:
        global _GPU_WARNING_LOGGED
        if "gpu" in key and not _GPU_WARNING_LOGGED:
            with suppress(Exception):
                if int(k8s_resource_limits[key]) > 0:
                    logger.warning(
                        f"Detected GPUs in container resources for group {group_name}."
                        "To ensure Ray and the autoscaler are aware of the GPUs,"
                        " set the `--num-gpus` rayStartParam."
                    )
                    _GPU_WARNING_LOGGED = True
            break

    return None
Read the number of GPUs from the Ray start params.

    Potential TODO: Read GPU info from the container spec, here and in the
    Ray Operator.
    
Read the number of GPUs from the Ray start params.
Potential TODO: Read GPU info from the container spec, here and in the
Ray Operator.
Read the number of GPUs from the Ray start params . Potential TODO : Read GPU info from the container spec here and in the Ray Operator .
def _get_num_gpus(
    ray_start_params: Dict[str, str],
    k8s_resource_limits: Dict[str, Any],
    group_name: str,
) -> Optional[int]:
    if "num-gpus" in ray_start_params:
        return int(ray_start_params["num-gpus"])
    for key in k8s_resource_limits:
        global _GPU_WARNING_LOGGED
        if "gpu" in key and not _GPU_WARNING_LOGGED:
            with suppress(Exception):
                if int(k8s_resource_limits[key]) > 0:
                    logger.warning(
                        f"Detected GPUs in container resources for group {group_name}."
                        "To ensure Ray and the autoscaler are aware of the GPUs,"
                        " set the `--num-gpus` rayStartParam."
                    )
                    _GPU_WARNING_LOGGED = True
            break
    return None
def _get_num_gpus ( ray_start_params : Dict [ str , str ] , k8s_resource_limits : Dict [ str , Any ] , group_name : str , ) -> Optional [ int ] : if "num-gpus" in ray_start_params : return int ( ray_start_params [ "num-gpus" ] ) for key in k8s_resource_limits : global _GPU_WARNING_LOGGED if "gpu" in key and not _GPU_WARNING_LOGGED : with suppress ( Exception ) : if int ( k8s_resource_limits [ key ] ) > 0 : logger . warning ( f"Detected GPUs in container resources for group {group_name}." "To ensure Ray and the autoscaler are aware of the GPUs," " set the `--num-gpus` rayStartParam." ) _GPU_WARNING_LOGGED = True break return None
Read the number of GPUs from the Ray start params.
Read the number of GPUs from the Ray start params .
"""Read the number of GPUs from the Ray start params.

    Potential TODO: Read GPU info from the container spec, here and in the
    Ray Operator.
    """ # Issue a warning if GPUs are present in the container spec but not in the # ray start params. # TODO: Consider reading GPU info from container spec.
ray_start_params
Dict[str, str]
k8s_resource_limits
Dict[str, Any]
group_name
str