Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing lightgbm in R

Tags:

github

package

r

I have tried different things to install the lightgbm package but I can´t get it done. I tried all methods at the github repository but they don't work. I run Windows 10 and R 3.5 (64 bit). There is someone with similar problems. So I tried his solution:

    1. Installing cmake (64bit)
    1. Installing Visual Studio (2017)
    1. Installing Rtools (64bit)
    1. Changing Path in the System Variables to "C:\Program Files\CMake\bin\cmake;"
    1. Installing lightgbm with Precompiled dll/lib

-->

  devtools::install_github("Laurae2/lgbdl", force = TRUE)
  library(lgbdl)
  lgb.dl(commit = "master",
  compiler = "vs",
  repo = "https://github.com/Microsoft/LightGBM")

 *** arch - i386
installing via 'install.libs.R' to C:/Users/X1/Documents/R/win- 
library/3.5/lightgbm
Error in eval(ei, envir) : Cannot find lib_lightgbm.dll
* removing 'C:/Users/XXX/Documents/R/win-library/3.5/lightgbm'
In R CMD INSTALL
installation of package 
�C:/Users/XXX/AppData/Local/Temp/RtmpczNLaN/LightGBM/R-package� had non- 
zero exit status[1] FALSE

Any idea how to fix this?

like image 226
Banjo Avatar asked Jun 04 '18 17:06

Banjo


2 Answers

It works for me, hope it helps.

  1. Make sure you install all mandatory software

  2. Download the precomplied .dll file from https://github.com/Microsoft/LightGBM/releases and put it in .\LightGBM\

  3. In install.libs.R, set use_precompile <- TRUE

  4. Copy CMakeLists.txt from root directory into .\LightGBM\R-package\inst\bin

  5. In R console type: install.packages(file.path("C:\yourdirectory\", "LightGBM", "R-package"), repos = NULL, type = "source")

like image 151
Lê Anh Tuấn Avatar answered Oct 05 '22 03:10

Lê Anh Tuấn


For some poor soul struggling through this and if the above mentioned fixes did not work. What I had to do to get it working was:

  • Ensure you have the following in your path environment variables:

    • Rtools (point to the bin folder in the install directory of rtools)

    • Rtools mingw_64 (point to the mingw_64 folder in the rtools install directory)

    • Base R (point to the bin folder in your base R install directory, i.e. where you install R version whatever)

    • CMake (point to the bin folder in your cmake install directory)

    • Visual Studio (allows you to build with VS Build Tools, otherwise will fallback to RTools or any MinGW64 available as stated on the github page)

    • Git

  • Before installing LightGBM, install the following packages in R itself:

    • data.tools

    • magrittr

    • R6

    • jsonlite

  • Once all the above is done, run with the git installation instructions as on the github page here

    For those not able to access the link (or if it should move), the command are the following:

    git clone --recursive https://github.com/microsoft/LightGBM
    
    cd LightGBM
    
    Rscript build_r.R
    
like image 45
pwjvr Avatar answered Oct 05 '22 04:10

pwjvr