views:

467

answers:

4

I guess the question speaks for itself. I'm interested in doing some serious computations but am not a programmer by trade. I can string enough python together to get done what I want. But can I write a program in python and have the GPU execute it using CUDA? Or do I have to use some mix of python and C?

The examples on Klockner's (sp) "pyCUDA" webpage had a mix of both python and C, so I'm not sure what the answer is.

If anyone wants to chime in about Opencl, feel free. I heard about this CUDA business only a couple of weeks ago and didn't know you could use your video cards like this.

thx

+6  A: 

I believe that, with PyCUDA, your computational kernels will always have to be written as "CUDA C Code". PyCUDA takes charge of a lot of otherwise-tedious book-keeping, but does not build computational CUDA kernels from Python code.

Alex Martelli
Indeed, though there are interesting projects that do; see my answer. ;)
dwf
+2  A: 

pyopencl offers an interesting alternative to PyCUDA. It is described as a "sister project" to PyCUDA. It is a complete wrapper around OpenCL's API.

As far as I understand, OpenCL has the advantage of running on GPUs beyond Nvidia's.

EOL
OpenCL in theory can execute on supported CPUs as well. However, support outside of Nvidia's hardware is rather half-assed so far.
dwf
+5  A: 

You should take a look at CUDAmat and Theano. Both are approaches to writing code that executes on the GPU without really having to know much about GPU programming.

dwf
+1, neat stuff indeed!
Alex Martelli
+1  A: 

Great answers already, but another option is Clyther. It will let you write OpenCL programs without even using C, by compiling a subset of Python into OpenCL kernels.

Yann Vernier