Table of Contents | ||
---|---|---|
|
As a part of MXNet release process, R packages needs to build and tested.
Currently MXNetR is supported on MacOS, Linux need to be built, tested and hosted on the S3 bucket, which acts as a CRAN-like repository for installing the mxnet-R package. Currently we host MXNet-R packages for MacOS and Windows. Details of building and testing of each package is described below.
Mac OS
...
For Mac, we currently maintain and distribute the binary for the CPU version of mxnet-R.
Building MXNet Source Code
- Clone the MXNet GitHub repository and checkout the release branch -
- git clone --recursive https://github.com/apache/incubator-mxnet
- Building the source code - (From here : http://mxnet.incubator.apache.org/versions/master/install/osx_setup.html )
- cp make/osx.mk config.mk
echo "USE_BLAS = openblas" >> ./config.mk
echo "ADD_CFLAGS += -I/usr/local/opt/openblas/include" >> ./config.mk
echo "ADD_LDFLAGS += -L/usr/local/opt/openblas/lib" >> ./config.mk
echo "ADD_LDFLAGS += -L/usr/local/lib/graphviz/" >> ./config.mk- make -j $(nproc) USE_OPENCV=1 USE_BLAS=openblas
Build and install the R-package
Execute these commands in order from the MXNet home folder. This will generate a file called "mxnet_<version>.tgz" in your local folder
Code Block language bash theme Eclipse linenumbers true mkdir -p R-package/inst/libs cp src/io/image_recordio.h R-package/src cp -rf lib/libmxnet.so R-package/inst/libs mkdir -p R-package/inst/include cp -rf include/* R-package/inst/include cp -rf 3rdparty/dmlc-core/include/* R-package/inst/include/ cp -rf 3rdparty/tvm/nnvm/include/* R-package/inst/include Rscript -e "library(devtools); library(methods); options(repos=c(CRAN='https://cloud.r-project.org/'));install_deps(pkg='R-package', dependencies = TRUE)" echo "import(Rcpp)" >> R-package/NAMESPACE R CMD INSTALL R-package Rscript -e "devtools::install_version('roxygen2',version='5.0.1', repos='https://cloud.r-project.org/',quiet=TRUE)" Rscript -e "require(mxnet); mxnet:::mxnet.export('R-package'); warnings()" Rscript -e "require(roxygen2); roxygen2::roxygenise('R-package'); warnings()" R CMD INSTALL --build R-package
You can view the contents of the generated tgz file by: tar -tf mxnet_<version>.tgz
Verify the contents of the package and upload it in the corresponding S3 bucket. Once uploaded on the S3 bucket, we can install and verify using the following commands from an R console.
Code Block language bash theme RDark linenumbers true cran <- getOption("repos") cran["dmlc"] <- "https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/R/CRAN/" options(repos = cran) install.packages("mxnet”) library(mxnet) a <- mx.nd.ones(c(2,3), ctx = mx.cpu()) b <- a * 2 + 1 b packageVersion('mxnet') # Should print the version number. eg : ‘1.4.0’
Windows
For Windows, we support CPU version as well as GPU version. We support 3 GPU versions- cu90, cu91, cu92
Each of the above packages needs to be build, tested and uploaded in the S3 which is mentioned in the official install instructions.
...
Take the package and upload it in the specific S3 bucket.
Where X is 100, 90, 91 or 92 depended on the CUDA version.
...
cran <- getOption("repos")
cran["dmlc"] <- "https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/R/CRAN/"options(repos = cran)
install.packages("mxnet”)
Reverify the installation using
library(mxnet)
a <- mx.nd.ones(c(2,3), ctx = mx.gpu())
b <- a * 2 + 1
b
Linux
N/A