you can also assign k8s resource through scripts.
this the sample of my codes with kubernetes client.
(I have struggle to assign nvidia GPU - A100 & V100, especiall Multi Instance GPU)
when you assign gpu in some specific nodes, then you may setup toleration or node selector to get resource from the nodes.
container = V1Container(
name="container",
resources=V1ResourceRequirements(
requests={"cpu": "1", "memory":"4Gi", "<http://nvidia.com|nvidia.com>":"1"},
limits={"cpu": "4", "memory":"16Gi", "<http://nvidia.com|nvidia.com>":"1"},
) ,
image=<your image name>,
)
pod_spec = V1PodSpec(
containers=[container],
image_pull_secrets=[V1LocalObjectReference(<your image_account>)],
volumes=volumes,
tolerations=<your node toleration which want to assign resource>,
node_selector=<you will need some specific node selector when there are the same spec nodes>
)
@task(
task_config=Pod(
pod_spec=pod_spec,
),
)
def your_task()->None:
print("this is test")