Merge pull request #18989 from hawkinsp:fork

PiperOrigin-RevId: 591286756
This commit is contained in:
jax authors 2023-12-15 10:01:36 -08:00
commit eb595af36f

View File

@ -106,6 +106,16 @@ _CPU_ENABLE_GLOO_COLLECTIVES = config.DEFINE_bool(
)
# Warn the user if they call fork(), because it's not going to go well for them.
def _at_fork():
warnings.warn(
"os.fork() was called. os.fork() is incompatible with multithreaded code, "
"and JAX is multithreaded, so this will likely lead to a deadlock.",
RuntimeWarning, stacklevel=2)
os.register_at_fork(before=_at_fork)
# Backends