LIRRA  1.0.0
Loading...
Searching...
No Matches
rl_stl.utils.device Namespace Reference

Functions

bool _cuda_available ()
 
str resolve_device (str|None device=None)
 
str configure_jax_device (str|None device=None)
 
dict[str, object] jax_device_summary ()
 

Variables

tuple _VALID = ("cpu", "gpu", "auto")
 

Detailed Description

CPU/GPU switch for JAX, MJX and Brax.

The same code runs on the laptop (CPU smoke tests) and on the cluster (GPU
training). Select the device with, in order of precedence:

1. the ``device`` argument (``"cpu"``, ``"gpu"`` or ``"auto"``),
2. the ``RL_STL_DEVICE`` environment variable,
3. ``"auto"``: GPU if ``nvidia-smi`` exists and the JAX CUDA plugin is installed
   (``uv sync --extra cuda12``), otherwise CPU.

JAX reads its platform configuration at import time, so
:func:`configure_jax_device` must run **before** the first ``import jax``
anywhere in the process (including indirect imports via brax/playground).

Function Documentation

◆ _cuda_available()

bool rl_stl.utils.device._cuda_available ( )
protected

◆ configure_jax_device()

str rl_stl.utils.device.configure_jax_device ( str | None   device = None)
Set JAX/XLA environment variables for the resolved device and return it.

◆ jax_device_summary()

dict[str, object] rl_stl.utils.device.jax_device_summary ( )
Describe the devices JAX actually sees (imports jax).

◆ resolve_device()

str rl_stl.utils.device.resolve_device ( str | None   device = None)

Variable Documentation

◆ _VALID

tuple rl_stl.utils.device._VALID = ("cpu", "gpu", "auto")
protected