Skip to content

Commit

Permalink
Fix MXNet R package build (apache#13952)
Browse files Browse the repository at this point in the history
* fix mxnet r package build

* add ci

* remove mkldnn-gpu test for R

* add minimal test for MKLDNN-R

* pick mlp as minimal R test
  • Loading branch information
jitMatrix authored and haohuw committed Jun 23, 2019
1 parent ce524a2 commit 90300b5
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,13 @@ rpkg:
mkdir -p R-package/inst/libs
cp src/io/image_recordio.h R-package/src
cp -rf lib/libmxnet.so R-package/inst/libs

if [ -e "lib/libmkldnn.so.0" ]; then \
cp -rf lib/libmkldnn.so.0 R-package/inst/libs; \
cp -rf lib/libiomp5.so R-package/inst/libs; \
cp -rf lib/libmklml_intel.so R-package/inst/libs; \
fi

mkdir -p R-package/inst/include
cp -rf include/* R-package/inst/include
rm R-package/inst/include/dmlc
Expand Down
30 changes: 30 additions & 0 deletions ci/docker/runtime_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,36 @@ unittest_ubuntu_cpu_R() {
make rpkgtest R_LIBS=/tmp/r-site-library
}

unittest_ubuntu_minimal_R() {
set -ex
mkdir -p /tmp/r-site-library
# build R packages in parallel
mkdir -p ~/.R/
build_ccache_wrappers
echo "MAKEFLAGS = -j"$(nproc) > ~/.R/Makevars
# make -j not supported
make rpkg \
USE_BLAS=openblas \
R_LIBS=/tmp/r-site-library

R CMD INSTALL --library=/tmp/r-site-library R-package
# pick mlp as minimal R test
R_LIBS=/tmp/r-site-library \
Rscript -e "library(mxnet); require(mlbench); \
data(Sonar, package=\"mlbench\"); \
Sonar[,61] = as.numeric(Sonar[,61])-1; \
train.ind = c(1:50, 100:150); \
train.x = data.matrix(Sonar[train.ind, 1:60]); \
train.y = Sonar[train.ind, 61]; \
test.x = data.matrix(Sonar[-train.ind, 1:60]); \
test.y = Sonar[-train.ind, 61]; \
model = mx.mlp(train.x, train.y, hidden_node = 10, \
out_node = 2, out_activation = \"softmax\", \
learning.rate = 0.1, \
array.layout = \"rowmajor\"); \
preds = predict(model, test.x, array.layout = \"rowmajor\")"
}

unittest_ubuntu_gpu_R() {
set -ex
mkdir -p /tmp/r-site-library
Expand Down
14 changes: 14 additions & 0 deletions ci/jenkins/Jenkins_steps.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,20 @@ def test_unix_r_cpu() {
}]
}

def test_unix_r_mkldnn_cpu() {
return ['R: MKLDNN-CPU': {
node(NODE_LINUX_CPU) {
ws('workspace/ut-r-mkldnn-cpu') {
timeout(time: max_time, unit: 'MINUTES') {
utils.unpack_and_init('mkldnn_cpu', mx_mkldnn_lib, true)
utils.docker_run('ubuntu_cpu', 'unittest_ubuntu_minimal_R', false)
utils.publish_test_coverage()
}
}
}
}]
}

def test_unix_perl_cpu() {
return ['Perl: CPU': {
node(NODE_LINUX_CPU) {
Expand Down
1 change: 1 addition & 0 deletions ci/jenkins/Jenkinsfile_unix_cpu
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ core_logic: {
custom_steps.test_unix_clojure_integration_cpu(),
custom_steps.test_unix_perl_cpu(),
custom_steps.test_unix_r_cpu(),
custom_steps.test_unix_r_mkldnn_cpu(),
custom_steps.test_unix_julia07_cpu(),
custom_steps.test_unix_julia10_cpu(),
custom_steps.test_unix_onnx_cpu(),
Expand Down

0 comments on commit 90300b5

Please sign in to comment.