Skip to content
Latchkey

XGBoost "Library cannot be loaded ... libgomp.so.1" in CI

Importing xgboost loads its compiled shared library, which links against the OpenMP runtime libgomp.so.1. On a minimal image that package is absent, so the dynamic linker fails and xgboost raises an XGBoostError at import.

What this error means

import xgboost fails with "XGBoostError: ... libgomp.so.1: cannot open shared object file: No such file or directory" on a slim Debian/Alpine-based runner.

python
xgboost.core.XGBoostError: XGBoost Library (libxgboost.so) could not be loaded.
... libgomp.so.1: cannot open shared object file: No such file or directory

Common causes

The OpenMP runtime is not installed

XGBoost is built with OpenMP and links libgomp.so.1 at load time. A slim base image omits libgomp1, so the import fails.

Alpine/musl base without the GNU OpenMP library

On musl images the GNU libgomp is not present by default, so the manylinux wheel cannot resolve its dependency.

How to fix it

Install the OpenMP runtime

Add libgomp1 (Debian/Ubuntu) before importing xgboost.

Terminal
sudo apt-get update
sudo apt-get install -y libgomp1

On Alpine, install the libgomp package

Provide the OpenMP runtime through apk so the shared object resolves.

Terminal
apk add --no-cache libgomp

How to prevent it

  • Bake libgomp1 into custom runner images that run XGBoost.
  • Prefer the glibc manylinux wheels over musl where possible.
  • Add an import smoke test so missing runtime libraries fail fast.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →