TaylorJones94
TaylorJones94

Reputation: 1

Avoid Runtime Error Caused by Multiprocessing in Windows

I'm trying to run the code found here: https://github.com/iraur/MMM_PyMC_demo/blob/main/demo.ipynb on my Windows machine (an MMM built using PyMC and PyMC Marketing), however every time I try and run it I get a RuntimeError (below) that's caused by multiprocessing. I've tried wrapping the whole script in a if __name__ == '__main__':

but it's still triggering the same issue below:

RuntimeError:
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.

        To fix this issue, refer to the "Safe importing of main module"
        section in https://docs.python.org/3/library/multiprocessing.html

As far as I was aware, wrapping the script in if __name__ == '__main__':

should work to handle multiprocessing, however it doesn't seem to make a difference here. The error appears to be triggered by the line

   trace = pm.sample(draws=1000, # number of samples to draw from posterior distribution

regardless of how many cores I use.

Any suggestions very welcome!

Upvotes: 0

Views: 79

Answers (0)

Related Questions