Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

from_pyro fails when MCMC is run on GPU #1529

Closed
chrhck opened this issue Jan 31, 2021 · 2 comments · Fixed by #1659
Closed

from_pyro fails when MCMC is run on GPU #1529

chrhck opened this issue Jan 31, 2021 · 2 comments · Fixed by #1659

Comments

@chrhck
Copy link

chrhck commented Jan 31, 2021

When MCMC is performed on a GPU, from_pyro fails, as the sites returned by
trace = pyro.poutine.trace(self.model).get_trace(*self._args, **self._kwargs) can be tensors that still live on the GPU.
This will cause this line to break:

vals = utils.one_de(vals)

Since there is currently no easy way of transferring a pyro MCMC object to the cpu, a workaround is adding a .cpu()to this line:

name: site["value"]

@ahartikainen
Copy link
Contributor

That sounds ok solution.

Is there a way to see if the trace is on cpu or gpu? And should we unpack data from gpu in one step or one-by-one (when numpy array is creates)

@fonnesbeck
Copy link
Contributor

Calling the cpu() method on data that's already on the cpu() will just be ignored, so no need to check. I will submit a PR for this now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants