bayesiains / nflows

Normalizing flows in PyTorch
MIT License
845 stars 118 forks source link

Sampling on gpu #20

Closed janfb closed 4 years ago

janfb commented 4 years ago

Hi Artur, we have been working on training the density estimators in sbi on a GPU. That worked just fine when globally setting the default tensor to torch.cuda.FloatTensor. We wanted to avoid this global setting and instead move the net and the training batches to the device manually during training (see https://github.com/mackelab/sbi/pull/331) However, this resulted in problems in nflows (mainly CPU-cuda device mismatches). I tried to fix these problems with the two commits in this PR, following the discussion in https://github.com/bayesiains/nflows/pull/9.

I am happy to discuss the changes and feel free to change them or fix it differently.

Once this is fixed, sbi can depend on it via pyknos.

Best, Jan