none
I really can't believe that this BUG is going to happen for MRO! Help!!! RRS feed

  • Question

  • U=matrix(runif(5000*5000),5000)
    X=matrix(1,5000)

    myf=function(x){crossprod(U,X)}

    myCross=crossprod(U,X)
    myCross.para=mclapply(1:10,myf,mc.cores=5)

    When I enter the above codes in MRO of MAC, there is a strange error and i don't know how to avoid this error. I think this math calculation is very normal and common, i can't believe that this BUG is going to happen for MRO! Really hope the team of MRO can fix this bug!

    Thursday, February 9, 2017 6:55 AM

Answers

  • Hello,

    I seems that the forked processes of mclapply are getting confused by the multiple threads from Mac's Accelerate. 

    The workaround for this issue is to set Accelerate to use 1 thread using an environment var.

    Sys.setenv("VECLIB_MAXIMUM_THREADS" = "1")

    This post may also help you. http://blog.revolutionanalytics.com/2015/10/edge-cases-in-using-the-intel-mkl-and-parallel-programming.html

    Thanks, Josee



    Friday, February 10, 2017 6:04 PM
    Moderator

All replies

  • Can you share the error message and behavior you are getting?
    Thursday, February 9, 2017 1:32 PM
    Moderator
  • Thanks for your reply! I have copied the output from my screen about the error: 

    *** caught segfault ***
    address 0x110, cause 'memory not mapped'

     *** caught segfault ***
    address 0x110, cause 'memory not mapped'

     *** caught segfault ***
    address 0x110, cause 'memory not mapped'

     *** caught segfault ***
    address 0x110, cause 'memory not mapped'

    Traceback:
     1: crossprod(U, X)
     2: FUN(X[[i]], ...)
     3: lapply(X = S, FUN = FUN, ...)
     4: doTryCatch(return(expr), name, parentenv, handler)
     5: tryCatchOne(expr, names, parentenv, handlers[[1L]])
     6: tryCatchList(expr, classes, parentenv, handlers)
     7: tryCatch(expr, error = function(e) {    call <- conditionCall(e)    if (!is.null(call)) {        if (identical(call[[1L]], quote(doTryCatch)))             call <- sys.call(-4L)        dcall <- deparse(call)[1L]        prefix <- paste("Error in", dcall, ": ")        LONG <- 75L        msg <- conditionMessage(e)        sm <- strsplit(msg, "\n")[[1L]]        w <- 14L + nchar(dcall, type = "w") + nchar(sm[1L], type = "w")        if (is.na(w))             w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L],                 type = "b")        if (w > LONG)             prefix <- paste0(prefix, "\n  ")    }    else prefix <- "Error : "    msg <- paste0(prefix, conditionMessage(e), "\n")    .Internal(seterrmessage(msg[1L]))    if (!silent && identical(getOption("show.error.messages"),         TRUE)) {        cat(msg, file = stderr())        .Internal(printDeferredWarnings())    }    invisible(structure(msg, class = "try-error", condition = e))})
     8: try(lapply(X = S, FUN = FUN, ...), silent = TRUE)
     9: sendMaster(try(lapply(X = S, FUN = FUN, ...), silent = TRUE))
    10: FUN(X[[i]], ...)
    11: lapply(seq_len(cores), inner.do)
    12: mclapply(1:10, myf, mc.cores = 5)

    Possible actions:
    1: abort (with core dump, if enabled)
    2: normal R exit
    3: exit R without saving workspace
    4: exit R saving workspace
    Selection: 
     *** caught segfault ***
    address 0x110, cause 'memory not mapped'


    Traceback:
    Traceback:
     1:  1: crossprod(U, X)crossprod(U, X)

     2:  2: FUN(X[[i]], ...)FUN(X[[i]], ...)

     3:  3: lapply(X = S, FUN = FUN, ...)lapply(X = S, FUN = FUN, ...)

     4:  4: doTryCatch(return(expr), name, parentenv, handler)doTryCatch(return(expr), name, parentenv, handler)

     5:  5: tryCatchOne(expr, names, parentenv, handlers[[1L]])tryCatchOne(expr, names, parentenv, handlers[[1L]])

     6:  6: tryCatchList(expr, classes, parentenv, handlers)tryCatchList(expr, classes, parentenv, handlers)

     7:  7: tryCatch(expr, error = function(e) {tryCatch(expr, error = function(e) {    call <- conditionCall(e)    call <- conditionCall(e)    if (!is.null(call)) {    if (!is.null(call)) {        if (identical(call[[1L]], quote(doTryCatch)))         if (identical(call[[1L]], quote(doTryCatch)))             call <- sys.call(-4L)            call <- sys.call(-4L)        dcall <- deparse(call)[1L]        dcall <- deparse(call)[1L]        prefix <- paste("Error in", dcall, ": ")        prefix <- paste("Error in", dcall, ": ")        LONG <- 75L        LONG <- 75L        msg <- conditionMessage(e)        msg <- conditionMessage(e)        sm <- strsplit(msg, "\n")[[1L]]        sm <- strsplit(msg, "\n")[[1L]]        w <- 14L + nchar(dcall, type = "w") + nchar(sm[1L], type = "w")        w <- 14L + nchar(dcall, type = "w") + nchar(sm[1L], type = "w")        if (is.na(w))         if (is.na(w))             w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L],             w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L],                 type = "b")                type = "b")        if (w > LONG)         if (w > LONG)             prefix <- paste0(prefix, "\n  ")            prefix <- paste0(prefix, "\n  ")    }    }    else prefix <- "Error : "    else prefix <- "Error : "    msg <- paste0(prefix, conditionMessage(e), "\n")    msg <- paste0(prefix, conditionMessage(e), "\n")    .Internal(seterrmessage(msg[1L]))    .Internal(seterrmessage(msg[1L]))    if (!silent && identical(getOption("show.error.messages"),     if (!silent && identical(getOption("show.error.messages"),         TRUE)) {        TRUE)) {        cat(msg, file = stderr())        cat(msg, file = stderr())        .Internal(printDeferredWarnings())        .Internal(printDeferredWarnings())    }    }    invisible(structure(msg, class = "try-error", condition = e))})    invisible(structure(msg, class = "try-error", condition = e))
    }) 8: 
    try(lapply(X = S, FUN = FUN, ...), silent = TRUE)
     8:  9: try(lapply(X = S, FUN = FUN, ...), silent = TRUE)sendMaster(try(lapply(X = S, FUN = FUN, ...), silent = TRUE))

    10:  9: FUN(X[[i]], ...)
    sendMaster(try(lapply(X = S, FUN = FUN, ...), silent = TRUE))
    11: lapply(seq_len(cores), inner.do)10: 
    FUN(X[[i]], ...)
    12: mclapply(1:10, myf, mc.cores = 5)11: 
    lapply(seq_len(cores), inner.do)

    12: Possible actions:
    1: abort (with core dump, if enabled)
    mclapply(1:10, myf, mc.cores = 5)2: normal R exit

    3: exit R without saving workspace
    4: exit R saving workspace

    Possible actions:
    1: abort (with core dump, if enabled)
    2: normal R exit
    3: exit R without saving workspace
    4: exit R saving workspace
    Selection: Selection: 
    Traceback:
     1: crossprod(U, X)
     2: FUN(X[[i]], ...)
     3: lapply(X = S, FUN = FUN, ...)
     4: doTryCatch(return(expr), name, parentenv, handler)
     5: tryCatchOne(expr, names, parentenv, handlers[[1L]])
     6: tryCatchList(expr, classes, parentenv, handlers)
     7: tryCatch(expr, error = function(e) {    call <- conditionCall(e)    if (!is.null(call)) {        if (identical(call[[1L]], quote(doTryCatch)))             call <- sys.call(-4L)        dcall <- deparse(call)[1L]        prefix <- paste("Error in", dcall, ": ")        LONG <- 75L        msg <- conditionMessage(e)        sm <- strsplit(msg, "\n")[[1L]]        w <- 14L + nchar(dcall, type = "w") + nchar(sm[1L], type = "w")        if (is.na(w))             w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L],                 type = "b")        if (w > LONG)             prefix <- paste0(prefix, "\n  ")    }    else prefix <- "Error : "    msg <- paste0(prefix, conditionMessage(e), "\n")    .Internal(seterrmessage(msg[1L]))    if (!silent && identical(getOption("show.error.messages"),         TRUE)) {        cat(msg, file = stderr())        .Internal(printDeferredWarnings())    }    invisible(structure(msg, class = "try-error", condition = e))})
     8: try(lapply(X = S, FUN = FUN, ...), silent = TRUE)
     9: sendMaster(try(lapply(X = S, FUN = FUN, ...), silent = TRUE))
    10: FUN(X[[i]], ...)
    11: lapply(seq_len(cores), inner.do)
    12: mclapply(1:10, myf, mc.cores = 5)

    Possible actions:
    1: abort (with core dump, if enabled)
    2: normal R exit
    3: exit R without saving workspace
    4: exit R saving workspace
    Selection: 
    Traceback:
     1: crossprod(U, X)
     2: FUN(X[[i]], ...)
     3: lapply(X = S, FUN = FUN, ...)
     4: doTryCatch(return(expr), name, parentenv, handler)
     5: tryCatchOne(expr, names, parentenv, handlers[[1L]])
     6: tryCatchList(expr, classes, parentenv, handlers)
     7: tryCatch(expr, error = function(e) {    call <- conditionCall(e)    if (!is.null(call)) {        if (identical(call[[1L]], quote(doTryCatch)))             call <- sys.call(-4L)        dcall <- deparse(call)[1L]        prefix <- paste("Error in", dcall, ": ")        LONG <- 75L        msg <- conditionMessage(e)        sm <- strsplit(msg, "\n")[[1L]]        w <- 14L + nchar(dcall, type = "w") + nchar(sm[1L], type = "w")        if (is.na(w))             w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L],                 type = "b")        if (w > LONG)             prefix <- paste0(prefix, "\n  ")    }    else prefix <- "Error : "    msg <- paste0(prefix, conditionMessage(e), "\n")    .Internal(seterrmessage(msg[1L]))    if (!silent && identical(getOption("show.error.messages"),         TRUE)) {        cat(msg, file = stderr())        .Internal(printDeferredWarnings())    }    invisible(structure(msg, class = "try-error", condition = e))})
     8: try(lapply(X = S, FUN = FUN, ...), silent = TRUE)
     9: sendMaster(try(lapply(X = S, FUN = FUN, ...), silent = TRUE))
    10: FUN(X[[i]], ...)
    11: lapply(seq_len(cores), inner.do)
    12: mclapply(1:10, myf, mc.cores = 5)

    Possible actions:
    1: abort (with core dump, if enabled)
    2: normal R exit
    3: exit R without saving workspace
    4: exit R saving workspace
    Selection: 

     
    Friday, February 10, 2017 12:35 PM
  • Hello,

    I seems that the forked processes of mclapply are getting confused by the multiple threads from Mac's Accelerate. 

    The workaround for this issue is to set Accelerate to use 1 thread using an environment var.

    Sys.setenv("VECLIB_MAXIMUM_THREADS" = "1")

    This post may also help you. http://blog.revolutionanalytics.com/2015/10/edge-cases-in-using-the-intel-mkl-and-parallel-programming.html

    Thanks, Josee



    Friday, February 10, 2017 6:04 PM
    Moderator
  • Hi! Josee,

    Thanks for your reply! It works well when following your suggestion("Sys.setenv("VECLIB_MAXIMUM_THREADS" = "1")"), and there is no error when i use mclapply, but another question makes me confused, if the mclapply() function finished, i want to start muti-threads, so i set "Sys.setenv("VECLIB_MAXIMUM_THREADS" = "4")", but unfortunately it doesn't work, only one thread can be used during my math calculation. Could you please give me some suggestion about this question?

    Thanks, YinLL

    Saturday, February 11, 2017 9:06 AM
  • I'm not sure why. Did you try restarting R? That's the only workaround we've found to this Accelerate issue. 
    Tuesday, February 14, 2017 6:19 PM
    Moderator