Can't install mxnet on Mac

Hi,
I’m using Mac and RStudio and I’m absolute beginner in this field.
How should I install mxnet package in RStudio, because I’he tried many commands
like this:

ran <- getOption(“repos”)
cran[“dmlc”] <- “https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/R/CRAN/
options(repos = cran)
install.packages(“mxnet”)

or this

cran <- getOption(“repos”)
cran[“dmlc”] <- “https://s3-us-west-2.amazonaws.com/apache-mxnet/R/CRAN/
options(repos = cran)
install.packages(“mxnet”,dependencies = T)

and some others

I see the name of the package among others in downloaded packages (as I understand),
BUT when I try to command
library(mxnet) or require(mxnet) I get the following error

Ошибка: .onLoad не удалось в loadNamespace() для ‘mxnet’, подробности:
вызов: dyn.load(file, DLLpath = DLLpath, …)
ошибка: не могу загрузить разделяемый объект ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/mxnet/libs/libmxnet.so’:
dlopen(/Library/Frameworks/R.framework/Versions/3.5/Resources/library/mxnet/libs/libmxnet.so, 10): Library not loaded: /usr/local/opt/openblas/lib/libopenblasp-r0.3.1.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.5/Resources/library/mxnet/libs/libmxnet.so
Reason: image not found

What to deal with this???
I don’t know R much and don’t understand what to do?

Could anyone explain step by step what should I do???, commands I should use and other
stuff.
I read topics and forums on this issue (something about CPU, GPU), but I really don’t understand.

Hi,

The easiest way to install R on mac is by using a prebuilt binary by following this instructions

Alternatively, here are the instructions to build the mxnet shared library and the R language bindings from source

First you have to install the mxnet engine from source with the following instructions - http://mxnet.incubator.apache.org/install/build_from_source.html

After which you can then install the R language bindings by following the instructions specifically for R.

1 Like

Thank you!
I’s sorry for such questions but I really don’t understand

Could you explain how should I add a soft link to the OpenBLAS installation???

Should I just copy the following line:

ln -sf /usr/local/opt/openblas/lib/libopenblasp-r0.3.* /usr/local/opt/openblas/lib/libopenblasp-r0.3.1.dylib

past it in the terminal and press Enter???

You can and should be able to just copy paste the line and press enter

1 Like

Thank you!

I tried to do such things:

copy paste the line:
ln -sf /usr/local/opt/openblas/lib/libopenblasp-r0.3.5 /usr/local/opt/openblas/lib/libopenblasp-r0.3.5.dylib
(I replaced * and 1 with 5 as the latest version of openblas is 0.3.5)

then I installed latest R ( R 3.5.2) according to the link in the instructions and

run the command:

cran <- getOption(“repos”)
cran[“dmlc”] <- “https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/R/CRAN/
options(repos = cran)
install.packages(“mxnet”)

I got this massage:

trying URL 'https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/R/CRAN/bin/macosx/el-capitan/contrib/3.5/mxnet_1.3.0.tgz
Content type ‘application/x-tar’ length 10369234 bytes (9.9 MB)
==================================================
downloaded 9.9 MB

tar: Failed to set default locale

and when I run:
library(mxnet) I get the following error:

Error: package or namespace load failed for ‘mxnet’:
.onLoad failed in loadNamespace() for ‘mxnet’, details:
call: dyn.load(file, DLLpath = DLLpath, …)
error: unable to load shared object ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/mxnet/libs/libmxnet.so’:
dlopen(/Library/Frameworks/R.framework/Versions/3.5/Resources/library/mxnet/libs/libmxnet.so, 10): Library not loaded: /usr/local/opt/openblas/lib/libopenblasp-r0.3.1.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.5/Resources/library/mxnet/libs/libmxnet.so
Reason: image not found

I am also trying to install mxnet for R on MacOS (10.15.4). I installed openblas 0.3.9 and opencv 4.2.0_3.

cran <- getOption(“repos”)
cran[“dmlc”] <- “https://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/R/CRAN/
options(repos = cran)
install.packages(“mxnet”)
library(mxnet)

and I get the following error:

[1] “Loading local: inst/libs/libmxnet.so”
Error: package or namespace load failed for ‘mxnet’:
.onLoad failed in loadNamespace() for ‘mxnet’, details:
call: dyn.load(“R-package/inst/libs/libmxnet.so”, local = FALSE)
error: unable to load shared object ‘/Users/Stefanos/R-package/inst/libs/libmxnet.so’:
dlopen(/Users/Stefanos/R-package/inst/libs/libmxnet.so, 10): image not found

sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS 10.15.4

Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] devtools_2.2.2 usethis_1.5.1

loaded via a namespace (and not attached):
[1] Rcpp_1.0.4 tidyr_1.0.2 prettyunits_1.1.1 ps_1.3.2 visNetwork_2.0.9 assertthat_0.2.1
[7] rprojroot_1.3-2 digest_0.6.25 R6_2.4.1 backports_1.1.5 ggplot2_3.3.0 pillar_1.4.3
[13] rlang_0.4.5 rstudioapi_0.11 callr_3.4.3 drat_0.1.5 DiagrammeR_0.9.2 desc_1.2.0
[19] downloader_0.4 servr_0.16 readr_1.3.1 stringr_1.4.0 htmlwidgets_1.5.1 igraph_1.2.5
[25] munsell_0.5.0 compiler_3.5.2 influenceR_0.1.0 rgexf_0.16.0 httpuv_1.5.2 xfun_0.12
[31] pkgconfig_2.0.3 pkgbuild_1.0.6 htmltools_0.4.0 tidyselect_1.0.0 tibble_3.0.0 gridExtra_2.3
[37] XML_3.99-0.3 fansi_0.4.1 viridisLite_0.3.0 crayon_1.3.4 dplyr_0.8.5 withr_2.1.2
[43] later_1.0.0 grid_3.5.2 jsonlite_1.6.1 gtable_0.3.0 lifecycle_0.2.0 magrittr_1.5
[49] scales_1.1.0 neuralnet_1.44.2 cli_2.0.2 stringi_1.4.6 viridis_0.5.1 fs_1.3.2
[55] promises_1.1.0 remotes_2.1.1 testthat_2.3.2 ellipsis_0.3.0 vctrs_0.2.4 RColorBrewer_1.1-2
[61] tools_3.5.2 glue_1.3.2 purrr_0.3.3 hms_0.5.3 processx_3.4.2 pkgload_1.0.2
[67] yaml_2.2.1 colorspace_1.4-1 sessioninfo_1.1.1 memoise_1.1.0

Any ideas how to fix this issue?
Thank you.