Skip to content
Advertisement

How to run scipy’s BFGS on GPU

I’d like to run scipy implementation of BFGS optimization algorithm on GPU and scipy seems not to support GPUs. The target function which I want to run on GPU is the following one which is part of the implementation of this repository:

JavaScript

I know there is Tensorflow Probablity implementation of BFGS, but I couldn’t find out how I can convert this scipy function into Tensordlow Probablity. Any Idea how I could to run the following function on GPU with minimum code change?

Advertisement

Answer

Here are two suggestions of mine:

  • jax.scipy: Jax contains the implementation of scipy and also supports GPUs and TPUs. You can theoretically install it, convert your numpy variables to jax.numpy and call jax.scipy.optimize.minimize(params):

    JavaScript

Dont foget to also take care of converting the variables which will be used in private_loss and private_gradient function to jax.numpy.

  • Tensorflow Probability: As you already mentioned, you can also use bfgs_minimize implementation by tensorflow. based on the colab here, your code will be something like this:

    JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement