jax-ml/jax · error · ValueError
No active profiler server.
Error message
No active profiler server.
What it means
jax.profiler.stop_server raises ValueError when no profiler server is currently running; the global `_profiler_server` is None. It is the counterpart guard to start_server's singleton check.
Source
Thrown at jax/_src/profiler.py:89
# Make sure backends are initialized before creating a profiler
# session. Otherwise on Cloud TPU, libtpu may not be initialized before
# creating the tracer, which will cause the TPU tracer initialization to
# fail and no TPU operations will be included in the profile.
# NOTE(skyewm): I'm not sure this is necessary for start_server (is definitely
# is for start_trace), but I'm putting it here to be safe.
if requires_backend:
xla_bridge.get_backend()
_profiler_server = _profiler.start_server(port)
return _profiler_server
def stop_server():
"""Stops the running profiler server."""
global _profiler_server
if _profiler_server is None:
raise ValueError("No active profiler server.")
_profiler_server = None # Should destroy the profiler server
def register_subprocess(pid: int, port: int) -> Callable[[], None]:
"""Registers a subprocess's profiler server to be profiled alongside the current process.
When the current process collects a profile (either programmatically or via
its profiler server), it will propagate the request to all registered
subprocesses' profiler servers and subsequently, aggregate all their responses
into the main response returned by this process's profiler server.
This is helpful when running workers in separate processes that may affect the
performance of the main process (e.g. PyGrain).
NOTE: Currently, only CPU profiling of subprocesses is supported.
Args:
pid: The process ID of the subprocess.View on GitHub (pinned to 1e1c6a8fc0)
Solutions
- Track server state in your own flag and only stop when started
- Wrap stop_server in try/except ValueError for idempotent cleanup
- Ensure tearDown only runs after a successful setUp start
Example fix
# before jax.profiler.stop_server() # may raise # after try: jax.profiler.stop_server() except ValueError: pass
Defensive patterns
Strategy: try-catch
Validate before calling
import jax.profiler as jp # track your own state server_started = False
Try / catch
try:
jp.stop_server()
except ValueError:
pass # nothing to stop; idempotent cleanup Prevention
- Only stop when your code started it
- Use try/finally with a started flag
When it happens
Trigger: Calling `jax.profiler.stop_server()` before any successful start_server, or after stop_server was already called.
Common situations: Cleanup code (finally blocks, tearDown) running when startup failed or was skipped; paired tests where ordering varies.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- No profile started
- distributed.initialize should only be called once.
- Only one profiler server can be active at a time.
- Profile has already been started. Only one profile may be ru
- Invalid trace folder: {latest_trace_folder}
AI-assisted analysis of jax-ml/jax@1e1c6a8fc0 (2026-08-27).
Data as JSON: /api/errors/ca2e4dba632b4093.
Report an issue: GitHub.