Commit 2c9ce598 authored by Laurae's avatar Laurae Committed by Guolin Ke
Browse files

R-package version to 0.2 (#592)

* Add some stuff for README

* Bump R package version and fix license

* Attempt to add one additional option and refactor

* Add more review fixes for install.libs.R

* Undo ./../../ removal (path breaking)

* Retry again simple /../

* No print, use cat.
parent bfdcdf65
Package: lightgbm
Type: Package
Title: Light Gradient Boosting Machine
Version: 0.1
Date: 2016-12-29
Version: 0.2
Date: 2017-06-05
Author: Guolin Ke <guolin.ke@microsoft.com>
Maintainer: Guolin Ke <guolin.ke@microsoft.com>
Description: LightGBM is a gradient boosting framework that uses tree based learning algorithms.
It is designed to be distributed and efficient with the following advantages:
1.Faster training speed and higher efficiency.
2.Lower memory usage.
3.Better accuracy.
4.Parallel learning supported.
1. Faster training speed and higher efficiency.
2. Lower memory usage.
3. Better accuracy.
4. Parallel learning supported.
5. Capable of handling large-scale data.
License: The MIT License (MIT) | file LICENSE
License: MIT + file LICENSE
URL: https://github.com/Microsoft/LightGBM
BugReports: https://github.com/Microsoft/LightGBM/issues
VignetteBuilder: knitr
......
......@@ -5,33 +5,37 @@ Installation
------------
### Preparation
You need to install *git* and [cmake](https://cmake.org/) first.
You need to install git and [cmake](https://cmake.org/) first.
The default compiler is Visual Studio (or [MS Build](https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017)) in Windows. You also can use MinGW64 to compile by set ```use_mingw <- TRUE``` in ```R-package/src/install.libs.R``` (We recommend *Visual Studio* for its better multi-threading efficency in Windows).
The default compiler is Visual Studio (or [MS Build](https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017)) in Windows. You also can use Rtools (default) or [MinGW64](https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/) (x86_64-posix-seh) to compile by setting `use_mingw` to `TRUE` in `R-package/src/install.libs.R`.
For OSX user, gcc need to be installed first (refer to https://github.com/Microsoft/LightGBM/wiki/Installation-Guide#osx).
It is recommended to use *Visual Studio* for its better multi-threading efficency in Windows for many core systems. For simple systems (like laptops or small desktops), MinGW64 is recommended.
For Mac OS X users, gcc with OpenMP support must be installed first. Refer to [wiki](https://github.com/Microsoft/LightGBM/wiki/Installation-Guide#osx) for installing gcc with OpenMP support.
To avoid critical package issues if you are using R 3.4.0 (not the patched/devel version), it is recommended to install once the LightGBM R package, even if it is an old version: `devtools::install_github("Microsoft/LightGBM@v1", subdir = "R-package")`. Make sure you have the correct permissions to install the package.
### Install
Install LightGBM R-package by following command:
Install LightGBM R-package with the following command:
```
```sh
git clone --recursive https://github.com/Microsoft/LightGBM
cd LightGBM/R-package
R CMD INSTALL --build .
```
Or build a self-contained R package then install:
```
Or build a self-contained R package which can be installed afterwards:
```sh
git clone --recursive https://github.com/Microsoft/LightGBM
cd LightGBM/R-package
Rscript build_package.R
R CMD INSTALL lightgbm_0.1.tar.gz
R CMD INSTALL lightgbm_0.2.tar.gz
```
Windows users may need to run with administrator rights (either R or the command prompt, depending on the way you are installing this package). Rtools must be installed for Windows. Linux users might require the appropriate user write permissions for packages.
Set ```use_gpu <- TRUE``` in ```R-package/src/install.libs.R``` can enable the build with GPU support (Need to install *Boost* and *OpenCL* first, details can be found in [gpu-support](https://github.com/Microsoft/LightGBM/wiki/Installation-Guide#with-gpu-support)).
Set `use_gpu` to `TRUE` in `R-package/src/install.libs.R` to enable the build with GPU support. You will need to install Boost and OpenCL first: details for installation can be found in [gpu-support](https://github.com/Microsoft/LightGBM/wiki/Installation-Guide#with-gpu-support).
You can also install directly from R using the repository with `devtools`:
......
if(!file.copy("./../include", "src/", overwrite=TRUE, recursive = TRUE)){
stop("cannot find folder LightGBM/include")
if (!file.copy("./../include", "src/", overwrite = TRUE, recursive = TRUE)) {
stop("Cannot find folder LightGBM/include")
}
if(!file.copy("./../src", "src/", overwrite=TRUE, recursive = TRUE)){
stop("cannot find folder LightGBM/src")
if (!file.copy("./../src", "src/", overwrite = TRUE, recursive = TRUE)) {
stop("Cannot find folder LightGBM/src")
}
if(!file.copy("./../compute", "src/", overwrite=TRUE, recursive = TRUE)){
print("cannot find folder LightGBM/compute, will disable GPU build")
if (!file.copy("./../compute", "src/", overwrite = TRUE, recursive = TRUE)) {
print("Cannot find folder LightGBM/compute, will disable GPU build")
}
if(!file.copy("./../CMakeLists.txt", "src/", overwrite=TRUE, recursive=TRUE)){
stop("cannot find file LightGBM/CMakeLists.txt")
if (!file.copy("./../CMakeLists.txt", "src/", overwrite = TRUE, recursive = TRUE)) {
stop("Cannot find file LightGBM/CMakeLists.txt")
}
if(!file.exists("src/_IS_FULL_PACKAGE")){
if (!file.exists("src/_IS_FULL_PACKAGE")) {
file.create("src/_IS_FULL_PACKAGE")
}
system("R CMD build --no-build-vignettes .")
# User options
use_precompile <- FALSE
use_gpu <- FALSE
use_mingw <- FALSE
source_dir <- paste0(R_PACKAGE_SOURCE, '/src')
setwd(source_dir)
if(!file.exists("_IS_FULL_PACKAGE")){
if(!file.copy("./../../include", "./", overwrite=TRUE, recursive = TRUE)){
stop("cannot find folder LightGBM/include")
}
if(!file.copy("./../../src", "./", overwrite=TRUE, recursive = TRUE)){
stop("cannot find folder LightGBM/src")
}
if(use_gpu){
if(!file.copy("./../../compute", "./", overwrite=TRUE, recursive = TRUE)){
print("cannot find folder LightGBM/compute, will disable GPU build")
# Check for precompilation
if (!use_precompile) {
# Check repository content
source_dir <- paste0(R_PACKAGE_SOURCE, "/src")
setwd(source_dir)
if (!file.exists("_IS_FULL_PACKAGE")) {
if (!file.copy("./../../include", "./", overwrite = TRUE, recursive = TRUE)) {
stop("Cannot find folder LightGBM/include")
}
if (!file.copy("./../../src", "./", overwrite = TRUE, recursive = TRUE)) {
stop("Cannot find folder LightGBM/src")
}
if (use_gpu) {
if (!file.copy("./../../compute", "./", overwrite = TRUE, recursive = TRUE)) {
print("Cannot find folder LightGBM/compute, disabling GPU build.")
use_gpu <- FALSE
}
}
if(!file.copy("./../../CMakeLists.txt", "./", overwrite=TRUE, recursive=TRUE)){
stop("cannot find file LightGBM/CMakeLists.txt")
if (!file.copy("./../../CMakeLists.txt", "./", overwrite = TRUE, recursive = TRUE)) {
stop("Cannot find file LightGBM/CMakeLists.txt")
}
}
}
build_dir <- paste0(source_dir, "/build")
dir.create(build_dir, recursive = TRUE, showWarnings = FALSE)
setwd(build_dir)
# Prepare building package
build_dir <- paste0(source_dir, "/build")
dir.create(build_dir, recursive = TRUE, showWarnings = FALSE)
setwd(build_dir)
cmake_cmd <- "cmake"
build_cmd <- "make -j"
lib_folder <- paste0(R_PACKAGE_SOURCE, '/src')
# Prepare installatio nsteps
cmake_cmd <- "cmake"
build_cmd <- "make -j"
lib_folder <- paste0(R_PACKAGE_SOURCE, "/src")
if (WINDOWS) {
if(use_mingw){
if (WINDOWS) {
if (use_mingw) {
cmake_cmd <- paste0(cmake_cmd, " -G \"MinGW Makefiles\" ")
build_cmd <- "mingw32-make.exe -j"
} else{
} else {
cmake_cmd <- paste0(cmake_cmd, " -DCMAKE_GENERATOR_PLATFORM=x64 ")
build_cmd <- "cmake --build . --target _lightgbm --config Release"
lib_folder <- paste0(R_PACKAGE_SOURCE, '/src/Release')
lib_folder <- paste0(R_PACKAGE_SOURCE, "/src/Release")
}
}
}
if(use_gpu) {
if (use_gpu) {
cmake_cmd <- paste0(cmake_cmd, " -DUSE_GPU=1 ")
}
# Install
system(paste0(cmake_cmd, " .."))
system(build_cmd)
src <- paste0(lib_folder, "/lib_lightgbm", SHLIB_EXT)
} else {
# Has precompiled package
lib_folder <- paste0(R_PACKAGE_SOURCE, "/../")
if (file.exists(paste0(lib_folder, "lib_lightgbm", SHLIB_EXT))) {
src <- paste0(lib_folder, "lib_lightgbm", SHLIB_EXT)
} else if (file.exists(paste0(lib_folder, "windows/x64/DLL/lib_lightgbm", SHLIB_EXT))) {
src <- paste0(lib_folder, "windows/x64/DLL/lib_lightgbm", SHLIB_EXT)
} else {
src <- paste0(lib_folder, "Release/lib_lightgbm", SHLIB_EXT) # Expected result: installation will fail if it is not here or any other
}
}
system(paste0(cmake_cmd, " .."))
system(build_cmd)
dest <- file.path(R_PACKAGE_DIR, paste0('libs', R_ARCH))
# Check installation correctness
dest <- file.path(R_PACKAGE_DIR, paste0("libs", R_ARCH))
dir.create(dest, recursive = TRUE, showWarnings = FALSE)
src <- paste0(lib_folder, '/lib_lightgbm', SHLIB_EXT)
if(file.exists(src)){
print(paste0("find library file: ", src))
if (file.exists(src)) {
cat("Found library file: ", src, " to move to ", dest, sep = "")
file.copy(src, dest, overwrite = TRUE)
} else {
stop("cannot find lib_lightgbm.dll")
stop(paste0("Cannot find lib_lightgbm", SHLIB_EXT))
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment