rJava etc in R

189 views
Skip to first unread message

Dima Pasechnik

unread,
May 11, 2016, 5:25:40 AM5/11/16
to sage-cloud, sage-clou...@googlegroups.com
I was asked to help with running few R packages (in particular coreNLP), but the system-wide R does not have rJava package installed; installing it for a particular user fails with mysterious 

** testing if installed package can be loaded
Error : .onLoad failed in loadNamespace() for 'rJava', details:
  call: dyn.load(file, DLLpath = DLLpath, ...)
  error: unable to load shared object '/projects/ee1c777f-df48-4b64-8963-c58e8c268ed7/R/x86_64-pc-linux-gnu-library/3.2/rJava/libs/rJava.so':
  libjvm.so: cannot open shared object file: No such file or directory
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/projects/ee1c777f-df48-4b64-8963-c58e8c268ed7/R/x86_64-pc-linux-gnu-library/3.2/rJava’
 
The downloaded source packages are in
        ‘/tmp/RtmpMQDqJS/downloaded_packages’
Warning message:
In install.packages("rJava") :
  installation of package ‘rJava’ had non-zero exit status

(to get that far I did run 'R CMD javareconf -e, as suggested by R during install of rJava;
it sets a hell of a lot of environment variables, and looks generally quite hacky)

It would be great if rJava were available in the system-wide R. (Even better, if coreNLP is installed, too).

Dima

 

Harald Schilly

unread,
May 11, 2016, 5:35:20 AM5/11/16
to sage-cloud, sage-cloud-members
On Wed, May 11, 2016 at 11:25 AM, Dima Pasechnik <dim...@gmail.com> wrote:
> It would be great if rJava were available in the system-wide R.

I have the feeling, that this setup script is incompatible with what's
installed right now. Can you point me to a good page for how to setup
rJava? Is there one? I have no experience setting it up, and I also
don't know if we've ever tried it.

libjvm.so does exist via the usual channels, though:

$ dpkg -L openjdk-7-jre-headless | grep libjvm
/usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/server/libjvm.so

-- harald

Dima Pasechnik

unread,
May 11, 2016, 6:53:44 AM5/11/16
to sage-cloud, sage-clou...@googlegroups.com
I would try running in R, as the root,

install.packages("rJava")

and see how far you get.

(I don't know how much a security issues this might be though)

Dima

Dima Pasechnik

unread,
May 11, 2016, 6:59:55 AM5/11/16
to sage-cloud, sage-clou...@googlegroups.com
there is  r-cran-rjava package in Ubuntu, which would be just what you need...


On Wednesday, May 11, 2016 at 10:35:20 AM UTC+1, Harald Schilly wrote:

drxyzzy

unread,
May 11, 2016, 7:34:39 AM5/11/16
to sage-cloud-members, sage-...@googlegroups.com
I was able to install rJava and coreNLP by setting
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/jvm/default-java/jre/lib/amd64:/usr/lib/jvm/default-java/jre/lib/amd64/server
in my .bash_aliases, restarting, then doing "R CMD javareconf -e" and the usual "sage -R". I don't know how to test that package, though.

This used to work by setting LD_LIBRARY_PATH in ~/.sagemathcloud-env but I don't see the hook for that any more.

William Stein

unread,
May 11, 2016, 8:55:59 AM5/11/16
to drxyzzy, sage-cloud-members, sage-cloud
Hal or Dima,

Can you make a github issue from this?

Dima: can you ask for a test case...? Also, can you give us the
full list of "help with running few R packages"...

After a few years, my experience with packages (for both R and pip) is
that there are a lot of requests for a while, and if we sort them all
out... they suddenly nearly stop, because most things people want get
installed. So it's far better to just make
those top requested packages standard for everybody.

-- William
> --
> You received this message because you are subscribed to the Google Groups
> "sage-cloud-members" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-cloud-memb...@googlegroups.com.
> Visit this group at https://groups.google.com/group/sage-cloud-members.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sage-cloud-members/90cea40f-fa19-4955-89d7-1401c696d2da%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



--

Best Regards,
William Stein

CEO, SageMath, Inc.

Professor of Mathematics at a university

Dima Pasechnik

unread,
May 11, 2016, 9:52:59 AM5/11/16
to sage-cloud, drx...@gmail.com, sage-clou...@googlegroups.com


On Wednesday, May 11, 2016 at 1:55:59 PM UTC+1, William Stein wrote:
Hal or Dima,

Can you make a github issue from this?



Dima: can you ask for a test case...?     Also, can you give us the
full list of "help with running few R packages"...

This I will do tomorrow, after I talk to guys who want this...

 

Dima Pasechnik

unread,
May 13, 2016, 2:58:23 AM5/13/16
to sage-cloud, drx...@gmail.com, sage-clou...@googlegroups.com
I spent hours yesterday trying to make coreNLP running on R in Windows, trying to make it run in a Linux VM, etc.

1. no idea how to make it run on Windows, due to Java problems; 

2. It needs a 64-bit Linux to run; 3. As of R 3.2.5, It needs Java-8, while the Linux I chose has Java 7 by default...

3. it appears to be hard to find a working 64-bit Linux image for VirtualBox; I ended up installing 64-bit Linux from a (virtual) ISO image.

4. still not done, so cannot give you a test case...

5. Thanks for SMC T-shirt - just arrived yesterday :-)

PS. I am sure if SMC were to provide it, it would get new users instantly :-)

drxyzzy

unread,
May 13, 2016, 4:47:17 AM5/13/16
to sage-cloud-members, sage-...@googlegroups.com, drx...@gmail.com

On Friday, May 13, 2016 at 1:58:24 AM UTC-5, dimpase wrote:
I spent hours yesterday trying to make coreNLP running on R in Windows, trying to make it run in a Linux VM, etc.

1. no idea how to make it run on Windows, due to Java problems; 

2. It needs a 64-bit Linux to run; 3. As of R 3.2.5, It needs Java-8, while the Linux I chose has Java 7 by default...

3. it appears to be hard to find a working 64-bit Linux image for VirtualBox; I ended up installing 64-bit Linux from a (virtual) ISO image.

4. still not done, so cannot give you a test case...

5. Thanks for SMC T-shirt - just arrived yesterday :-)

PS. I am sure if SMC were to provide it, it would get new users instantly :-)


I was able to run a tiny test in SMC. Don't really know what coreNLP is about yet though.
Here's a summary of the steps:
Give project >= 3 g memory (this can be tuned, I'm sure)

install jdk1.8 in ~/jdk1.8.0_91
create wrapper ~/bin/sage that does the equivalent of

export JAVA_HOME=$HOME/jdk1.8.0_91
export PATH="$JAVA_HOME/bin:$PATH"
export LD_LIBRARY_PATH=$JAVA_HOME/jre/lib/amd64:$JAVA_HOME/jre/lib/amd64/server:$LD_LIBRARY_PATH
/usr/local/bin/sage "$@"

in .term session, do

R CMD javareconf -e
sage -R
install.packages("rJava",type="source")
install.packages("coreNLP")

in .sagews file, do

%default_mode r
--
# verify rJava built with Java 8
library(rJava)
.jinit()
.jcall("java/lang/System","S","getProperty","java.version")

[1] "1.8.0_91"

--
# need to omit the "ner" annotator or we get heap overflow in gc
initCoreNLP(mem = "2g", annotators = c("tokenize", "ssplit", "pos"))
Adding annotator tokenize
Adding annotator ssplit
Adding annotator pos

sIn <- "Mother died today. Or, maybe, yesterday; I can't be sure."
annoObj <- annotateString(sIn)
summary(annoObj)
                 Length Class      Mode
token            9      data.frame list
parse            0      -none-     NULL
basicDep         0      -none-     NULL
collapsedDep     0      -none-     NULL
collapsedProcDep 0      -none-     NULL
coref            0      -none-     NULL
sentiment        3      data.frame list

==

 

drxyzzy

unread,
May 13, 2016, 4:52:29 AM5/13/16
to sage-cloud-members, sage-...@googlegroups.com, drx...@gmail.com
P.S.: Just saw this. Don't know about an R interface for it.

Harald Schilly

unread,
May 13, 2016, 1:46:55 PM5/13/16
to drxyzzy, sage-cloud-members, sage-cloud
On Fri, May 13, 2016 at 10:52 AM, drxyzzy <drx...@gmail.com> wrote:
> Google SyntaxNet parser goes open source.

That's implemented on top of "TensorFlow", which is installed in
Anaconda, and that's available as a kernel in the jupyter notebook or
on the command line. I.e. that's Python + some wrapping behind the
scenes :-)

-- harald
Reply all
Reply to author
Forward
0 new messages