Creating a Remote Plan when R is in an Environment Module #648
-
I have access to a Sun Grid Engine cluster, and I've successfully set up The trouble I'm running into is that R is activated via an environment module on the remote machine. That is, if I were logging in to run R as normal, I'd do:
My understanding is that |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
Hello. I think the easiest approach is to create a custom shell script that replaces #! /usr/bin/env bash
## Load the 'r' module
module load r
## Call Rscript and pass all arguments as-is
Rscript "$@" Make sure it's executable, i.e. do: {remote}$ chmod ugo+x myRscript Verify it works; {remote}$ ~/myScript --version
Rscript (R) version 4.2.1 (2022-06-23)
{remote}$ ~/myRscript -e "getRversion()"
[1] ‘4.2.1’ and also from your local computer, e.g. {laptop}$ ssh remote.server.com '~/myRscript -e "getRversion()"'
[1] ‘4.2.1’ When you've verified all of the above, then you should be able to launch a parallel worker using the following "low-level" parallelly code: {laptop}$ R
...
> cl <- parallelly::makeClusterPSOCK("remote.server.com", rscript = "myRscript")
> print(cl)
Socket cluster with 1 nodes where 1 node is on host 'remote.server.com' (R version 4.2.1 (2022-06-23), platform x86_64-pc-linux-gnu) When you've confirmed that working, you should be able to do: {laptop}$ R
...
> library(future)
> cl <- parallelly::makeClusterPSOCK("remote.server.com", rscript = "myRscript")
> plan(cluster, workers = cl)
> f <- future(Sys.info()[["nodename"]])
> value(f)
[1] "remote.server.org" or shorter, > library(future)
> plan(cluster, workers = "remote.server.com", rscript = "myRscript")
> f <- future(Sys.info()[["nodename"]])
> value(f)
[1] "remote.server.org" Hope this helps |
Beta Was this translation helpful? Give feedback.
Hello. I think the easiest approach is to create a custom shell script that replaces
Rscript
when it comes to launching the R worker. Assuming you use Bash as your shell script on the remote system, create amyRscript
script like:Make sure it's executable, i.e. do:
Verify it works;
and also from your local computer, e.g.
{laptop}$ ssh remote.server.com '~/myRscript -e "getRversion()"' [1] ‘4.2.1’
When you've verified a…