Hi, From the documentation of ?options Options set in package parallel These will be set when package parallel (or its namespace) is loaded if not already set. mc.cores: a integer giving the maximum allowed number of additional R processes allowed to be run in parallel to the current R process. Defaults to the setting of the environment variable MC_CORES if set. Most applications which use this assume a limit of 2 if it is unset. Then I try: > getOption("mc.cores") NULL I suspect that my environment variable MC_CORES is not set. I test and that's right: > Sys.getenv("MC_CORES") [1] "" Then I do: > Sys.setenv(MC_CORES=4) > Sys.getenv("MC_CORES") [1] "4" But when I try again getOption("mc.cores"); it does not change: > getOption("mc.cores") NULL Probably I do something wrong but I don't see what ! Thanks Marc
Your error is in thinking that environment variables are the same thing as options. While environment variables might be used to set initial values of certain options, options are completely separate from environment variables. If you want to change the option on the fly, then change the option. -- Sent from my phone. Please excuse my brevity. On December 7, 2016 6:26:55 AM PST, Marc Girondot via R-help <r-help at r-project.org> wrote:>Hi, > > From the documentation of ?options > >Options set in package parallel >These will be set when package parallel (or its namespace) is loaded if > >not already set. > >mc.cores: >a integer giving the maximum allowed number of additional R processes >allowed to be run in parallel to the current R process. Defaults to the > >setting of the environment variable MC_CORES if set. Most applications >which use this assume a limit of 2 if it is unset. > >Then I try: > > getOption("mc.cores") >NULL > >I suspect that my environment variable MC_CORES is not set. I test and >that's right: > > Sys.getenv("MC_CORES") >[1] "" > >Then I do: > > Sys.setenv(MC_CORES=4) > > Sys.getenv("MC_CORES") >[1] "4" > >But when I try again getOption("mc.cores"); it does not change: > > getOption("mc.cores") >NULL > >Probably I do something wrong but I don't see what ! > >Thanks > >Marc > >______________________________________________ >R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide >http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code.
On Wed, Dec 7, 2016 at 7:04 AM, Jeff Newmiller <jdnewmil at dcn.davis.ca.us> wrote:> Your error is in thinking that environment variables are the same thing as options. While environment variables might be used to set initial values of certain options, options are completely separate from environment variables. If you want to change the option on the fly, then change the option.i.e. ?options -- Bert> -- > Sent from my phone. Please excuse my brevity. > > On December 7, 2016 6:26:55 AM PST, Marc Girondot via R-help <r-help at r-project.org> wrote: >>Hi, >> >> From the documentation of ?options >> >>Options set in package parallel >>These will be set when package parallel (or its namespace) is loaded if >> >>not already set. >> >>mc.cores: >>a integer giving the maximum allowed number of additional R processes >>allowed to be run in parallel to the current R process. Defaults to the >> >>setting of the environment variable MC_CORES if set. Most applications >>which use this assume a limit of 2 if it is unset. >> >>Then I try: >> > getOption("mc.cores") >>NULL >> >>I suspect that my environment variable MC_CORES is not set. I test and >>that's right: >> > Sys.getenv("MC_CORES") >>[1] "" >> >>Then I do: >> > Sys.setenv(MC_CORES=4) >> > Sys.getenv("MC_CORES") >>[1] "4" >> >>But when I try again getOption("mc.cores"); it does not change: >> > getOption("mc.cores") >>NULL >> >>Probably I do something wrong but I don't see what ! >> >>Thanks >> >>Marc >> >>______________________________________________ >>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see >>https://stat.ethz.ch/mailman/listinfo/r-help >>PLEASE do read the posting guide >>http://www.R-project.org/posting-guide.html >>and provide commented, minimal, self-contained, reproducible code. > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
On Wed, 7 Dec 2016, Marc Girondot via R-help wrote:> Hi, > > From the documentation of ?options > > Options set in package parallel > These will be set when package parallel (or its namespace) is loaded if not > already set. > > mc.cores: > a integer giving the maximum allowed number of additional R processes allowed > to be run in parallel to the current R process. Defaults to the setting of > the environment variable MC_CORES if set. Most applications which use this > assume a limit of 2 if it is unset. >As advertised. - Start R with no MC_CORES specified: - check environment var - set environment var - check options - THEN load parallel - check option again Sys.getenv("MC_CORES") [1] ""> Sys.setenv("MC_CORES"=3L) > options("mc.cores")$mc.cores NULL> library(parallel) > options("mc.cores")$mc.cores [1] 3 --- I think you confused things by loading parallel *before* setting the environment var. HTH, Chuck