Importing xgboost before torch + openmp causes seg fault
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 28.8k
- Forks
- 8.9k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 54
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:
```py
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the Apple Silicon failure using the provided uv environment, import order, and Cholesky example. Compare the failing order with importing torch first and with OMP_NUM_THREADS=1, then investigate the reported libomp loading interaction between xgboost and torch. Done means the reproducible import sequence no longer segfaults without requiring an import-order workaround or environment variable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- machine-learning, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100