diff --git a/nemo_rl/distributed/virtual_cluster.py b/nemo_rl/distributed/virtual_cluster.py index 16e589d0ed..566b6550ca 100644 --- a/nemo_rl/distributed/virtual_cluster.py +++ b/nemo_rl/distributed/virtual_cluster.py @@ -1018,6 +1018,11 @@ def shutdown(self) -> bool: This method is idempotent and can be safely called multiple times. """ + # Skip if Ray is already gone (typically from __del__ during _Py_Finalize + # after Ray's atexit teardown). Any Ray API call would trigger a fatal + # core_worker_process.cc:88 CHECK. Placement groups die with Ray. + if not ray.is_initialized(): + return True if self._node_placement_groups is not None: # Remove all placement groups for pg in self._node_placement_groups: