{"action":"created","issue":{"url":"https://api.github.com/repos/pymc-devs/pymc3/issues/1033","repository_url":"https://api.github.com/repos/pymc-devs/pymc3","labels_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/1033/labels{/name}","comments_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/1033/comments","events_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/1033/events","html_url":"https://github.com/pymc-devs/pymc3/issues/1033","id":142863716,"number":1033,"title":"mixture model failure with njobs > 1","user":{"login":"DeliciousHair","id":6540809,"avatar_url":"https://avatars.githubusercontent.com/u/6540809?v=3","gravatar_id":"","url":"https://api.github.com/users/DeliciousHair","html_url":"https://github.com/DeliciousHair","followers_url":"https://api.github.com/users/DeliciousHair/followers","following_url":"https://api.github.com/users/DeliciousHair/following{/other_user}","gists_url":"https://api.github.com/users/DeliciousHair/gists{/gist_id}","starred_url":"https://api.github.com/users/DeliciousHair/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DeliciousHair/subscriptions","organizations_url":"https://api.github.com/users/DeliciousHair/orgs","repos_url":"https://api.github.com/users/DeliciousHair/repos","events_url":"https://api.github.com/users/DeliciousHair/events{/privacy}","received_events_url":"https://api.github.com/users/DeliciousHair/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-03-23T05:10:28Z","updated_at":"2016-04-18T11:08:43Z","closed_at":null,"body":"Greetings!\r\n\r\nI'm trying to speed up a rather lengthy sampling process on a mixture model, first thing to try was simply using the `njobs=` flag in `sample()`.  This is not working...\r\n\r\nAs a minimal example, if I alter the example provided [here](https://github.com/pymc-devs/pymc3/blob/master/pymc3/examples/gaussian_mixture_model.ipynb) from:\r\n```\r\n    tr = pm.sample(10000, step=[step1, step2])\r\n```\r\nto\r\n```\r\n   tr = pm.sample(10000, step=[step1, step2], njobs=3)\r\n```\r\nthen I get:\r\n```\r\nApplied stickbreaking-transform to p and added transformed p_stickbreaking to model.\r\nApplied interval-transform to sd and added transformed sd_interval to model.\r\n---------------------------------------------------------------------------\r\nRemoteTraceback                           Traceback (most recent call last)\r\nRemoteTraceback: \r\n\"\"\"\r\nTraceback (most recent call last):\r\n  File \"/usr/local/lib/python3.4/dist-packages/theano/compile/function_module.py\", line 859, in __call__\r\n    outputs = self.fn()\r\nIndexError: index 3 is out of bounds for size 3\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n  File \"/usr/lib/python3.4/multiprocessing/pool.py\", line 119, in worker\r\n    result = (True, func(*args, **kwds))\r\n  File \"/usr/lib/python3.4/multiprocessing/pool.py\", line 44, in mapstar\r\n    return list(map(*args))\r\n  File \"/usr/local/lib/python3.4/dist-packages/pymc3/sampling.py\", line 296, in argsample\r\n    return _sample(*args)\r\n  File \"/usr/local/lib/python3.4/dist-packages/pymc3/sampling.py\", line 165, in _sample\r\n    for i, strace in enumerate(sampling):\r\n  File \"/usr/local/lib/python3.4/dist-packages/pymc3/sampling.py\", line 247, in _iter_sample\r\n    point = step.step(point)\r\n  File \"/usr/local/lib/python3.4/dist-packages/pymc3/step_methods/compound.py\", line 14, in step\r\n    point = method.step(point)\r\n  File \"/usr/local/lib/python3.4/dist-packages/pymc3/step_methods/compound.py\", line 14, in step\r\n    point = method.step(point)\r\n  File \"/usr/local/lib/python3.4/dist-packages/pymc3/step_methods/compound.py\", line 14, in step\r\n    point = method.step(point)\r\n  File \"/usr/local/lib/python3.4/dist-packages/pymc3/step_methods/arraystep.py\", line 118, in step\r\n    apoint = self.astep(bij.map(point))\r\n  File \"/usr/local/lib/python3.4/dist-packages/pymc3/step_methods/metropolis.py\", line 125, in astep\r\n    q_new = metrop_select(self.delta_logp(q,q0), q, q0)\r\n  File \"/usr/local/lib/python3.4/dist-packages/theano/compile/function_module.py\", line 871, in __call__\r\n    storage_map=getattr(self.fn, 'storage_map', None))\r\n  File \"/usr/local/lib/python3.4/dist-packages/theano/gof/link.py\", line 314, in raise_with_op\r\n    reraise(exc_type, exc_value, exc_trace)\r\n  File \"/usr/local/lib/python3.4/dist-packages/six.py\", line 685, in reraise\r\n    raise value.with_traceback(tb)\r\n  File \"/usr/local/lib/python3.4/dist-packages/theano/compile/function_module.py\", line 859, in __call__\r\n    outputs = self.fn()\r\nIndexError: index 3 is out of bounds for size 3\r\nApply node that caused the error: AdvancedSubtensor1(p, Subtensor{int64:int64:}.0)\r\nToposort index: 28\r\nInputs types: [TensorType(float64, vector), TensorType(int64, vector)]\r\nInputs shapes: [(3,), (2000,)]\r\nInputs strides: [(8,), (8,)]\r\nInputs values: [array([ 0.33333333,  0.33333333,  0.33333333]), 'not shown']\r\nOutputs clients: [[Elemwise{Composite{Switch((GE(i0, i1) * LE(i0, i2) * i3), log(i4), i5)}}[(0, 4)](Subtensor{int64:int64:}.0, TensorConstant{(1,) of 0}, Elemwise{Add}[(0, 1)].0, Elemwise{Composite{LE(Abs((i0 + i1)), i2)}}.0, AdvancedSubtensor1.0, TensorConstant{(1,) of -inf})]]\r\n\r\nBacktrace when the node is created:\r\n  File \"/usr/local/lib/python3.4/dist-packages/pymc3/distributions/discrete.py\", line 379, in logp\r\n    return bound(T.log(p[value]),\r\n\r\nHINT: Use the Theano flag 'exception_verbosity=high' for a debugprint and storage map footprint of this apply node.\r\n\"\"\"\r\n\r\nThe above exception was the direct cause of the following exception:\r\n\r\nIndexError                                Traceback (most recent call last)\r\n<ipython-input-15-6ee43e24a0b0> in <module>()\r\n     32     step1 = pm.Metropolis(vars=[p, sd, means])\r\n     33     step2 = pm.ElemwiseCategoricalStep(vars=[category], values=[0, 1, 2])\r\n---> 34     tr = pm.sample(2000, step=[step1, step2], njobs=3)\r\n\r\n/usr/local/lib/python3.4/dist-packages/pymc3/sampling.py in sample(draws, step, start, trace, chain, njobs, tune, progressbar, model, random_seed)\r\n    154         sample_args = [draws, step, start, trace, chain,\r\n    155                        tune, progressbar, model, random_seed]\r\n--> 156     return sample_func(*sample_args)\r\n    157 \r\n    158 \r\n\r\n/usr/local/lib/python3.4/dist-packages/pymc3/sampling.py in _mp_sample(njobs, args)\r\n    275 def _mp_sample(njobs, args):\r\n    276     p = mp.Pool(njobs)\r\n--> 277     traces = p.map(argsample, args)\r\n    278     p.close()\r\n    279     return merge_traces(traces)\r\n\r\n/usr/lib/python3.4/multiprocessing/pool.py in map(self, func, iterable, chunksize)\r\n    258         in a list that is returned.\r\n    259         '''\r\n--> 260         return self._map_async(func, iterable, mapstar, chunksize).get()\r\n    261 \r\n    262     def starmap(self, func, iterable, chunksize=None):\r\n\r\n/usr/lib/python3.4/multiprocessing/pool.py in get(self, timeout)\r\n    597             return self._value\r\n    598         else:\r\n--> 599             raise self._value\r\n    600 \r\n    601     def _set(self, i, obj):\r\n\r\nIndexError: index 3 is out of bounds for size 3\r\nApply node that caused the error: AdvancedSubtensor1(p, Subtensor{int64:int64:}.0)\r\nToposort index: 28\r\nInputs types: [TensorType(float64, vector), TensorType(int64, vector)]\r\nInputs shapes: [(3,), (2000,)]\r\nInputs strides: [(8,), (8,)]\r\nInputs values: [array([ 0.33333333,  0.33333333,  0.33333333]), 'not shown']\r\nOutputs clients: [[Elemwise{Composite{Switch((GE(i0, i1) * LE(i0, i2) * i3), log(i4), i5)}}[(0, 4)](Subtensor{int64:int64:}.0, TensorConstant{(1,) of 0}, Elemwise{Add}[(0, 1)].0, Elemwise{Composite{LE(Abs((i0 + i1)), i2)}}.0, AdvancedSubtensor1.0, TensorConstant{(1,) of -inf})]]\r\n\r\nBacktrace when the node is created:\r\n  File \"/usr/local/lib/python3.4/dist-packages/pymc3/distributions/discrete.py\", line 379, in logp\r\n    return bound(T.log(p[value]),\r\n\r\nHINT: Use the Theano flag 'exception_verbosity=high' for a debugprint and storage map footprint of this apply node.\r\n```\r\n\r\nThat last hint is not very helpful to me BTW :-)\r\n\r\nAny ideas?\r\n"},"comment":{"url":"https://api.github.com/repos/pymc-devs/pymc3/issues/comments/211331461","html_url":"https://github.com/pymc-devs/pymc3/issues/1033#issuecomment-211331461","issue_url":"https://api.github.com/repos/pymc-devs/pymc3/issues/1033","id":211331461,"user":{"login":"twiecki","id":674200,"avatar_url":"https://avatars.githubusercontent.com/u/674200?v=3","gravatar_id":"","url":"https://api.github.com/users/twiecki","html_url":"https://github.com/twiecki","followers_url":"https://api.github.com/users/twiecki/followers","following_url":"https://api.github.com/users/twiecki/following{/other_user}","gists_url":"https://api.github.com/users/twiecki/gists{/gist_id}","starred_url":"https://api.github.com/users/twiecki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/twiecki/subscriptions","organizations_url":"https://api.github.com/users/twiecki/orgs","repos_url":"https://api.github.com/users/twiecki/repos","events_url":"https://api.github.com/users/twiecki/events{/privacy}","received_events_url":"https://api.github.com/users/twiecki/received_events","type":"User","site_admin":false},"created_at":"2016-04-18T11:08:43Z","updated_at":"2016-04-18T11:08:43Z","body":"Interesting, so we're not communicating the step-method assignment to the individual workers?"}}