Skip to content

Commit 591dcf4

Browse files
LilithHafnerLilith Hafner
and
Lilith Hafner
authored
add torch interop warning and actionable hint (#385)
Co-authored-by: Lilith Hafner <[email protected]>
1 parent 80ed1ff commit 591dcf4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pysrc/juliacall/__init__.py

+9
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ def init():
5353
import ctypes as c
5454
import sys
5555
import subprocess
56+
import warnings
57+
58+
# importing pytorch before juliacall sometimes causes segfaults. TODO: remove
59+
if "torch" in sys.modules:
60+
warnings.warn(
61+
"`torch` was loaded before the juliacall. This may cause a segfault. "
62+
"To avoid this, import `juliacall` *before* importing `torch`. "
63+
"For updates, see https://github.com/pytorch/pytorch/issues/78829"
64+
)
5665

5766
def option(name, default=None, xkey=None, envkey=None):
5867
"""Get an option.

0 commit comments

Comments
 (0)