Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[SOLVED] %dopar% operator incorrectly load balancing in R

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
antishatter
Posts: 4
Joined: 2015-05-12 15:34

[SOLVED] %dopar% operator incorrectly load balancing in R

#1 Post by antishatter »

am using R version 3.1.2 with rstudio-server 0.98.113 on debian build 3.2.0-4-amd64 #1 SMP Debian 3.2.68-1+deb7u1 x86_64 GNU/Linux.

I often use the %dopar% operator in from the foreach package to run code in parallel. However, the only other use on the box seemingly installed a few items and suddenly %dopar% will use far more than the number of cores I am specifying and seems to load balance between all of them. The issue with this is that it doesn't actually seem to perform non-trivial tasks at all anymore.

This is an example of testing code I've been using for testing the %dopar% loop.

Code: Select all

library(iterators)
library(foreach)
library(doParallel)
library(Parallel)
nCores <- 4

cl <- makeCluster(nCores)
registerDoParallel(cl)
trials = 100000

x <- iris[which(iris[,5] != "setosa"),c(1,5)]
    t2 <- system.time({
    r2 <- foreach(icount(trials), .combine=cbind) %dopar% {
    ind <- sample(100,100,replace= TRUE)
    results1 <- glm(x[ind,2]~x[ind,1],family=binomial(logit))
    coefficients(results1)
   }
})[3]

stopCluster(cl)
Another interesting behavior is that I can now stop R code that should be running on the slave workers where as previously I had to use a kill command to handle the workers.

I have checked the system logs and can't seem to find what's been changed so it's unclear to me exactly how to proceed. It is almost reminiscent of a change in the BLAS library but this behavior persists after recompiling R to not use the shared BLAS lib.

here is the output from lsof -p 23618 | grep 'blas\|lapack'

Code: Select all

R       39781 mem    REG               8,17  3576576 1055038 /usr/local/lib/R/lib/libRlapack.so
R       39781 mem    REG               8,17   655336 1572936 /usr/lib/libblas/libblas.so.3.0
Output from R CMD ldd /usr/local/lib/R/bin/exec/R

Code: Select all

linux-vdso.so.1 (0x00007ffca59fd000)
libR.so => /usr/local/lib/R/lib/libR.so (0x00007f15fdc30000)
libgomp.so.1 => /usr/lib/x86_64-linux-gnu/libgomp.so.1 (0x00007f15fd9f7000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f15fd7da000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f15fd431000)
libblas.so.3 => /usr/lib/libblas.so.3 (0x00007f15fd190000)
libgfortran.so.3 => /usr/lib/x86_64-linux-gnu/libgfortran.so.3 (0x00007f15fce72000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f15fcb71000)
libquadmath.so.0 => /usr/lib/x86_64-linux-gnu/libquadmath.so.0 (0x00007f15fc933000)
libreadline.so.6 => /lib/x86_64-linux-gnu/libreadline.so.6 (0x00007f15fc6e9000)
liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f15fc4c6000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f15fc2bd000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f15fc0b9000)
libicuuc.so.48 => /usr/lib/x86_64-linux-gnu/libicuuc.so.48 (0x00007f15fbd4a000)
libicui18n.so.48 => /usr/lib/x86_64-linux-gnu/libicui18n.so.48 (0x00007f15fb97e000)
/lib64/ld-linux-x86-64.so.2 (0x00007f15fe1cf000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f15fb768000)
libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007f15fb53d000)
libicudata.so.48 => /usr/lib/x86_64-linux-gnu/libicudata.so.48 (0x00007f15fa1cd000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f15f9ec2000)

Is it possible to rebuild R without any shared library's? I am open to any suggestions at this point.

Thanks for your help guys!
Last edited by antishatter on 2016-05-11 14:31, edited 2 times in total.

User avatar
dasein
Posts: 7680
Joined: 2011-03-04 01:06
Location: Terra Incantationum

Re: Foreach %dopar% operator incorrectly load balancing in R

#2 Post by dasein »

Because your question is all about R, and nothing about Debian, your highest probability of a satisfactory answer would come from posting your question in a R forum. (Just sayin')

antishatter
Posts: 4
Joined: 2015-05-12 15:34

Re: Foreach %dopar% operator incorrectly load balancing in R

#3 Post by antishatter »

dasein wrote:Because your question is all about R, and nothing about Debian, your highest probability of a satisfactory answer would come from posting your question in a R forum. (Just sayin')
I do agree with you however I was hoping someone here might be able to spot interesting dependencies in the ldd output.

User avatar
dasein
Posts: 7680
Joined: 2011-03-04 01:06
Location: Terra Incantationum

Re: Foreach %dopar% operator incorrectly load balancing in R

#4 Post by dasein »

Well, there's only a couple of R gurus hereabouts, and they don't necessarily visit all that often. So an answer may be slow in coming, if it comes at all. (Just FYI)

User avatar
edbarx
Posts: 5401
Joined: 2007-07-18 06:19
Location: 35° 50 N, 14 º 35 E
Been thanked: 2 times

Re: Foreach %dopar% operator incorrectly load balancing in R

#5 Post by edbarx »

antishatter wrote:Is it possible to rebuild R without any shared library's? I am open to any suggestions at this point.

Thanks for your help guys!
It depends what you mean by without any shared libraries. If you mean to built one executable containing all imported functions, I should think it is possible. Look up static linking.

http://www.linuxquestions.org/questions ... es-696714/
Debian == { > 30, 000 packages }; Debian != systemd
The worst infection of all, is a false sense of security!
It is hard to get away from CLI tools.

antishatter
Posts: 4
Joined: 2015-05-12 15:34

Re: Foreach %dopar% operator incorrectly load balancing in R

#6 Post by antishatter »

edbarx wrote:
antishatter wrote:Is it possible to rebuild R without any shared library's? I am open to any suggestions at this point.

Thanks for your help guys!
It depends what you mean by without any shared libraries. If you mean to built one executable containing all imported functions, I should think it is possible. Look up static linking.

http://www.linuxquestions.org/questions ... es-696714/
Thank's I'll give this a shot. Hoping to not have to pull the 'rebuild a bunch of packages to fix an issue' rookie level of move.

antishatter
Posts: 4
Joined: 2015-05-12 15:34

Re: Foreach %dopar% operator incorrectly load balancing in R

#7 Post by antishatter »

edbarx wrote:
antishatter wrote:Is it possible to rebuild R without any shared library's? I am open to any suggestions at this point.

Thanks for your help guys!
It depends what you mean by without any shared libraries. If you mean to built one executable containing all imported functions, I should think it is possible. Look up static linking.

http://www.linuxquestions.org/questions ... es-696714/
Hey I got this working, thanks!

Edit: How do I mark this solved?

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: Foreach %dopar% operator incorrectly load balancing in R

#8 Post by Head_on_a_Stick »

antishatter wrote:How do I mark this solved?
Edit the title of your first post in this thread & add "[SOLVED]" to the start.
deadbang

Post Reply