推薦先看一手官方的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所在的位置,之后正常編譯就好了.