8

I want to install the GPU version of lightgbm on Ubuntu, based on the following command:

pip install lightgbm --install-option=--gpu

During installation, an error is occurred saying "Please install CMake first". After installing CMake, I get the same error again. To be sure that CMake is installed, I run the following command and get the correct version of the installed CMake:

/opt/cmake/bin/cmake -version

What is the possible reason of this error?

Hossein
  • 2,041
  • 1
  • 16
  • 29
  • Is CMake in your path? What are the results of `which cmake`? – Cinder Biscuits Nov 03 '17 at 14:45
  • @CinderBiscuits '/usr/local/bin/cmake' – Hossein Nov 03 '17 at 14:56
  • Looks like your system version of cmake is too old. Please give the output of the following 3 commands: `cmake --version`, `/usr/local/bin/cmake --version`, `/opt/cmake/bin/cmake --version` – Steve Lorimer Nov 03 '17 at 15:17
  • @SteveLorimer Actually, I installed the latest stable release. All the mentioned commands return 3.9.4 as the version. – Hossein Nov 03 '17 at 15:25
  • According to the docs it should work then. Perhaps try build from source? Instructions [here](https://github.com/Microsoft/LightGBM/tree/master/python-package): `git clone --recursive https://github.com/Microsoft/LightGBM.git cd LightGBM/python-package python setup.py install --gpu` – Steve Lorimer Nov 03 '17 at 15:30
  • @SteveLorimer The same error occurred while installing from source. Thanks anyway. – Hossein Nov 03 '17 at 15:39

4 Answers4

10

I had same issue too, on my M1 MacBook Air. I solve this problem by using brew. Firstly, I ran brew install gcc then brew install CMake because of dependicies. After that, I ran brew install lightgbm on my IDE's terminal. Finally, run pip install lightgbm command on my IDE's terminal and I can succesfully import lightgbm.

7

I got exactly this error, on Ubuntu 16.04 with CUDA installed and cmake version 3.5.1. In my case, despite the "Please install CMake" error, the issue was:

  • The necessary boost libraries were not installed, and
  • cmake was not able to find OpenCL.

I was able to install LightGBM for Python by doing the following:

# Install boost libraries.
sudo apt-get install libboost-all-dev
# Get LightGBM source.
git clone --recursive https://github.com/Microsoft/LightGBM.git
cd LightGBM/python-package/
# cmake specifying locations of OpenCL files.
sudo cmake -DUSE_GPU=1 -DOpenCL_LIBRARY=/usr/local/cuda-8.0/lib64/libOpenCL.so -DOpenCL_INCLUDE_DIR=/usr/local/cuda-8.0/include/ ..
# Compile.
sudo make
# Install for Python, using what we just compiled.
python setup.py install --precompile

After that I was able to run Python and import lightgbm successfully.

Didn't help?

"Please install CMake" can mask other errors. To see more detail about what is going wrong, in LightGBM/python-package/setup.py, in the function silent_call, change the line

subprocess.check_output(cmd, stderr=shut_up)

to

subprocess.check_output(cmd) 

and run

python setup.py install --gpu
andycraig
  • 710
  • 5
  • 18
1

I had this error on pip 7.1.0.

An update to pip 9.0.1 solved the problem!

Benoit R
  • 338
  • 1
  • 3
  • 8
0

In jupyter notebook run

!pip uninstall numba -y
!conda install numba -y

!pip uninstall numpy -y
!conda install numpy -y

In Mac open terminal and run the following

brew install gcc
brew install CMake
brew install lightgbm

Finally go back to notebook and run

!pip install lightgbm
Noordeen
  • 1,547
  • 20
  • 26