florianhartig / BayesianTools

General-Purpose MCMC and SMC Samplers and Tools for Bayesian Statistics
https://cran.r-project.org/web/packages/BayesianTools/index.html
117 stars 29 forks source link

GPU support in BayesianTools #185

Closed naodaihuang closed 5 years ago

naodaihuang commented 5 years ago

Is a GPU version possible? Maybe based on gpuR or gpuRcuda package? May speed up by a lot

florianhartig commented 5 years ago

Hi naodaihuang,

MCMCs cannot sensibly be parallelized to more than few cores (unless you parallelize the model on the GPU), because of the Markov updating. The only thing in BT that could sensibly make use of a GPU is SMC sampling, see the sampler in our development branch https://github.com/florianhartig/BayesianTools/tree/SMC

Using a GPU for this, however, would only make sense if the model itself evaluates super fast. As our general vision for BT is that this package should optimize for large / slow models, which would typically run better on CPUs, I don't expect that we would put a strong effort on GPU support in the next time.

If you have a model that could itself be parallelized on a GPU (e.g. a large statistical model), you may want to consider https://greta-stats.org/, which uses tensorflow as a backend and should therefore be able to use GPU resources for that purpose!