Skip to content
Latchkey

How to Install XGBoost and LightGBM in CI Without libgomp Errors

XGBoost and LightGBM install from wheels easily, but both link against OpenMP - so on a slim image import fails with "libgomp.so.1 cannot open shared object file".

Both libraries ship manylinux wheels with their C++ cores bundled, so pip succeeds. The classic runtime failure is the missing OpenMP runtime: the wheels dlopen libgomp.so.1, which slim images do not include. LightGBM also needs libgomp on Linux for multithreading.

Why it fails in CI

The prebuilt wheels install fine, but at runtime they link to the OpenMP runtime libgomp.so.1. Minimal images (python:3.x-slim, some bases) omit it, so import xgboost or import lightgbm aborts even though the install succeeded.

  • OSError: libgomp.so.1: cannot open shared object file on import.
  • On macOS-based images, a missing libomp (OpenMP) for LightGBM.
  • No matching distribution on a brand-new Python or musl with no wheel.

Install it reliably

Keep the wheels and add the OpenMP runtime. On Debian/Ubuntu that is libgomp1; on Alpine it is libgomp. Pin a supported Python and stay on glibc.

Terminal
# Add the OpenMP runtime the wheels link against
apt-get update && apt-get install -y libgomp1   # Debian/Ubuntu
# apk add --no-cache libgomp                     # Alpine

pip install --only-binary=:all: xgboost lightgbm

Cache & speed

Cache ~/.cache/pip so the wheels are reused, and bake libgomp1 into the image so apt does not run every job.

.github/workflows/ci.yml
- uses: actions/cache@v4
  with:
    path: ~/.cache/pip
    key: pip-boosting-${{ hashFiles('requirements*.txt') }}

Common errors

ErrorCauseFix
libgomp.so.1: cannot open shared object fileNo OpenMP runtimeapt-get install libgomp1
LightGBM OpenMP error on macOS imageMissing libompInstall libomp/libgomp
No matching distribution (new Python)No wheel yetPin a supported Python
Failed building wheelSource build (CMake)Force --only-binary

Key takeaways

  • XGBoost/LightGBM wheels need the OpenMP runtime - install libgomp1.
  • Keep the wheels; never compile their C++ cores in CI.
  • Bake libgomp1 into the image and cache ~/.cache/pip.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →