I would like to increase the niceness of my cluster jobs. The following code is successful:
> cl <- makePSOCKcluster(rep('localhost', 2))
> clusterEvalQ(cl = cl, rnorm(3))
[[1]]
[1] -0.6452848 -0.9899609 0.3083131
[[2]]
[1] 1.1687733 -0.1930413 1.1576510
This, however, is not.
cl <- makePSOCKcluster(names = rep('localhost', 8), renice = 15)
nice: +15: No such file or directory
I am able to set the niceness after cluster creation using the following code:
clusterEvalQ(cl = cl, tools::psnice(value = 15))
After reading the documentation for makePSOCKcluster
, I'm not sure what I'm doing wrong in the cluster creation step, and have been unable to track down the issue. How can I create a cluster and set the niceness of the worker threads all at the same time?
I consider this to be a bug in the "parallel" package. When you use the makePSOCKcluster "renice" option, it uses a form of the "nice" command that doesn't work with bash, but I believe works with csh/tcsh. You can see the generated command by using the "manual=TRUE" option:
> library(parallel)
> cl <- makePSOCKcluster(2, renice=15, manual=TRUE)
Manually start worker on localhost with
nice +15 '/home/sw/R/sources/R-3.3.0/bin/Rscript' --default-packages=datasets,utils,grDevices,graphics,stats,methods -e 'parallel:::.slaveRSOCK()' MASTER=localhost PORT=11379 OUT=/dev/null TIMEOUT=2592000 XDR=TRUE
If you try to execute this from bash, you will get the same error message that you reported. The syntax for bash should be:
$ nice -n 15 '/home/sw/R/sources/R-3.3.0/bin/Rscript' ...