JuliaPy / PythonCall.jl

Python and Julia in harmony.
https://juliapy.github.io/PythonCall.jl/stable/
MIT License
776 stars 63 forks source link

Segmentation fault when `juliacall` is imported before `torch` #435

Open fiktor opened 9 months ago

fiktor commented 9 months ago

Minimal example:

$ python -c 'import juliacall; import torch; print("Done.")'
Segmentation fault (core dumped)

The segfault happens at 0x00007fffa673c342 in __kmp_env_blk_init () in libgomp.so.1

Importing only one of the two modules does not result in an error.

Note that this issue is related but different from #215: here juliacall is imported before torch, and there torch is imported before juliacall.

Environment details:

Similar issues:

fiktor commented 9 months ago

Attached are other information which might be relevant to reproduce the bug: gdb trace and the list of installed packages (in plaintext and as environment.yml renamed environment.yml.txt to pass github filetype filter).

environment.yml.txt mamba_list.txt trace.txt

fiktor commented 9 months ago

It looks like this problem was mentioned in pytorch.#78829: while the issue 78829 is about the order "import torch; import juliacall", the comment cited above says

In the Linux scenario the issue occurs when Julia is loaded before pytorch within the same process.

which is consistent with this issue. Three more observations:

mkitti commented 9 months ago

You appear to be using juliacall which is unrelated to the pyjulia package. I'm going to transfer this issue to https://github.com/JuliaPy/PythonCall.jl

There are a number of possibilities here. You could for example configure Julia to use MKL.