Skip to content

Commit

Permalink
add torch interop warning and actionable hint (#385)
Browse files Browse the repository at this point in the history
Co-authored-by: Lilith Hafner <[email protected]>
  • Loading branch information
LilithHafner and Lilith Hafner authored Oct 20, 2023
1 parent 80ed1ff commit 591dcf4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pysrc/juliacall/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ def init():
import ctypes as c
import sys
import subprocess
import warnings

# importing pytorch before juliacall sometimes causes segfaults. TODO: remove
if "torch" in sys.modules:
warnings.warn(
"`torch` was loaded before the juliacall. This may cause a segfault. "
"To avoid this, import `juliacall` *before* importing `torch`. "
"For updates, see https://github.com/pytorch/pytorch/issues/78829"
)

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

0 comments on commit 591dcf4

Please sign in to comment.