mirror of
https://github.com/wassname/ray.git
synced 2026-06-28 20:07:41 +08:00
Try to raise ulimit for file descriptors to max allowed; warn if ulimit is still too low (#11515)
This commit is contained in:
@@ -622,6 +622,29 @@ def init(
|
||||
arguments is passed in.
|
||||
"""
|
||||
|
||||
# Try to increase the file descriptor limit, which is too low by
|
||||
# default for Ray: https://github.com/ray-project/ray/issues/11239
|
||||
try:
|
||||
import resource
|
||||
soft, hard = resource.getrlimit(resource.RLIMIT_NOFILE)
|
||||
if soft < hard:
|
||||
logger.debug("Automatically increasing RLIMIT_NOFILE to max "
|
||||
"value of {}".format(hard))
|
||||
try:
|
||||
resource.setrlimit(resource.RLIMIT_NOFILE, (hard, hard))
|
||||
except ValueError:
|
||||
logger.debug("Failed to raise limit.")
|
||||
soft, _ = resource.getrlimit(resource.RLIMIT_NOFILE)
|
||||
if soft < 4096:
|
||||
logger.warning(
|
||||
"File descriptor limit {} is too low for production "
|
||||
"servers and may result in connection errors. "
|
||||
"At least 8192 is recommended. --- "
|
||||
"Fix with 'ulimit -n 8192'".format(soft))
|
||||
except ImportError:
|
||||
logger.debug("Could not import resource module (on Windows)")
|
||||
pass
|
||||
|
||||
if "RAY_ADDRESS" in os.environ:
|
||||
if address is None or address == "auto":
|
||||
address = os.environ["RAY_ADDRESS"]
|
||||
|
||||
Reference in New Issue
Block a user