Search code examples
gcccmakelightgbm

How can i install LightGBM? Error about Could not find OpenMP_C in Mac


I am using Mac os and installing Lightgbm

pip uninstall lightgbm

git clone --recursive https://github.com/Microsoft/LightGBM ; cd LightGBM

export CXX=g++-8 CC=gcc-8

mkdir build ; cd build

cmake ..

make -j4

I can't install gcc@8 , gcc@7 and so on, so I tried brew install gcc and it worked.

But cmake .. is failed. The error message:

Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES)

error
error picture


Solution

  • Could NOT find OpenMP_C

    LightGBM uses OpenMP to parallelize some computations. If you are building small models and / or working with small datasets and do not need the speedups this parallelism offers, you can install lightgbm (the LightGBM Python package) from source without OpenMP support.

    git clone --recursive https://github.com/Microsoft/LightGBM
    cd LightGBM/python-package
    pip install --install-option="--nomp" .
    

    To build lightgbm with OpenMP support, install OpenMP on your system. Since you said you are on a Mac, you could (for example) use the Homebrew package manager to do that.

    brew install libomp
    

    Additional information on building the lightgbm can be found in the LightGBM documentation.