Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add warning and hint when loading torch before juliacall #385

Merged
merged 1 commit into from
Oct 20, 2023

Conversation

LilithHafner
Copy link
Contributor

Before

x@x pythoncall % python -c 'import torch; from torch.autograd import Function; import juliacall'
zsh: segmentation fault  python3 -c 
x@x pythoncall % be sad
zsh: command not found: be

After

x@x pythoncall % python -c 'import torch; from torch.autograd import Function; import juliacall'
/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/juliacall/__init__.py:62: UserWarning: `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
  warnings.warn(
zsh: segmentation fault  python3 -c 
x@x pythoncall % python -c 'import juliacall; import torch; from torch.autograd import Function'
x@x

Helps with #384, but doesn't solve the issue satisfactorily.

@LilithHafner
Copy link
Contributor Author

"Swap the import order and your segfaults will go away"

@cjdoris cjdoris merged commit 591dcf4 into JuliaPy:main Oct 20, 2023
6 of 13 checks passed
@LilithHafner LilithHafner deleted the lh/torch-fail branch October 20, 2023 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants