推荐先看一手官方的Installation Guide.我用的是ubuntu 16.04,一些要求如下图:
主要是OpenCL以及libboost两个环境的要求.
(1) OpenCL的安装.我这里之前安装了NVIDA-395的驱动以及CUDA 9.0,只需要在编译的时候给出对应的path就可以了(这部分后面编译的时候会有解释).可以用clinfo查看OpenCL的信息.
Lenovo-Rescuer-15ISK:~$ clinfo Number of platforms 1 Platform Name NVIDIA CUDA Platform Vendor NVIDIA Corporation Platform Version OpenCL 1.2 CUDA 9.1.84 Platform Profile FULL_PROFILE Platform Extensions cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_fp64 cl_khr_byte_addressable_store cl_khr_icd cl_khr_gl_sharing cl_nv_compiler_options cl_nv_device_attribute_query cl_nv_pragma_unroll cl_nv_copy_opts cl_nv_create_buffer Platform Extensions function suffix NV Platform Name NVIDIA CUDA Number of devices 1 Device Name GeForce GTX 960M Device Vendor NVIDIA Corporation Device Vendor ID 0x10de Device Version OpenCL 1.2 CUDA Driver Version 390.87 Device OpenCL C Version OpenCL C 1.2
(2)libboost安装.
> 从https://dl.bintray.com/boostorg/release/1.69.0/source/boost_1_69_0.tar.gz下载对应的压缩包
> 解压缩 tar -xzvf boost_1_69_0.tar.gz
> 切换到对应的文件目录下 sudo ./bootstrap.sh
> 根据提示 sudo ./b2 install 这样头文件就被默认安装在/usr/local/include头文件下,库文件就被默认安装在/usr/local/lib下
上述两个依赖搞定之后,安装官方给的安装方式(linux)如下:
git clone --recursive https://github.com/microsoft/LightGBM ; cd LightGBM mkdir build ; cd build cmake -DUSE_GPU=1 .. # if you have installed NVIDIA CUDA to a customized location, you should specify paths to OpenCL headers and library like the following: # cmake -DUSE_GPU=1 -DOpenCL_LIBRARY=/usr/local/cuda/lib64/libOpenCL.so -DOpenCL_INCLUDE_DIR=/usr/local/cuda/include/ .. make -j4
注意,如果已经安装过cuda的要指出OpenCL所在的位置,之后正常编译就好了.