From 4a5693ef92a308217d28fc3830561ac37474884d Mon Sep 17 00:00:00 2001 From: MilesCranmer Date: Sun, 4 Feb 2024 14:55:11 +0000 Subject: [PATCH] Check if user already set JULIA_NUM_THREADS --- pysr/julia_helpers.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pysr/julia_helpers.py b/pysr/julia_helpers.py index 887874050..e9b7ceed4 100644 --- a/pysr/julia_helpers.py +++ b/pysr/julia_helpers.py @@ -15,7 +15,16 @@ + "You will experience segfaults if running with multithreading." ) -os.environ["PYTHON_JULIACALL_HANDLE_SIGNALS"] = "yes" +if os.environ.get("JULIA_NUM_THREADS", "auto") != "auto": + warnings.warn( + "JULIA_NUM_THREADS environment variable is set to something other than 'auto', " + "so PySR was not able to set it. You may wish to set it to `'auto'` for full use " + "of your CPU." + ) + +os.environ["PYTHON_JULIACALL_HANDLE_SIGNALS"] = os.environ.get( + "PYTHON_JULIACALL_HANDLE_SIGNALS", "yes" +) os.environ["JULIA_NUM_THREADS"] = os.environ.get("JULIA_NUM_THREADS", "auto") import juliapkg