Lightgbm: run python setup.py,says:“Please install CMake first”

Created on 3 Dec 2017  ·  5Comments  ·  Source: microsoft/LightGBM

I succeeded in compile lightgbm by:

git clone --recursive https://github.com/Microsoft/LightGBM ; cd LightGBM
mkdir build ; cd build
 sudo cmake -DUSE_GPU=1 -DOpenCL_LIBRARY=/usr/local/cuda-9.0/lib64/libOpenCL.so -OpenCL_INCLUDE_DIR=/usr/local/cuda-9.0/include/ ..
make -j4

When I try to run:python setup.py install --gpu,error occured:

Traceback (most recent call last):
  File "setup.py", line 232, in <module>
    'Topic :: Scientific/Engineering :: Artificial Intelligence'])
  File "/home/innnk/anaconda3/lib/python3.6/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/home/innnk/anaconda3/lib/python3.6/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/home/innnk/anaconda3/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "setup.py", line 162, in run
    compile_cpp(use_mingw=self.mingw, use_gpu=self.gpu)
  File "setup.py", line 128, in compile_cpp
    silent_call(cmake_cmd, raise_error=True, error_msg='Please install CMake first')
  File "setup.py", line 73, in silent_call
    raise Exception(error_msg)
Exception: Please install CMake first

I run conda listand found that cmake is already installed.
Any suggestion will be appreciated!^_^

awaiting response

Most helpful comment

It may be trying to use the cmake not in your virtual env, you'll want to make sure the path is either pointed to your venv or you can pip install cmake in your non-virtual env and it should work then

All 5 comments

@innnk Since you have already successfully compiled lightgbm, you should run python setup.py install --precompile.

@innnk Does the suggestion above solve the issue?

It may be trying to use the cmake not in your virtual env, you'll want to make sure the path is either pointed to your venv or you can pip install cmake in your non-virtual env and it should work then

Insert the following two lines after cmake_cmd.append("-DUSE_GPU=ON") in function compile_cpp in setup.py

cmake_cmd.append("-DOpenCL_LIBRARY=/usr/local/cuda/lib64/libOpenCL.so")
cmake_cmd.append("-DOpenCL_INCLUDE_DIR=/usr/local/cuda/include/")

OP has already successfully compiled the library, so he doesn't need to compile it second time. Just pick up the library by --precompile flag.

Was this page helpful?
0 / 5 - 0 ratings