pyro-ppl/pyro

MCMC num_chains>1 does not work on Windows

Open

#2,315 opened on Feb 19, 2020

View on GitHub
 (9 comments) (0 reactions) (0 assignees)Python (981 forks)batch import
bughelp wanted

Repository metrics

Stars
 (8,211 stars)
PR merge metrics
 (Avg merge 10d 19h) (1 merged PR in 30d)

Description

Hi!

I tried to implement some very simple Bayesian Regression via NUTS/MCMC. It works well, if I use a single Markov Chain, however, when I increase the number, the program does not stop anymore (but also doesn't yield any error message).

import torch
import pyro
import pyro.distributions as dist
from pyro.infer.mcmc import MCMC, NUTS

X = torch.FloatTensor([[float(i), 1.] for i in range(100)]).reshape(-1, 2)
y = torch.FloatTensor([float(i) for i in range(100)])

def linreg(x, y):
    w = pyro.sample('w', dist.Normal(torch.zeros(x.size(1))+5., 10.0))
    return pyro.sample('measurement', dist.Normal(x@w, 1.), obs=y)

hmc_kernel = NUTS(linreg)
posterior = MCMC(hmc_kernel, num_samples=10, warmup_steps=10, num_chains=2)
posterior.run(X, y)

If you set num_chains to 1, it will work.

Pyro 1.2.1 PyTorch 1.4.0+cpu Python 3.7.6 (tags/v3.7.6:43364a7ae0, Dec 19 2019, 00:42:30) [MSC v.1916 64 bit (AMD64)] Windows 10

Thanks for help!

Contributor guide