cuddly-jelly-27016
04/05/2025, 10:14 PMRayJobConfig without using a pod template. However, this doesn't seem to work.
Just using a head node, I'm trying to do this with a PodTemplate that includes a pod_spec=V1PodSpec, which in turn has
node_selector={
"cloud.google.com/gke-accelerator": "nvidia-l4",
"cloud.google.com/gke-accelerator-count": "1",
},
However, this node selector does not seem to be propagated to the k8s ray job. There appears to be some issue in the merging logic.
A work-around is to set the @task itself to have a GPU. This sets the node selector appropriately in the head node. However, this then also makes the submitting pod have a GPU, which remains idle, which is a bit wasteful.
### Expected behavior
I expect the Node Selector to be properly set, and the job to launch.
### Additional context to reproduce
import ray
from flytekit import PodTemplate, task
from flytekitplugins.ray import HeadNodeConfig, RayJobConfig
from kubernetes.client import V1Container, V1PodSpec, V1ResourceRequirements
@ray.remote
def f(x):
return x * 2
head_template = PodTemplate(
pod_spec=V1PodSpec(
node_selector={
"cloud.google.com/gke-accelerator": "nvidia-l4",
"cloud.google.com/gke-accelerator-count": "1",
},
containers=[
V1Container(
name="ray-head",
resources=V1ResourceRequirements(
limits={
"cpu": "8",
"memory": "16Gi",
"nvidia.com/gpu": "1",
},
requests={
"cpu": "8",
"memory": "16Gi",
"nvidia.com/gpu": "1",
},
),
),
],
)
)
@task(
task_config=RayJobConfig(
shutdown_after_job_finishes=True,
ttl_seconds_after_finished=60,
worker_node_config=[],
head_node_config=HeadNodeConfig(
pod_template=head_template,
),
),
)
def test_ray_task() -> list[int]:
futures = [f.remote(i) for i in range(5)]
return ray.get(futures)
Gives GKE error
admission webhook "warden-validating.common-webhooks.networking.gke.io" denied the request: GKE Warden rejected the request because it violates one or more constraints.
Violations details: {"[denied by autogke-gpu-limitation]":["When requesting 'nvidia.com/gpu' resources, you must specify either node selector 'cloud.google.com/gke-accelerator' with accelerator type or node selector 'cloud.google.com/compute-class' with existing custom compute class which has at least one GPU priority rule."]}
The YAML of the produced RayJob is
headGroupSpec:
enableIngress: true
rayStartParams:
dashboard-host: 0.0.0.0
disable-usage-stats: "true"
include-dashboard: "true"
node-ip-address: $MY_POD_IP
serviceType: NodePort
template:
metadata:
labels:
domain: development
execution-id: a8x8kxcnf6mzn6mbltwj
interruptible: "false"
node-id: raytesttestraytask
project: test
shard-key: "11"
task-name: ray-test-test-ray-task
workflow-name: flytegen-ray-test-test-ray-task
spec:
affinity: {}
containers:
- env: #omitted
image: # omitted
name: ray-head
ports:
- containerPort: 6379
name: redis
protocol: TCP
- containerPort: 10001
name: head
protocol: TCP
- containerPort: 8265
name: dashboard
protocol: TCP
resources:
limits:
cpu: "8"
memory: 16Gi
nvidia.com/gpu: "1"
requests:
cpu: "8"
ephemeral-storage: 8Gi
memory: 16Gi
nvidia.com/gpu: "1"
terminationMessagePolicy: FallbackToLogsOnError
restartPolicy: Never
which doesn't include the nodeselector.
### Screenshots
No response
### Are you sure this issue hasn't been raised already?
• Yes
### Have you read the Code of Conduct?
• Yes
flyteorg/flytecuddly-jelly-27016
04/09/2025, 7:40 PM