LightGBM installation error_MacOSX10.14_Cmake

Created on 10 Dec 2018  ·  44Comments  ·  Source: microsoft/LightGBM

gcc -v
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
Apple LLVM version 10.0.0 (clang-1000.10.44.4)
Target: x86_64-apple-darwin18.2.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Issue:
I followed the installation guide and on 'cmake ..' step got following error:

#

-- The C compiler identification is Clang 4.0.1
-- The CXX compiler identification is Clang 4.0.1
-- Check for working C compiler: /anaconda3/bin/x86_64-apple-darwin13.4.0-clang
-- Check for working C compiler: /anaconda3/bin/x86_64-apple-darwin13.4.0-clang -- broken
CMake Error at /anaconda3/share/cmake-3.12/Modules/CMakeTestCCompiler.cmake:52 (message):
The C compiler

"/anaconda3/bin/x86_64-apple-darwin13.4.0-clang"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: /Users/adityajuvali/LightGBM/build/CMakeFiles/CMakeTmp

Run Build Command:"/anaconda3/bin/make" "cmTC_4d700/fast"
/anaconda3/bin/make -f CMakeFiles/cmTC_4d700.dir/build.make CMakeFiles/cmTC_4d700.dir/build
make[1]: Entering directory '/Users/adityajuvali/LightGBM/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_4d700.dir/testCCompiler.c.o
/anaconda3/bin/x86_64-apple-darwin13.4.0-clang   -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk   -o CMakeFiles/cmTC_4d700.dir/testCCompiler.c.o   -c /Users/adityajuvali/LightGBM/build/CMakeFiles/CMakeTmp/testCCompiler.c
Linking C executable cmTC_4d700
/anaconda3/bin/cmake -E cmake_link_script CMakeFiles/cmTC_4d700.dir/link.txt --verbose=1
/anaconda3/bin/x86_64-apple-darwin13.4.0-clang -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe  -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names -Wl,-pie -Wl,-headerpad_max_install_names -Wl,-dead_strip_dylibs  CMakeFiles/cmTC_4d700.dir/testCCompiler.c.o  -o cmTC_4d700 
ld: warning: ignoring file /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/lib/libSystem.tbd, file was built for unsupported file format ( 0x2D 0x2D 0x2D 0x20 0x21 0x74 0x61 0x70 0x69 0x2D 0x74 0x62 0x64 0x2D 0x76 0x33 ) which is not the architecture being linked (x86_64): /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/lib/libSystem.tbd
ld: dynamic main executables must link with libSystem.dylib for architecture x86_64
clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [CMakeFiles/cmTC_4d700.dir/build.make:87: cmTC_4d700] Error 1
make[1]: Leaving directory '/Users/adityajuvali/LightGBM/build/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_4d700/fast] Error 2

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:7 (PROJECT)

-- Configuring incomplete, errors occurred!

#

Please help. I am not able install even other models due to this same error.

Most helpful comment

@AdityaJuvali Can you try this?

cmake \
  -DOpenMP_C_FLAGS="-Xpreprocessor -fopenmp -I/usr/local/opt/libomp/include" \
  -DOpenMP_C_LIB_NAMES="omp" \
  -DOpenMP_CXX_FLAGS="-Xpreprocessor -fopenmp -I/usr/local/opt/libomp/include" \
  -DOpenMP_CXX_LIB_NAMES="omp" \
  -DOpenMP_omp_LIBRARY=/usr/local/opt/libomp/lib/libomp.dylib \
  ..

All 44 comments

Hi @AdityaJuvali !

As it can be observed from your logs, CMake cannot find you system Clang compiler. Instead, it uses some compiler from Anaconda installation.

-- The C compiler identification is Clang 4.0.1
-- The CXX compiler identification is Clang 4.0.1
-- Check for working C compiler: /anaconda3/bin/x86_64-apple-darwin13.4.0-clang
-- Check for working C compiler: /anaconda3/bin/x86_64-apple-darwin13.4.0-clang -- broken

Try to specify right compilers by the following command:

export CXX=g++ CC=gcc

Or just remove /anaconda3/bin from your PATH variable.

Hi @AdityaJuvali !

As it can be observed from your logs, CMake cannot find you system Clang compiler. Instead, it uses some compiler from Anaconda installation.

-- The C compiler identification is Clang 4.0.1
-- The CXX compiler identification is Clang 4.0.1
-- Check for working C compiler: /anaconda3/bin/x86_64-apple-darwin13.4.0-clang
-- Check for working C compiler: /anaconda3/bin/x86_64-apple-darwin13.4.0-clang -- broken

Try to specify right compilers by the following command:

export CXX=g++ CC=gcc

Or just remove /anaconda3/bin from your PATH variable.

Thank you for the supportive response. I tried this and got another error. It's anaconda again. Could you please help on changing the PATH variable that you mentioned. I am a beginner Data science student and haven't handled MacOSX before.

Error:
-- The C compiler identification is AppleClang 10.0.0.10001044
-- The CXX compiler identification is AppleClang 10.0.0.10001044
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/gcc
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/g++
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at /anaconda3/share/cmake-3.12/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES)
Call Stack (most recent call first):
/anaconda3/share/cmake-3.12/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
/anaconda3/share/cmake-3.12/Modules/FindOpenMP.cmake:466 (find_package_handle_standard_args)
CMakeLists.txt:78 (find_package)

-- Configuring incomplete, errors occurred!

@AdityaJuvali Now everything OK with your gcc (Apple Clang actually)! No need to do anything else, like PATH modification.

The current error says you don't have OpenMP on your machine.
Please follow the installation guide (step 2) to install it:
https://lightgbm.readthedocs.io/en/latest/Installation-Guide.html#apple-clang

I have OpenMP on my pc. Please check below:

brew install libomp
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
postgresql@10
==> Updated Formulae
easyengine

Warning: libomp 7.0.0 is already installed and up-to-date
To reinstall 7.0.0, run brew reinstall libomp

@AdityaJuvali Now everything OK with your gcc (Apple Clang actually)! No need to do anything else, like PATH modification.

The current error says you don't have OpenMP on your machine.
Please follow the installation guide (step 2) to install it:
https://lightgbm.readthedocs.io/en/latest/Installation-Guide.html#apple-clang

I have OpenMP on my pc. Please check below:

brew install libomp
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
postgresql@10
==> Updated Formulae
easyengine

Warning: libomp 7.0.0 is already installed and up-to-date
To reinstall 7.0.0, run brew reinstall libomp

@AdityaJuvali Now everything OK with your gcc (Apple Clang actually)! No need to do anything else, like PATH modification.

The current error says you don't have OpenMP on your machine.
Please follow the installation guide (step 2) to install it:
https://lightgbm.readthedocs.io/en/latest/Installation-Guide.html#apple-clang

Is the OpenMP installation faulty? Please check below:

brew install libomp
==> Downloading https://homebrew.bintray.com/bottles/libomp-7.0.0.mojave.bottle.tar.gz
Already downloaded: /Users/MyName/Library/Caches/Homebrew/downloads/0aedeb35dcb855e8798934be27a1204ec12efb4b1833c6885416802fd0e9885f--libomp-7.0.0.mojave.bottle.tar.gz
==> Pouring libomp-7.0.0.mojave.bottle.tar.gz
==> Caveats
On Apple Clang, you need to add several options to use OpenMP's front end
instead of the standard driver option. This usually looks like
-Xpreprocessor -fopenmp -lomp

You might need to make sure the lib and include directories are discoverable
if /usr/local is not searched:

-L/usr/local/opt/libomp/lib -I/usr/local/opt/libomp/include

For CMake, the following flags will cause the OpenMP::OpenMP_CXX target to
be set up correctly:
-DOpenMP_CXX_FLAGS="-Xpreprocessor -fopenmp -I/usr/local/opt/libomp/include" -DOpenMP_CXX_LIB_NAMES="omp" -DOpenMP_omp_LIBRARY=/usr/local/opt/libomp/lib/libomp.dylib
==> Summary
🍺 /usr/local/Cellar/libomp/7.0.0: 12 files, 1.2MB

It seems that OpenMP is installed correctly.

Are you still getting the following error?

Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES)

It seems that OpenMP is installed correctly.

Are you still getting the following error?

Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES)

Yes. I uninstalled everything and followed all your steps. I am getting the same error.

Then try to temporary remove all conda-associated items from your PATH variable and follow installation guide from the scratch.

Then try to temporary remove all conda-associated items from your PATH variable and follow installation guide from the scratch.

you mean, should I uninstall anaconda3?
I don't know how to remove PATH temporarily, please give reference or steps.
Thank you so much for your help. Appreciated. 👍

you mean, should I uninstall anaconda3?

I suppose it's unneeded. Just try to remove all things connected to anaconda from PATH:
https://blog.just2us.com/2011/05/setting-path-variable-in-mac-permanently/

I removed the variable 'anaconda3/bin' from the PATH. It moved ahead but again gave error as:

CMake Error at /usr/local/Cellar/cmake/3.13.1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES)
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.13.1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
/usr/local/Cellar/cmake/3.13.1/share/cmake/Modules/FindOpenMP.cmake:473 (find_package_handle_standard_args)
CMakeLists.txt:78 (find_package)

Try to brew reinstall libomp

I tried that too. No progress. Please help!

Please provide the full sequence of actions you've performed and the error message.

Also try the following command: brew link openmp

brew link openmp gives following error:

$ brew link openmp
Error: No such keg: /usr/local/Cellar/openmp

Sorry, I've mistyped. Correct command is brew link libomp.

I had also tried that. It said 'already linked'. I will send all the sequence of steps in 2 days. I am travelling. Thank you.

In my environment (macOS 10.14.1), installation error happens.

❯ cmake ..
-- The C compiler identification is AppleClang 10.0.0.10001145
-- The CXX compiler identification is AppleClang 10.0.0.10001145
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at /usr/local/Cellar/cmake/3.13.2/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES)
Call Stack (most recent call first):
  /usr/local/Cellar/cmake/3.13.2/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
  /usr/local/Cellar/cmake/3.13.2/share/cmake/Modules/FindOpenMP.cmake:473 (find_package_handle_standard_args)
  CMakeLists.txt:78 (find_package)


-- Configuring incomplete, errors occurred!
See also "/Users/henry/.ghq/github.com/henry0312/LightGBM/build/CMakeFiles/CMakeOutput.log".

Exactly the same error. Did you get success thereafter?

Seems to be that this is Mojave-specific issue, because on Azure Pipelines everything OK with CMake 3.13.2 and libomp 7.0.0:

2018-12-17T05:58:37.6588020Z ==> Downloading https://homebrew.bintray.com/bottles/libomp-7.0.0.high_sierra.bottle.tar.gz
2018-12-17T05:58:38.6903780Z ==> Pouring libomp-7.0.0.high_sierra.bottle.tar.gz
2018-12-17T05:58:40.0097150Z ==> Caveats
2018-12-17T05:58:40.0098320Z On Apple Clang, you need to add several options to use OpenMP's front end
2018-12-17T05:58:40.0098450Z instead of the standard driver option. This usually looks like
2018-12-17T05:58:40.0099000Z   -Xpreprocessor -fopenmp -lomp
2018-12-17T05:58:40.0099050Z 
2018-12-17T05:58:40.0099110Z You might need to make sure the lib and include directories are discoverable
2018-12-17T05:58:40.0099270Z if /usr/local is not searched:
2018-12-17T05:58:40.0099310Z 
2018-12-17T05:58:40.0099810Z   -L/usr/local/opt/libomp/lib -I/usr/local/opt/libomp/include
2018-12-17T05:58:40.0099940Z 
2018-12-17T05:58:40.0100010Z For CMake, the following flags will cause the OpenMP::OpenMP_CXX target to
2018-12-17T05:58:40.0100730Z be set up correctly:
2018-12-17T05:58:40.0101480Z   -DOpenMP_CXX_FLAGS="-Xpreprocessor -fopenmp -I/usr/local/opt/libomp/include" -DOpenMP_CXX_LIB_NAMES="omp" -DOpenMP_omp_LIBRARY=/usr/local/opt/libomp/lib/libomp.dylib
2018-12-17T05:58:40.0101790Z ==> Summary
2018-12-17T05:58:40.0102460Z 🍺  /usr/local/Cellar/libomp/7.0.0: 12 files, 1.2MB
2018-12-17T05:58:42.2522760Z ==> Upgrading 1 outdated package:
2018-12-17T05:58:42.2524200Z cmake 3.13.1 -> 3.13.2
2018-12-17T05:58:42.2524290Z ==> Upgrading cmake 
2018-12-17T05:58:42.7773500Z ==> Downloading https://homebrew.bintray.com/bottles/cmake-3.13.2.high_sierra.bottle.tar.gz
2018-12-17T05:58:44.8503970Z ==> Pouring cmake-3.13.2.high_sierra.bottle.tar.gz
2018-12-17T05:58:52.5900040Z ==> Caveats
2018-12-17T05:58:52.5900390Z Emacs Lisp files have been installed to:
2018-12-17T05:58:52.5902670Z   /usr/local/share/emacs/site-lisp/cmake
2018-12-17T05:58:52.5902790Z ==> Summary
2018-12-17T05:58:52.5903440Z 🍺  /usr/local/Cellar/cmake/3.13.2: 5,542 files, 50.6MB
2018-12-17T05:59:03.3040880Z Solving environment: ...working... done
2018-12-17T06:00:35.5450690Z -- The C compiler identification is AppleClang 8.1.0.8020041
2018-12-17T06:00:35.6472470Z -- The CXX compiler identification is AppleClang 8.1.0.8020041
2018-12-17T06:00:35.6588080Z -- Check for working C compiler: /Applications/Xcode_8.3.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
2018-12-17T06:00:36.6639250Z -- Check for working C compiler: /Applications/Xcode_8.3.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
2018-12-17T06:00:36.6639930Z -- Detecting C compiler ABI info
2018-12-17T06:00:36.6640500Z -- Detecting C compiler ABI info - done
2018-12-17T06:00:36.6640990Z -- Detecting C compile features
2018-12-17T06:00:36.9180440Z -- Detecting C compile features - done
2018-12-17T06:00:36.9243210Z -- Check for working CXX compiler: /Applications/Xcode_8.3.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
2018-12-17T06:00:37.0678040Z -- Check for working CXX compiler: /Applications/Xcode_8.3.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
2018-12-17T06:00:37.0971140Z -- Detecting CXX compiler ABI info
2018-12-17T06:00:37.2393120Z -- Detecting CXX compiler ABI info - done
2018-12-17T06:00:37.2495630Z -- Detecting CXX compile features
2018-12-17T06:00:38.0855010Z -- Detecting CXX compile features - done
2018-12-17T06:00:39.0040450Z -- Found OpenMP_C: -Xclang -fopenmp (found version "3.1") 
2018-12-17T06:00:39.1810780Z -- Found OpenMP_CXX: -Xclang -fopenmp (found version "3.1") 
2018-12-17T06:00:39.1816250Z -- Found OpenMP: TRUE (found version "3.1")  
2018-12-17T06:00:39.1890090Z -- Configuring done
2018-12-17T06:00:39.2274230Z -- Generating done
2018-12-17T06:00:39.2394380Z -- Build files have been written to: /Users/vsts/agent/2.144.0/work/1/s/build

Google says that PyTorch users encountered with the same issue last month.

@henry0312 Do you have any guesses what can be wrong?

Xcode version doesn't matter too. Just run it with Xcode 10.0:

-- The C compiler identification is AppleClang 10.0.0.10001145
-- The CXX compiler identification is AppleClang 10.0.0.10001145
-- Check for working C compiler: /Applications/Xcode_10.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode_10.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode_10.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode_10.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenMP_C: -Xclang -fopenmp (found version "3.1") 
-- Found OpenMP_CXX: -Xclang -fopenmp (found version "3.1") 
-- Found OpenMP: TRUE (found version "3.1")  
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/vsts/agent/2.144.0/work/1/s/build

https://lightgbm-ci.visualstudio.com/lightgbm-ci/_build/results?buildId=1120 (MacOS regular log).

Hum...🤔

In an another environment (macOS 10.13.6), installation successes.

❯ cmake ..
-- The C compiler identification is AppleClang 10.0.0.10001145
-- The CXX compiler identification is AppleClang 10.0.0.10001145
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenMP_C: -Xclang -fopenmp (found version "3.1")
-- Found OpenMP_CXX: -Xclang -fopenmp (found version "3.1")
-- Found OpenMP: TRUE (found version "3.1")
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/tsukasa_omoto/.ghq/github.com/henry0312/LightGBM/build

I'm not sure what's wrong exactly, but I guess there is something wrong with Command Line Tools of Mojave (10.14), which you can install via Xcode or get from https://developer.apple.com/downloads/ .
Or there is something wrong with cmake on Mojave.

@henry0312 Can you please try gcc on Mojave? Is everything OK with it?

UPD: I suppose we should write a note in the installation guide about it and remove this note once upstream CMake issue will be fixed.

UPD2: Or can we temporary overcome this issue by manual editing LD_LIBRARY_PATH, like it was done here?
https://github.com/Microsoft/LightGBM/blob/cba824474897c8d7e71a3df261faaefa091a40c5/.travis.yml#L55

Can you please try gcc on Mojave? Is everything OK with it?

Yes, there is no problem with gcc-8.

UPD2: Or can we temporary overcome this issue by manual editing LD_LIBRARY_PATH, like it was done here?

If I really try to fix CMakeLists.txt, this issue may be solved.

@henry0312 The current OpenMP part of CMakeLists.txt is quite simple and elegant:
https://github.com/Microsoft/LightGBM/blob/2323cb3befa0515dd266d4a1393a37c833c11b83/CMakeLists.txt#L77-L86
https://github.com/Microsoft/LightGBM/blob/2323cb3befa0515dd266d4a1393a37c833c11b83/CMakeLists.txt#L212-L217
If I'm not mistaken, a hotfix from our side can be some path hardcoding only. I suppose that this issue should be fixed from CMake side actually.

I suppose that this issue should be fixed from CMake side actually.

I hope so, however, the issue doen't seem a priority.

image

from https://gitlab.kitware.com/cmake/cmake/issues/18520.

@henry0312 Yeah, you're right (unfortunately)!

Hey, what about proposing a PR to their repo? Or at least leave a comment with patch in the issue.

what about proposing a PR to their repo?

Yes, I'll do.
However, firstly, I must look up the cause and then fix the issue, because I think CMake doesn't accept dirty work-around.

@AdityaJuvali Can you try this?

cmake \
  -DOpenMP_C_FLAGS="-Xpreprocessor -fopenmp -I/usr/local/opt/libomp/include" \
  -DOpenMP_C_LIB_NAMES="omp" \
  -DOpenMP_CXX_FLAGS="-Xpreprocessor -fopenmp -I/usr/local/opt/libomp/include" \
  -DOpenMP_CXX_LIB_NAMES="omp" \
  -DOpenMP_omp_LIBRARY=/usr/local/opt/libomp/lib/libomp.dylib \
  ..

Oh Great work! The cmake step worked finally but 'make -j4' threw an error. The results for cmake are-

-- The C compiler identification is AppleClang 10.0.0.10001044
-- The CXX compiler identification is AppleClang 10.0.0.10001044
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/gcc
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/g++
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenMP_C: -Xpreprocessor -fopenmp -I/usr/local/opt/libomp/include (found version "3.1")
-- Found OpenMP_CXX: -Xpreprocessor -fopenmp -I/usr/local/opt/libomp/include (found version "3.1")
-- Found OpenMP: TRUE (found version "3.1")
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/adityajuvali/LightGBM/build

@AdityaJuvali I'm sorry I forgot I fixed CMakeLists.txt.
Can you edit CMakeLists.txt like this:

diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -211,8 +211,8 @@ endif(USE_MPI)

 if(USE_OPENMP)
     if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
-        TARGET_LINK_LIBRARIES(lightgbm ${OpenMP_libomp_LIBRARY})
-        TARGET_LINK_LIBRARIES(_lightgbm ${OpenMP_libomp_LIBRARY})
+        TARGET_LINK_LIBRARIES(lightgbm OpenMP::OpenMP_CXX)
+        TARGET_LINK_LIBRARIES(_lightgbm OpenMP::OpenMP_CXX)
     endif()
 endif(USE_OPENMP)

and then re-try cmake and make.

@AdityaJuvali Seeing conda in that thread ... you can also install a pre-compiled lightgbm or r-lightgbm via conda on win-64, linux-64 and osx-64:

  • lightgbm: conda install -c conda-forge lightgbm
  • r-lightgbm: conda install -c conda-forge r-lightgbm or conda install -c conda-forge/label/gcc7 r-lightgbm (osx-64).

ping @AdityaJuvali

ping @AdityaJuvali

I will try the solutions and get back soon with a feedback.

ping @AdityaJuvali Sorry, but we're waiting your feedback to merge the PR.

@henry0312 Any news about upstream issue?

Yes. So should I edit the CMakelists.txt file as, "-" lines replaced by the "+" lines(below code)? If it's different then kindly share the CMakeLists.txt file here.

diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -211,8 +211,8 @@ endif(USE_MPI)

if(USE_OPENMP)
if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
' - TARGET_LINK_LIBRARIES(lightgbm ${OpenMP_libomp_LIBRARY})
' - TARGET_LINK_LIBRARIES(_lightgbm ${OpenMP_libomp_LIBRARY})
' + TARGET_LINK_LIBRARIES(lightgbm OpenMP::OpenMP_CXX)
' + TARGET_LINK_LIBRARIES(_lightgbm OpenMP::OpenMP_CXX)
endif()
endif(USE_OPENMP)

@AdityaJuvali Yeah, you are right. Lines with "+" sign are new correct lines and they replace old lines marked with "-" sign. For simplicity, you can just copy-paste the entire file content from here.

@StrikerRUS The make command ran successfully now. I tried creating a python script which had single line code as 'import lightgbm'

That shows me following warning. I hope it should work in the model later.
$ python untitled0.py
/anaconda3/lib/python3.7/site-packages/lightgbm/__init__.py:46: UserWarning: Starting from version 2.2.1, the library file in distribution wheels for macOS is built by the Apple Clang (Xcode_8.3.1) compiler.
This means that in case of installing LightGBM from PyPI via the pip install lightgbm command, you don't need to install the gcc compiler anymore.
Instead of that, you need to install the OpenMP library, which is required for running LightGBM on the system with the Apple Clang compiler.
You can install the OpenMP library by the following command: brew install libomp.
"You can install the OpenMP library by the following command: brew install libomp.", UserWarning)

@AdityaJuvali Thanks a lot! This warning is OK, it shows that we've changed compiler for building wheels recently.

Are you able to train LightGBM model?

from sklearn.datasets import load_boston
import lightgbm as lgb

lgb.train({}, lgb.Dataset(*load_boston(True)))

Yes. I ran on all the datasets and models I am using. This seems to be resolved for me. To summarize-

I followed all the same steps as in the Installation guide
EXCEPT

  1. after git clone, change the CMakeLists.txt file and copy the script shown here
  1. Use the following CMAKE command instead of just cmake ..
    cmake
    -DOpenMP_C_FLAGS="-Xpreprocessor -fopenmp -I/usr/local/opt/libomp/include"
    -DOpenMP_C_LIB_NAMES="omp"
    -DOpenMP_CXX_FLAGS="-Xpreprocessor -fopenmp -I/usr/local/opt/libomp/include"
    -DOpenMP_CXX_LIB_NAMES="omp"
    -DOpenMP_omp_LIBRARY=/usr/local/opt/libomp/lib/libomp.dylib
    ..

Thank you all for the support. I appreciated the efforts.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

heroxrq picture heroxrq  ·  3Comments

raphay3l picture raphay3l  ·  3Comments

zanemarkson picture zanemarkson  ·  3Comments

hlee13 picture hlee13  ·  3Comments

jameslamb picture jameslamb  ·  3Comments