Install R & packages on CHTC:
(详见 http://chtc.cs.wisc.edu/r-jobs.shtml#version )
prepare
- downloads R-3.x.x.tar.gz on laptop (https://cran.r-project.org)
- upload R-3.x.x.tar.gz on CHTC
- create Create a Portable R Installation in an Interactive Job (http://chtc.cs.wisc.edu/inter-submit.shtml)
a file called interactive.sub 具体内容:
universe = vanilla
# Name the log file:
log = interactive.log
# Name the files where standard output and error should be saved:
output = process.out
error = process.err
# If you wish to compile code, you'll need the below lines.
# Otherwise, LEAVE THEM OUT if you just want to interactively test!
+IsBuildJob = true
requirements = (OpSysMajorVer =?= 6) && ( IsBuildSlot == true )
# If you need CentOS 7 (our new operating system), use the following
# requirements instead of the above line:
# requirements = (OpSysMajorVer =?= 7) && ( IsBuildSlot == true )
# Indicate all files that need to go into the interactive job session,
# including any tar files that you prepared:
# transfer_input_files = combined.tar.gz, other_file.txt
transfer_input_files = R-3.x.x.tar.gz
# It's still important to request enough computing resources. The below
# values are a good starting point, but consider your file sizes for an
# estimate of "disk" and use any other information you might have
# for "memory" and/or "cpus".
request_cpus = 1
request_memory = 1GB
request_disk =1GB
queue
- submit interactive job: condor_submit -i interactive.sub (接下来在该job情况下直接运行代码)
install R
- tar -xzf R-3.x.x.tar.gz
- cd R-3.x.x
- ./configure --prefix=$(pwd)
- make
- make install
- cd …
install packages
- R-3.x.x/lib64/R/bin/R
- install.packages(‘package_name’)
edit the R executable
- nano R-3.x.x/lib64/R/bin/R
- 在里面第一行修改路径: 把R_HOME_DIR=/var/lib/condor/execute/slot1/dir_554715/R-3.1.0/lib64/R
改成R_HOME_DIR=$(pwd)/R
exit the Interactive Job
- mv R-3.x.x/lib64/R ./
- tar -czvf R.tar.gz R/
- exit
结束后会有R.tar.gz这个包,之后写sh文件时放进去,就能用里面的包了:
#!/bin/bash
# untar your R installation
tar -xzf R.tar.gz
# make sure the script will use your R installation
export PATH=$(pwd)/R/bin:$PATH
export RHOME=$(pwd)/R
# run R, with the name of your R script
Rscript myscript.R