GPU Monitoring
Collect hardware telemetry from the GPUs your models run on. Relevant if you self-host models (vLLM, Ollama, Transformers, a local inference server); irrelevant if you only call hosted APIs.
Enabling it
import trail
trail.init(
application_name="inference-server",
environment="production",
collect_gpu_stats=True, # ← this
url=TRAIL_URL, public_key=TRAIL_PUBLIC_KEY, secret_key=TRAIL_SECRET_KEY,
)
collect_gpu_statsis available fromtrailai1.7.0. Older releases didn't accept it and raisedTypeError: init() got an unexpected keyword argument 'collect_gpu_stats'.
Two conditions must hold, or collection doesn't start (a warning is logged if metrics are disabled):
collect_gpu_stats=Truedisable_metricsis notTrue— GPU stats are metrics
# ❌ No GPU metrics — metrics are disabled entirely
trail.init(..., collect_gpu_stats=True, disable_metrics=True)
Supported hardware
| Vendor | Requires |
|---|---|
| NVIDIA | pynvml (NVIDIA Management Library bindings) |
| AMD | amdsmi (AMD System Management Interface) |
Install the one matching your hardware:
pip install nvidia-ml-py # NVIDIA (provides the pynvml module)
pip install amdsmi # AMD
The SDK detects which is available and uses it. Neither present, or no GPU on the host, and collection is skipped without error.
Metrics collected
Exported as OpenTelemetry observable gauges, sampled periodically:
Utilization
| Metric | Meaning |
|---|---|
GPU_UTILIZATION |
Overall compute utilization (%) |
GPU_UTILIZATION_ENC |
Encoder utilization (%) |
GPU_UTILIZATION_DEC |
Decoder utilization (%) |
Memory
| Metric | Meaning |
|---|---|
GPU_MEMORY_TOTAL |
Total VRAM (MB) |
GPU_MEMORY_USED |
VRAM in use (MB) |
GPU_MEMORY_FREE |
VRAM free (MB) |
GPU_MEMORY_AVAILABLE |
VRAM available for allocation (MB) |
Thermal & power
| Metric | Meaning |
|---|---|
GPU_TEMPERATURE |
Core temperature (°C) |
GPU_FAN_SPEED |
Fan speed (%) |
GPU_POWER_DRAW |
Current power draw (W) |
GPU_POWER_LIMIT |
Configured power limit (W) |
Each carries your application_name and environment, plus device identity — so a multi-GPU host
reports per device.
Note: the dedicated GPU analytics page is hidden from navigation in the current release — see Navigation. The metrics are still collected and stored, and the underlying API endpoints remain available.
What the numbers tell you
| Signal | Reading |
|---|---|
| Utilization pinned at 100% | Compute-bound. More concurrency won't help — you need more GPU |
| Utilization low, latency high | Bottleneck is elsewhere: memory bandwidth, CPU preprocessing, or I/O |
| Memory used near total | One more concurrent request away from OOM. Reduce batch size or context length |
| Temperature at the throttle point | Thermal throttling is silently costing you throughput. Check cooling |
| Power draw at the limit | Power-capped. Raising the limit may help, if your PSU and thermals allow |
| Utilization sawtooth | Idle gaps between batches — better batching would raise throughput |
The memory metrics are the ones to alert on. GPU OOM under load is abrupt and takes the whole inference process with it; watching headroom trend downward gives you warning.
Correlating with LLM telemetry
The reason to collect GPU metrics in TrailAI specifically — rather than in your infrastructure monitoring — is that they sit beside your LLM traces:
- Latency spike in LLM Analytics → check whether GPU utilization saturated at the same moment.
- Errors in Exceptions → check whether memory was exhausted.
- Throughput plateau → check whether temperature indicates throttling.
Same time window, same project, one place.
Overhead
Sampling is periodic and cheap — a management-library query per interval. On a busy inference server it's immaterial next to the inference itself.
Keep collect_gpu_stats=False (the default) on hosts without GPUs; there's nothing to collect and the
detection is wasted work.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
| No GPU metrics at all | collect_gpu_stats not set |
Set collect_gpu_stats=True |
| Still nothing | disable_metrics=True |
GPU stats are metrics — don't disable metrics |
| Still nothing | Neither pynvml nor amdsmi installed |
Install the one for your hardware |
| Still nothing | No GPU on the host, or drivers not loaded | nvidia-smi / amd-smi should work first |
| Some metrics missing | Not all metrics exist on all hardware | Expected — e.g. encoder/decoder utilization isn't universal |
| Metrics stop after a while | Collector thread died, or driver became unreachable | Check application logs; verify driver health |
Confirm the driver layer works independently first:
nvidia-smi # NVIDIA
amd-smi static # AMD
If those fail, the SDK cannot help — fix the driver installation first.
Related
- Configuration —
collect_gpu_statsanddisable_metrics - LLM Analytics — correlating hardware with model behaviour