Summary
When we execute OneComp with Llama.cpp on macOS, it conflicts OpenMP execution between PyTorch and Llama.cpp.
Environment
- macOS Tahoe 26.6.1
- CPU: M1 Pro
- uv 0.11.17
- Python 3.12.14
- OneComp 1.13.1
- torch 2.13.0
- llama-cpp-python 0.3.34
What Happened
- If you have installed gcc or clang on macOS using a tool like Homebrew, OpenMP associated with them will conflict with OpenMP within the .venv (generated by uv) directory.
- OneComp's PyTorch backend is configured to use OpenMP library located within .venv.
- Depending on the environment, Llama.cpp is configured to use the OpenMP library associated with gcc or clang.
- Therefore, the above two will result in a conflict at runtime.
If the following warning message is shown, this conflict may be occurring.
**/multiprocessing/resource_tracker.py:279: UserWarning: resource_tracker: There appear to be 1 leaked semaphore objects to clean up at shutdown
warnings.warn('resource_tracker: There appear to be %d '
Suggested Fix
Search for OpenMP associated with PyTorch.
$ find .venv -type f \( -name 'libomp.dylib' -o -name 'libgomp*.dylib' \) -print | grep torch
.venv/lib/python3.<PYVERSION>/site-packages/torch/lib/libomp.dylib
Create an .env
Create a .env file and add the OpenMP path as an environment variable, as shown below.
DYLD_LIBRARY_PATH=".venv/lib/python3.<PYVERSION>/site-packages/torch/lib"
Run uv
Pass the following --env-file options when running uv run.
uv run --env-file /path/to/.env ... python your_script.py
Summary
When we execute OneComp with Llama.cpp on macOS, it conflicts OpenMP execution between PyTorch and Llama.cpp.
Environment
What Happened
If the following warning message is shown, this conflict may be occurring.
Suggested Fix
Search for OpenMP associated with PyTorch.
Create an .env
Create a .env file and add the OpenMP path as an environment variable, as shown below.
Run uv
Pass the following
--env-fileoptions when running uv run.