andrewhooker / PopED

Population Experimental Design (PopED) in R
https://andrewhooker.github.io/PopED/
GNU Lesser General Public License v3.0
33 stars 21 forks source link

Parallelization with an mrgsolve model on Windows #36

Open Vincent-AC opened 5 years ago

Vincent-AC commented 5 years ago

Hello,

Thank you for this great tool ! I was trying to optimize some dosing regimens using an mrgsolve model as input for PopED. My OS is Windows 10. It worked fine while mono-threading but when paralellizing i did get this annoying error message :

There was a problem accessing the model shared object.
Either the model object is corrupted or  
  the model was not properly compiled and/or loaded.
Check mrgsolve:::funset(mod) for more information.

After some research I stumbled upon this issue in the mrgsolve github (https://github.com/metrumresearchgroup/mrgsolve/issues/471) where the authors suggested to use the loadso() command to load the model. After trying multiple different places to put this commnad (in the ff.model function for example, makes R crash on my computer), I finally found that by editing the start_parallel script adding these few lines made the parallelization work like a charm :

      # load mrgsolve models in workers using loadso
      if (!is.null(mrgsolve_model)) {
        parallel::clusterCall(cl, loadso, x=mrgsolve_model)
      }

I forked the repository (https://github.com/Vincent-AC/PopED) and added this to the package, would you be interested in a pull request ?

andrewhooker commented 5 years ago

Hi Vincent,

Thanks for the nice work!  I’d be happy to get a pull request from you.

Best regards, Andrew

Andrew Hooker, Ph.D. Associate Professor of Pharmacometrics Dept. of Pharmaceutical Biosciences Uppsala University Box 591, 751 24, Uppsala, Sweden Phone: +46 18 471 4355 Mobile: +46 768 000 725 http://www.farmbio.uu.se/research/researchgroups/pharmacometrics/ On 20 Jun 2019, 19:27 +0200, Vincent ARANZANA-CLIMENT notifications@github.com, wrote:

Hello, Thank you for this great tool ! I was trying to optimize some dosing regimens using an mrgsolve model as input for PopED. My OS is Windows 10. It worked fine while mono-threading but when paralellizing i did get this annoying error message : There was a problem accessing the model shared object. Either the model object is corrupted or the model was not properly compiled and/or loaded. Check mrgsolve:::funset(mod) for more information. After some research I stumbled upon this issue in the mrgsolve github (metrumresearchgroup/mrgsolve#471) where the authors suggested to use the loadso() command to load the model. After trying multiple different places to put this commnad (in the ff.model function for example, makes R crash on my computer), I finally found that by editing the start_parallel script adding these few lines made the parallelization work like a charm :

load mrgsolve models in workers using loadso

 if (!is.null(mrgsolve_model)) {
   parallel::clusterCall(cl, loadso, x=mrgsolve_model)
 }

I forked the repository (https://github.com/Vincent-AC/PopED) and added this to the package, would you be interested in a pull request ? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

Vincent-AC commented 5 years ago

You are welcome, the pull request is up !

Vincent