JuliaInterop / RCall.jl

Call R from Julia
Other
317 stars 59 forks source link

issues with the package corpcor in R #97

Closed rszoh closed 4 days ago

rszoh commented 8 years ago

Hi, I am trying to use the package corpcor in R from Julia. See the commands below: using RCall @rimport corpcor as corpcor @rusing corpcor

when I try to get help on the function imported from corpcor I get: help?> corpcor.cov.shrink ERROR: MethodError: which_module has no method matching which_module(::Function, ::Symbol) Closest candidates are: which_module(::Module, ::Symbol) in call at docs/bindings.jl:8

And of course when I try to use the function cov.shrink, I get: julia> corpcor.cov.shrink(randn(5,15)) ERROR: type Function has no field shrink

But I am able to work with other R packages without problem. Thank you

randy3k commented 8 years ago

It is because dot symbol is not a valid char in julia object name, you have to access the cov.shrink function by

@rimport corpcor
getfield(corpcor, symbol("cov.shrink"))(randn(5,15))

or if you use @rlibrary (@rusing is deprecated in new function of RCall) which imports all the functions,

@rlibrary corpcor
var"cov.shrink"(randn(5,15))

I recommend the first method since it is more explicit, the second implicit method may break at some point in the future.

rszoh commented 8 years ago

I just run your code and It kills my Julia section:

@rimport corpcor getfield(corpcor, symbol("cov.shrink"))(randn(5,15)) Intel MKL FATAL ERROR: Cannot load libmkl_def.so. [rszoh@r0:~/Temp_TryCode]$

randy3k commented 8 years ago

What OS are you using? Does the package corpcor work in R? I have no idea why it is related to Intel MKL.

rszoh commented 8 years ago

I am working on linux and yes the package works in R

nalimilan commented 8 years ago

Did you build R from source, linking to MKL?

EDIT: or does Julia link to MKL?

rszoh commented 8 years ago

I am not sure - I need to find that out from the network administrator

nalimilan commented 8 years ago

You should be able to find this out by looking at the output of ldd /usr/lib64/R/bin/exec/R (you may need to adjust the path, run which R to know where R is installed).

rszoh commented 8 years ago

I get:

[rszoh@r0:~]$ ldd /local/R-3.2.3/lib64/R/bin/R not a dynamic executable

simonbyrne commented 8 years ago

Are you running the revolution R distribution by any chance?

rszoh commented 8 years ago

No, I don't think so

nalimilan commented 8 years ago

@rszoh That's not the path I gave you. Note the exec/ part.

rszoh commented 8 years ago

@nalimilan oops sorry. Here is the output:

[rszoh@r0:~]$ ldd /local/R-3.2.3/lib64/R/bin/exec/R linux-vdso.so.1 => (0x00007ffdcc0f0000) libR.so => /local/R-3.2.3/lib64/R/lib/libR.so (0x00007fe59acf8000) libRblas.so => /local/R-3.2.3/lib64/R/lib/libRblas.so (0x00007fe59aaf0000) libc.so.6 => /lib64/libc.so.6 (0x00007fe59a708000) libgfortran.so.3 => /lib64/libgfortran.so.3 (0x00007fe59a3e0000) libm.so.6 => /lib64/libm.so.6 (0x00007fe59a0d8000) libgomp.so.1 => /lib64/libgomp.so.1 (0x00007fe599ec0000) libquadmath.so.0 => /lib64/libquadmath.so.0 (0x00007fe599c80000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fe599a60000) libreadline.so.6 => /lib64/libreadline.so.6 (0x00007fe599818000) libtre.so.5 => /lib64/libtre.so.5 (0x00007fe599608000) libpcre.so.1 => /lib64/libpcre.so.1 (0x00007fe5993a0000) liblzma.so.5 => /lib64/liblzma.so.5 (0x00007fe599178000) libbz2.so.1 => /lib64/libbz2.so.1 (0x00007fe598f68000) libz.so.1 => /lib64/libz.so.1 (0x00007fe598d50000) librt.so.1 => /lib64/librt.so.1 (0x00007fe598b48000) libdl.so.2 => /lib64/libdl.so.2 (0x00007fe598940000) libicuuc.so.50 => /lib64/libicuuc.so.50 (0x00007fe5985c0000) libicui18n.so.50 => /lib64/libicui18n.so.50 (0x00007fe5981c0000) /lib64/ld-linux-x86-64.so.2 (0x00007fe59b300000) libmkl_gf_lp64.so => /local/intel/composer_xe_2015.2.164/mkl/lib/intel64/libmkl_gf_lp64.so (0x00007fe597ae8000) libmkl_core.so => /local/intel/composer_xe_2015.2.164/mkl/lib/intel64/libmkl_core.so (0x00007fe595f88000) libmkl_gnu_thread.so => /local/intel/composer_xe_2015.2.164/mkl/lib/intel64/libmkl_gnu_thread.so (0x00007fe595248000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fe595030000) libtinfo.so.5 => /lib64/libtinfo.so.5 (0x00007fe594e00000) libicudata.so.50 => /lib64/libicudata.so.50 (0x00007fe593828000) libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007fe593520000)

nalimilan commented 8 years ago

OK, so indeed you're using MKL. No idea what Julia/RCall.jl can do about this. Maybe both R and Julia should use the same BLAS/LAPACK?

nalimilan commented 8 years ago

Maybe try running Julia with:

LD_LIBRARY_PATH=/local/intel/composer_xe_2015.2.164/mkl/lib/intel64/ julia
rszoh commented 8 years ago

Sys.getenv("LD_LIBRARY_PATH") [1] "/local/R-3.2.3/lib64/R/lib:/usr/local/lib64:/local/lib64:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.65-3.b17.el7.x86_64/jre/lib/amd64/server:/local/R-3.2.3/lib64/R/lib:/usr/local/lib64:/local/lib64:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.65-3.b17.el7.x86_64/jre/lib/amd64/server:/local/intel/composer_xe_2015.2.164/compiler/lib/intel64:/local/intel/composer_xe_2015.2.164/mpirt/lib/intel64:/local/intel/composer_xe_2015.2.164/ipp/../compiler/lib/intel64:/local/intel/composer_xe_2015.2.164/ipp/lib/intel64:/local/intel/composer_xe_2015.2.164/ipp/tools/intel64/perfsys:/local/intel/composer_xe_2015.2.164/compiler/lib/intel64:/local/intel/composer_xe_2015.2.164/mkl/lib/intel64:/local/intel/composer_xe_2015.2.164/tbb/lib/intel64/gcc4.4:/local/intel/composer_xe_2015.2.164/debugger/ipt/intel64/lib:/local/intel/composer_xe_2015.2.164/compiler/lib/intel64:/local/intel/composer_xe_2015.2.164/mpirt/lib/intel64:/local/intel/composer_xe_2015.2.164/ipp/../compiler/lib/intel64:/local/intel/composer_xe_2015.2.164/ipp/lib/intel64:/local/intel/composer_xe_2015.2.164/ipp/tools/intel64/perfsys:/local/intel/composer_xe_2015.2.164/compiler/lib/intel64:/local/intel/composer_xe_2015.2.164/mkl/lib/intel64:/local/intel/composer_xe_2015.2.164/tbb/lib/intel64/gcc4.4:/local/intel/composer_xe_2015.2.164/debugger/ipt/intel64/lib:/local/intel/composer_xe_2015.2.164/compiler/lib/intel64:/local/intel/composer_xe_2015.2.164/mpirt/lib/intel64:/local/intel/composer_xe_2015.2.164/ipp/../compiler/lib/intel64:/local/intel/composer_xe_2015.2.164/ipp/lib/intel64:/local/intel/composer_xe_2015.2.164/ipp/tools/intel64/perfsys:/local/intel/composer_xe_2015.2.164/compiler/lib/intel64:/local/intel/composer_xe_2015.2.164/mkl/lib/intel64:/local/intel/composer_xe_2015.2.164/tbb/lib/intel64/gcc4.4:/local/intel/composer_xe_2015.2.164/debugger/ipt/intel64/lib"

the path you specify is already available in LD_LIBRARY_PATH. Also, when I do what you suggested I get the following errrow in julia:

julia> using RCall ERROR: InitError: error compiling init: could not load library "/local/R-3.2.3/lib64/R/lib/libR.so" libRblas.so: cannot open shared object file: No such file or directory in _require_from_serialized at loading.jl:84 in _require_from_serialized at ./loading.jl:109 in require at ./loading.jl:219 during initialization of module RCall

palday commented 4 days ago

Closing as stale