mclapply

Printing from mclapply in R Studio

人盡茶涼 提交于 2019-12-05 12:52:34
问题 I am using mclapply from within RStudio and would like to have an output to the console from each process but this seems to be suppressed somehow (as mentioned for example here: Is mclapply guaranteed to return its results in order?). How could I get R Studio to print something like x <- mclapply(1:20, function(i) cat(i, "\n")) to the console? I've tried print(), cat(), write() but they all seem not to work. I also tried to set mc.silent = FALSE explicitly without an effect. 回答1: Parallel

Parallel processing of big rasters in R (windows)

安稳与你 提交于 2019-12-05 03:32:42
I'm using the doSNOW package and more specifically the parLapply function to perform reclassification (and subsequently other operations) on a list of big raster datasets (OS: Windows x64). The code looks a little like this minimalistic example: library(raster) library(doSNOW) #create list containing test rasters x <- raster(ncol=10980,nrow=10980) x <- setValues(x,1:ncell(x)) list.x <- replicate( 9 , x ) #setting up cluster NumberOfCluster <- 8 cl <- makeCluster(NumberOfCluster) registerDoSNOW(cl) junk <- clusterEvalQ(cl,library(raster)) #perform calculations on each raster list.x <- parLapply

R error with mclapply in a foreach loop

不羁的心 提交于 2019-12-04 16:02:29
Based on this post here , I tried to write a script, seen here: library(parallel) library(doParallel) cl<-makeCluster(2,outfile='') registerDoParallel(cl) foreach(i=1:5, .packages='parallel') %dopar% { system.time(mclapply(1:10, function(x){rnorm(1e5)},mc.cores=2)) } stopCluster(cl) It worked intially but is now throwing up error codes: Error in unserialize(node$con) : error reading from connection Calls: <Anonymous> ... doTryCatch -> recvData -> recvData.SOCKnode -> unserialize Execution halted Error in unserialize(socklist[[n]]) : error reading from connection Error in unserialize(node$con)

Printing from mclapply in R Studio

微笑、不失礼 提交于 2019-12-04 02:00:37
I am using mclapply from within RStudio and would like to have an output to the console from each process but this seems to be suppressed somehow (as mentioned for example here: Is mclapply guaranteed to return its results in order? ). How could I get R Studio to print something like x <- mclapply(1:20, function(i) cat(i, "\n")) to the console? I've tried print(), cat(), write() but they all seem not to work. I also tried to set mc.silent = FALSE explicitly without an effect. Parallel processing with GUI's is problematic. I write a lot of parallel code and it's constantly crashing my colleague

parallel r with foreach and mclapply at the same time

青春壹個敷衍的年華 提交于 2019-12-03 08:52:21
I am implementing a parallel processing system which will eventually be deployed on a cluster, but I'm having trouble working out how the various methods of parallel processing interact. I need to use a for loop to run a big block of code, which contains several large list of matrices operations. To speed this up, I want to parallelise the for loop with a foreach(), and parallelise the list operations with mclapply. example pseudocode: cl<-makeCluster(2) registerDoParallel(cl) outputs <- foreach(k = 1:2, .packages = "various packages") { l_output1 <- mclapply(l_input1, function, mc.cores = 2)

Understanding the differences between mclapply and parLapply in R

心已入冬 提交于 2019-12-03 02:20:47
问题 I've recently started using parallel techniques in R for a project and have my program working on Linux systems using mclapply from the parallel package. However, I've hit a road block with my understanding of parLapply for Windows. Using mclapply I can set the number of cores, iterations, and pass that to an existing function in my workspace. mclapply(1:8, function(z) adder(z, 100), mc.cores=4) I don't seem to be able to achieve the same in windows using parLapply . As I understand it, I

Is there way to track progress on a mclapply?

柔情痞子 提交于 2019-12-03 02:16:33
问题 I love the setting .progress = 'text' in plyr's llply . However, it causes my much anxiety to not know how far along an mclapply (from package multicore ) is since list items are sent to various cores and then collated at the end. I've been outputting messages like *currently in sim_id # ....* but that's not very helpful because it doesn't give me an indicator of what percentage of list items are complete (although it is helpful to know that that my script isn't stuck and moving along). Can

Is there way to track progress on a mclapply?

纵然是瞬间 提交于 2019-12-02 17:16:34
I love the setting .progress = 'text' in plyr's llply . However, it causes my much anxiety to not know how far along an mclapply (from package multicore ) is since list items are sent to various cores and then collated at the end. I've been outputting messages like *currently in sim_id # ....* but that's not very helpful because it doesn't give me an indicator of what percentage of list items are complete (although it is helpful to know that that my script isn't stuck and moving along). Can someone suggest other ideas that would allow me to look at my .Rout file and get a sense of progress? I

Speed-up data.table group by using multiple cores and parallel programming

◇◆丶佛笑我妖孽 提交于 2019-11-28 16:32:20
问题 I have a large code and the aggregation step is the current bottleneck in terms of speed. In my code I'd like to speed-up the data grouping step to be faster. A SNOTE (simple non trivial example) of my data looks like this: library(data.table) a = sample(1:10000000, 50000000, replace = TRUE) b = sample(c("3m","2m2d2m","3m2d1i3s2d","5m","4m","9m","1m"), 50000000, replace = TRUE) d = sample(c("3m","2m2d2m","3m2d1i3s2d","5m","4m","9m","1m"), 50000000, replace = TRUE) e = a dt = data.table(a = a,

tm_map has parallel::mclapply error in R 3.0.1 on Mac

假如想象 提交于 2019-11-27 22:50:20
I am using R 3.0.1 on Platform: x86_64-apple-darwin10.8.0 (64-bit) I am trying to use tm_map from the tm library. But when I execute the this code library(tm) data('crude') tm_map(crude, stemDocument) I get this error: Warning message: In parallel::mclapply(x, FUN, ...) : all scheduled cores encountered errors in user code Does anyone know a solution for this? I suspect you don't have the SnowballC package installed, which seems to be required. tm_map is supposed to run stemDocument on all the documents using mclapply . Try just running the stemDocument function on one document, so you can