Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I program Nvidia's CUDA using only Python or do I have to learn C?

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.

like image 473
Aquateenfan Avatar asked Jun 01 '10 04:06

Aquateenfan


People also ask

Does CUDA use C or C++?

CUDA C is essentially C/C++ with a few extensions that allow one to execute functions on the GPU using many threads in parallel.

Does CUDA work with Python?

CUDA® Python provides Cython/Python wrappers for CUDA driver and runtime APIs; and is installable today by using PIP and Conda. Python developers will be able to leverage massively parallel GPU computing to achieve faster results and accuracy.

Is CUDA written in C?

CUDA C is a programming language with C syntax.


2 Answers

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.

like image 136
dwf Avatar answered Oct 13 '22 23:10

dwf


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.

like image 33
Alex Martelli Avatar answered Oct 13 '22 21:10

Alex Martelli