1
$\begingroup$

I have a fluid dynamic solver written in python which I want to accelerate by moving the most expensive computations to the GPU. Ideally all arrays and sparse matrices used in my code should remain on the gpu, and matrices in COO format should be built directly from arrays on the gpu.

From my search it seems that there are two python packages which may help; pyviennacl and petsc4py. Is there a reason I should choose one over the other?

$\endgroup$
  • 1
    $\begingroup$ Have you considered pycuda? $\endgroup$ – nluigi Mar 6 '18 at 17:46
  • $\begingroup$ Can you call cusp routines from pycuda in a straight forward way $\endgroup$ – hakeem Mar 6 '18 at 18:16
  • $\begingroup$ there have been a couple of questions posted here, e.g. this one. Googling "pycuda cusp" shows a number of results aswell $\endgroup$ – nluigi Mar 6 '18 at 19:07
  • $\begingroup$ @nluigi you might want to convert your comments to the answer, as it seemed to offer an answer. $\endgroup$ – Anton Menshov Mar 11 '18 at 8:44
2
$\begingroup$

I have found pycuda particularly useful as wrapper for cuda in python. Especially the section on metaprogramming is useful if you are interested in building more sophisticated frameworks. It's a mature package, there is an active mailing list and the developer gives very useful advice.

$\endgroup$
1
$\begingroup$

Pycuda is one of the more pythonic way to handle cuda in python as @nluigi suggested.

If you are open to call C/C++ code inside python there is also CUSP:

Cusp is a library for sparse linear algebra and graph computations based on Thrust. Cusp provides a flexible, high-level interface for manipulating sparse matrices and solving sparse linear systems.

This is a template library that I found user friendly and with this you can do with it some heavy task. I use both pycuda and CUSP some time ago for a GPU solver for Navier-Stokes.

There are also other library I cite two:

scikit-cuda provides Python interfaces to many of the functions in the CUDA device/runtime, CUBLAS, CUFFT, and CUSOLVER libraries distributed as part of NVIDIA's CUDA Programming Toolkit, as well as interfaces to select functions in the CULA Dense Toolkit. Both low-level wrapper functions similar to their C counterparts and high-level functions comparable to those in NumPy and Scipy are provided.

PyCULA provides an efficient and simple CUDA GPU environment for python. PyCULA accomplishes this feat by combining the power of driver based PyCUDA with nVidia’s runtime libraries and, most importantly, CULA GPU-LAPACK functionality in a single environment. We aim to hide complications without limiting the enduser.

$\endgroup$

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.