runpod>=1.9.0.
There are two kinds of fitness checks: custom checks that you define for your own workload, and automatic system checks that Runpod runs for you without any code changes.
Register a custom fitness check
Use the@runpod.serverless.register_fitness_check decorator to register your own checks. A check is a function that raises an exception (typically RuntimeError) to signal failure. If it returns without raising, the check passes. Both synchronous and asynchronous functions are supported.
handler.py
Asynchronous checks
Checks can also be asynchronous functions, which is useful for I/O-bound validation such as confirming connectivity to an external service:handler.py
When checks run
Custom checks run once at worker startup, before the first job, and they execute in the order you register them. They run only on the Runpod Serverless platform, so they’re skipped during local development and testing. When a check fails, Runpod logs the check name and exception, the worker exits with code 1, and the container is marked unhealthy so your endpoint can restart it. When all checks pass, the worker starts its heartbeat and begins accepting jobs. A failed startup looks like this in the logs:Custom check examples
The following examples cover common readiness checks you can adapt to your own workload. Verify that a GPU is available and has enough memory:Automatic system checks
Along with your custom checks, Runpod automatically runs a set of built-in system checks at startup, with no registration required. These verify that the worker has enough memory, disk space, and network connectivity to run reliably. GPU workers run three additional checks that validate the CUDA version, initialize the CUDA device, and benchmark GPU compute. GPU workers also run a native GPU memory allocation test that exercises actual memory allocation across all detected GPUs; this test is skipped automatically on CPU-only workers. You can tune the thresholds for these checks using environment variables, or disable them entirely for testing. Your own registered checks always run, regardless of these settings.
The native GPU memory allocation test can be tuned with these additional variables. The test typically takes 100–500 ms per GPU, so keep that in mind when setting
RUNPOD_GPU_TEST_TIMEOUT.
You can set these variables in your Dockerfile to adjust the thresholds for your workload:
Dockerfile
Disable automatic checks
You can disable the automatic system checks with the following environment variables. This is intended for testing only and is not recommended in production, since the checks help catch unhealthy workers before they take traffic.
Your own registered checks still run even when these flags are set.
Test fitness checks locally
Fitness checks don’t run during local testing, so to verify yours before you deploy, call each check function directly. A check signals failure by raising an exception, so you can call it and handle the result yourself.test_fitness.py