R
From FarmShare
Line 1: | Line 1: | ||
- | + | == R Sample Job == | |
- | <pre> | + | Here's an example R file that generates a large array, fills it with some random numbers, then sleeps for 5mins. This happens to use up almost exactly 8GB of RAM. |
- | [chekh@corn-image-new.stanford.edu] /mnt/glusterfs/chekh/R_test [0] | + | <pre>[chekh@corn-image-new.stanford.edu] /mnt/glusterfs/chekh/R_test [0] |
$ cat 8GB.R | $ cat 8GB.R | ||
- | x | + | x <- array(1:1073741824, dim=c(1024,1024,1024)) |
- | x | + | x <- gaussian() |
Sys.sleep(300) | Sys.sleep(300) | ||
- | </pre> | + | </pre> |
- | + | Here's an example SGE submit script that runs that R file. | |
- | Here's an example SGE submit script that runs that R file. | + | <pre>$ cat r_test.script |
- | + | ||
- | <pre> | + | |
- | + | ||
- | $ cat r_test.script | + | |
#!/bin/bash | #!/bin/bash | ||
Line 25: | Line 21: | ||
#$ -S /bin/sh | #$ -S /bin/sh | ||
- | R --vanilla --no-save | + | R --vanilla --no-save < 8GB.R |
- | + | ||
- | + | ||
+ | </pre> | ||
You can submit it with just | You can submit it with just | ||
+ | |||
qsub r_test.script | qsub r_test.script | ||
- | Here are the output files that I get, one from stderr, one from stdout | + | Here are the output files that I get, one from stderr, one from stdout |
- | + | <pre>$ cat r_test.script.e497 | |
- | <pre> | + | |
- | $ cat r_test.script.e497 | + | |
tset: standard error: Function not implemented | tset: standard error: Function not implemented | ||
Undefined tty | Undefined tty | ||
stdin: is not a tty | stdin: is not a tty | ||
- | </pre> | + | </pre> <pre>$ cat r_test.script.o497 |
- | |||
- | |||
- | |||
Warning: no access to tty (Bad file descriptor). | Warning: no access to tty (Bad file descriptor). | ||
Thus no job control in this shell. | Thus no job control in this shell. | ||
+ | |||
R version 2.12.1 (2010-12-16) | R version 2.12.1 (2010-12-16) | ||
Line 52: | Line 44: | ||
ISBN 3-900051-07-0 | ISBN 3-900051-07-0 | ||
Platform: x86_64-pc-linux-gnu (64-bit) | Platform: x86_64-pc-linux-gnu (64-bit) | ||
+ | |||
R is free software and comes with ABSOLUTELY NO WARRANTY. | R is free software and comes with ABSOLUTELY NO WARRANTY. | ||
You are welcome to redistribute it under certain conditions. | You are welcome to redistribute it under certain conditions. | ||
Type 'license()' or 'licence()' for distribution details. | Type 'license()' or 'licence()' for distribution details. | ||
+ | |||
R is a collaborative project with many contributors. | R is a collaborative project with many contributors. | ||
Type 'contributors()' for more information and | Type 'contributors()' for more information and | ||
'citation()' on how to cite R or R packages in publications. | 'citation()' on how to cite R or R packages in publications. | ||
+ | |||
Type 'demo()' for some demos, 'help()' for on-line help, or | Type 'demo()' for some demos, 'help()' for on-line help, or | ||
Line 65: | Line 60: | ||
Type 'q()' to quit R. | Type 'q()' to quit R. | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | Those errors about tty and job control have something to do with shell startup and terminal settings, and are normal. | + | > x <- array(1:1073741824, dim=c(1024,1024,1024)) |
+ | > x <- gaussian() | ||
+ | > Sys.sleep(300) | ||
+ | > | ||
+ | |||
+ | |||
+ | </pre> | ||
+ | Those errors about tty and job control have something to do with shell startup and terminal settings, and are normal. Or specify the 'sh' shell in your job script | ||
#get rid of spurious messages about tty/terminal types | #get rid of spurious messages about tty/terminal types | ||
- | + | #$ -S /bin/sh | |
+ | |||
+ | In the mail that you get about the ending of the job, the maxvmem number is actually incorrect, it is a known bug in this version of SGE. The R script on this page actually uses 8GB of vmem. | ||
+ | |||
+ | == Installing CRAN Packages == | ||
+ | |||
+ | Most [http://cran.r-project.org/ CRAN] packages can be installed per-user by running install.packages() in an interactive session: | ||
+ | <pre>install.packages("package_name", dependencies = TRUE) | ||
+ | </pre> | ||
+ | R initially attempts to install to /usr/local/lib/R, but will prompt for the creation of a library subdirectory in ~/R (if necessary) and fall back to installation there when the initial attempt fails. If your package requires dependencies available from the standard Ubuntu [http://packages.ubuntu.com/ repositories] you can submit a [https://remedyweb.stanford.edu/helpsu/helpsu?pcat=farmshare HelpSU ticket] requesting installation. | ||
+ | |||
+ | == Links == | ||
- | + | Some other departments have some other more detailed examples: | |
- | + | *http://wiki.genomics.upenn.edu/index.php/HPC:ExamplesR | |
- | + | *http://me.eng.uab.edu/wiki/index.php?title=R-userinfo | |
- | *http://wiki.genomics.upenn.edu/index.php/HPC:ExamplesR | + | |
- | *http://me.eng.uab.edu/wiki/index.php?title=R-userinfo | + | |
*https://www.stanford.edu/dept/statistics/cgi-bin/projects/stat-sysadminwiki/index.php/R_Jobs | *https://www.stanford.edu/dept/statistics/cgi-bin/projects/stat-sysadminwiki/index.php/R_Jobs |
Revision as of 13:55, 1 February 2012
R Sample Job
Here's an example R file that generates a large array, fills it with some random numbers, then sleeps for 5mins. This happens to use up almost exactly 8GB of RAM.
[chekh@corn-image-new.stanford.edu] /mnt/glusterfs/chekh/R_test [0] $ cat 8GB.R x <- array(1:1073741824, dim=c(1024,1024,1024)) x <- gaussian() Sys.sleep(300)
Here's an example SGE submit script that runs that R file.
$ cat r_test.script #!/bin/bash # use the current directory #$ -cwd # mail this address #$ -M chekh@stanford.edu # send mail on begin, end, suspend #$ -m bes # get rid of spurious messages about tty/terminal types #$ -S /bin/sh R --vanilla --no-save < 8GB.R
You can submit it with just
qsub r_test.script
Here are the output files that I get, one from stderr, one from stdout
$ cat r_test.script.e497 tset: standard error: Function not implemented Undefined tty stdin: is not a tty
$ cat r_test.script.o497Warning: no access to tty (Bad file descriptor). Thus no job control in this shell.
R version 2.12.1 (2010-12-16) Copyright (C) 2010 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R.
> x <- array(1:1073741824, dim=c(1024,1024,1024)) > x <- gaussian() > Sys.sleep(300) >
Those errors about tty and job control have something to do with shell startup and terminal settings, and are normal. Or specify the 'sh' shell in your job script
#get rid of spurious messages about tty/terminal types #$ -S /bin/sh
In the mail that you get about the ending of the job, the maxvmem number is actually incorrect, it is a known bug in this version of SGE. The R script on this page actually uses 8GB of vmem.
Installing CRAN Packages
Most CRAN packages can be installed per-user by running install.packages() in an interactive session:
install.packages("package_name", dependencies = TRUE)
R initially attempts to install to /usr/local/lib/R, but will prompt for the creation of a library subdirectory in ~/R (if necessary) and fall back to installation there when the initial attempt fails. If your package requires dependencies available from the standard Ubuntu repositories you can submit a HelpSU ticket requesting installation.
Links
Some other departments have some other more detailed examples:
- http://wiki.genomics.upenn.edu/index.php/HPC:ExamplesR
- http://me.eng.uab.edu/wiki/index.php?title=R-userinfo
- https://www.stanford.edu/dept/statistics/cgi-bin/projects/stat-sysadminwiki/index.php/R_Jobs