Skip to content

This example shows how to scale a GPU worker deployment on Kubernetes to zero when there are no pending jobs and scale it back up when there are pending jobs.

Notifications You must be signed in to change notification settings

sunu/kind-gpu-worker-autoscaler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kind GPU Worker Autoscaler Example

This example shows how to scale a GPU worker deployment to zero when there are no pending jobs and scale it back up when there are pending jobs.

Prerequisites

Running

  1. Create a Kind cluster with GPU support
    make create-cluster
  2. Build the docker images
    make build-images
  3. Load the docker images into the Kind cluster
    make load-images
  4. Install NVIDIA GPU operator in the cluster
    make install-nvidia-operator
  5. Deploy the api, worker and autoscaler
    make deploy-all
  6. Port forward the api to localhost
    make port-forward-api
  7. Submit a job to the api on localhost:9091. Watch the pods and logs to see the autoscaler in action.
  8. Delete the cluster when you're done
    make delete-cluster

Notes

  • The api is a simple fastapi app that queues a matrix length into either the cpu or gpu redis queue.
  • cpu-worker listens to the cpu queue and multiplies two random matrices of dimension length x length together on the CPU.
  • Similarly gpu-worker listens to the gpu queue and multiplies two random matrices of dimension length x length together on the GPU.
  • The autoscaler is a simple python script that uses the Kubernetes API to scale the gpu-worker deployment to zero when there are no pending jobs in the gpu redis queue and scales gpu-worker back up when there are jobs available again in the gpu redis queue.

About

This example shows how to scale a GPU worker deployment on Kubernetes to zero when there are no pending jobs and scale it back up when there are pending jobs.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published