Open
Description
I'm on apple sillicon in a fresh environment that I just created.
uv venv --python 3.12
source .venv/bin/activate
uv pip install xgboost torch
Running the following seg faults:
import xgboost
import torch
M = torch.tensor([[2.0, 0.5],
[0.5, 1.0]],
dtype=torch.double, device="cpu")
L = torch.linalg.cholesky(M)
print("Cholesky succeeded:", L)
Switching the import order (torch before xgboost) fixes the problem. Also doing export OMP_NUM_THREADS=1
fixes the problem.
From my quick debugging session I think it's that xgboost loads libomp
from homebrew first while then torch loads it's own version. I don't know if torch or xgboost should do something differently here, I'm just opening the issue to raise awareness.
Activity
ikrommyd commentedon Jun 5, 2025
and indeed when loading
while with the opposite import order
matthewfeickert commentedon Jun 5, 2025
I think you're right about different symbols getting used, given that if everything is installed from conda-forge (on
linux-64
) then there's no issueSame as for
osx-arm64
:ikrommyd commentedon Jun 5, 2025
Yeah installing the packages from conda-forge is totally fine cause there is an openmp version coming with them from conda-forge. I'm talking about plain pypi installation here.
trivialfis commentedon Jun 6, 2025
There is ongoing work on the Python wheel side for more flexible dependencies. cc @hcho3 https://github.com/wheelnext
For now, Python projects must package all dependencies into a wheel, which can create conflicts between packages. Until the wheel format starts supporting native dependencies, you should use conda/mamba to resolve these kinds of issues.