Using GPU Resources
Kubernetes, the backbone of Release AI, provides mechanisms to allocate GPUs to your applications. This is crucial for running compute-intensive tasks such as machine learning model training, deep learning inference, and high-performance data processing.
Example Configurations for GPU Usage
Selecting GPUs for Your Service
To start, you need to specify that your service requires GPUs. This can be done by setting the nvidia.com/gpu limits. Below is an example configuration:
services:
- name: mlapp
image: "registry.k8s.io/cuda-vector-add:v0.1"
replicas: 4
nvidia_com_gpu:
limits: 1 # Number of GPUs, must be an integer
node_selector:
- key: nvidia.com/gpu
value: "true"In this example:
The
mlappservice is configured to run with an image that leverages CUDA.The
replicasfield is set to4, meaning four instances of this service will run.The
nvidia_com_gpu.limitsis set to1, specifying that each instance will use one GPU.The
node_selectorensures that the service is scheduled on nodes with GPU resources.
Selecting an Instance Type Known to Have GPUs
Choosing the right instance type is important for your application to access the necessary GPU resources. Here’s how you can specify an instance type with GPUs:
In this example:
The
nvidia.com/gpu.productkey is set toA10G, specifying that the nodes should have NVIDIA A10G GPUs.The
beta.kubernetes.io/instance-typekey is set tog5.12xlarge, which is a known instance type that includes GPU resources.
Complete Configuration Example
Combining the GPU selection and instance type configuration, here is the complete setup:
In this example:
The
servicessection defines the application services in your deployment.The
mlappservice runs a Docker image optimized for CUDA operations.The
replicasfield specifies the number of instances to run.The
nvidia_com_gpu.limitsensures each instance gets2GPU.The
node_selectorfilters the nodes to only those with the specified GPU (A10G) and instance type (g5.12xlarge).
Last updated
Was this helpful?