Skip to content

How to set up custom embedding nets for CUDA training #1202

Answered by janfb
janfb asked this question in Q&A
Discussion options

You must be logged in to vote

Given your code snipped, I don't see why this would not work. Maybe your data or your embedding net is still on the GPU?

You can check the device of the net like this:

assert next(net.parameters()).device == "cpu"
assert x.device == "cpu"
assert theta.device == "cpu"

neural_posterior = posterior_nn(model="maf", embedding_net=net, hidden_features=10, num_transforms=2)
inference = SNPE(device="cuda", density_estimator=neural_posterior)
inference.append_simulations(theta, x)
inference.train()
posterior = inference.build_posterior()

Replies: 1 comment 5 replies

Comment options

janfb
Jul 24, 2024
Maintainer Author

You must be logged in to vote
5 replies
@ningyuxin1999
Comment options

@janfb
Comment options

janfb Jul 26, 2024
Maintainer Author

@ningyuxin1999
Comment options

@janfb
Comment options

janfb Aug 8, 2024
Maintainer Author

Answer selected by janfb
@ningyuxin1999
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
2 participants
Converted from issue

This discussion was converted from issue #1201 on July 24, 2024 15:10.