XGBoostError and libomp

2 min read
Just in case you find yourself in my situation. Trying to run a Python/XGBoost script on a Mac, and keep getting this
raise XGBoostError(
xgboost.core.XGBoostError:
XGBoost Library (libxgboost.dylib) could not be loaded.
Likely causes:
* OpenMP runtime is not installed
- vcomp140.dll or libgomp-1.dll for Windows
- libomp.dylib for Mac OSX
- libgomp.so for Linux and other UNIX-like OSes
Mac OSX users: Run `brew install libomp` to install OpenMP runtime.
* You are running 32-bit Python on a 64-bit OS
% brew install libomp
==> Downloading https://formulae.brew.sh/api/formula.jws.json
==> Downloading https://formulae.brew.sh/api/cask.jws.json
Warning: libomp 20.1.3 is already installed and up-to-date.
To reinstall 20.1.3, run:
brew reinstall libomp
% brew reinstall libomp
==> Downloading https://ghcr.io/v2/homebrew/core/libomp/manifests/20.1.3
Already downloaded: /Users/john/Library/Caches/Homebrew/downloads/6fb106d95811ad1827b4ad653f3b94cb6dd44ceb8a4a4fb00355021f4d682a56--libomp-20.1.3.bottle_manifest.json
==> Fetching libomp
==> Downloading https://ghcr.io/v2/homebrew/core/libomp/blobs/sha256:70ca0ae9df9f32ef88357ad35efa5b20ee8d91419e385fb0722e52605bceb03b
Already downloaded: /Users/john/Library/Caches/Homebrew/downloads/9778a89c5d8464108701848888f35c0f20e4f3aae0ad620c0c79cefab06719d9--libomp--20.1.3.arm64_sequoia.bottle.tar.gz
==> Reinstalling libomp
==> Pouring libomp--20.1.3.arm64_sequoia.bottle.tar.gz
==> Caveats
libomp is keg-only, which means it was not symlinked into /Volumes/ExternalSSD/opt/homebrew,
because it can override GCC headers and result in broken builds.
For compilers to find libomp you may need to set:
export LDFLAGS="-L/Volumes/ExternalSSD/opt/homebrew/opt/libomp/lib"
export CPPFLAGS="-I/Volumes/ExternalSSD/opt/homebrew/opt/libomp/include"
==> Summary
🍺 /Volumes/ExternalSSD/opt/homebrew/Cellar/libomp/20.1.3: 9 files, 1.7MB
==> Running `brew cleanup libomp`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
Any chance you have HOMEBREW configured for a non-default location?
% env | grep HOMEBREW
HOMEBREW_CASK_OPTS=--appdir=/Volumes/ExternalSSD/opt/homebrew/Applications
HOMEBREW_TEMP=/Volumes/ExternalSSD/opt/homebrew/tmp
Try this (update the paths of course)
% find /Volumes/ExternalSSD/opt/homebrew -name libomp.dylib 2>/dev/null
/Volumes/ExternalSSD/opt/homebrew/Cellar/libomp/20.1.3/lib/libomp.dylib
% sudo mkdir -p /opt/homebrew/opt/libomp/lib
Password:
% sudo ln -s /Volumes/ExternalSSD/opt/homebrew/Cellar/libomp/20.1.3/lib/libomp.dylib /opt/homebrew/opt/libomp/lib/libomp.dylib
0
Subscribe to my newsletter
Read articles from John Walley directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
