Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between PyCUDA and NumbaPro CUDA Python?

I'm new to CUDA and am trying to figure out whether PyCUDA (free) or NumbaPro CUDA Python (not free) would be better for me (assuming the library cost is not an issue).

Both seem to require that you use their respective Python dialects. But, it seems that PyCUDA requires you to write a kernel function in C code, which would be more cumbersome than using NumbaPro, which seems to do all the hard work for you.

Is this indeed the case? Would there be notable performance differences?

like image 672
PDiracDelta Avatar asked Jul 18 '17 10:07

PDiracDelta


People also ask

What is PyCUDA for?

PyCUDA is a Python programming environment for CUDA it give you access to Nvidia's CUDA parallel computation API from Python.

What does Cuda do in Python?

CUDA Python provides uniform APIs and bindings for inclusion into existing toolkits and libraries to simplify GPU-based parallel processing for HPC, data science, and AI. CuPy is a NumPy/SciPy compatible Array library from Preferred Networks, for GPU-accelerated computing with Python.

Does Numba use GPU?

Numba supports CUDA GPU programming by directly compiling a restricted subset of Python code into CUDA kernels and device functions following the CUDA execution model. One feature that significantly simplifies writing GPU kernels is that Numba makes it appear that the kernel has direct access to NumPy arrays.


2 Answers

let's talk about each one of these libraries:

PyCUDA:

PyCUDA is a Python programming environment for CUDA it give you access to Nvidia's CUDA parallel computation API from Python. PyCUDA is written in C++(the base layer) and Python,the C++ code will be executed on the NVIDIA chip, and Python code to compile, execute, and get the results of the C++ code and Automatically manages resources which make it one of powerful library CUDA.

PyCUDA is slightly different from to PyOpenCl can be used to run code on a variety of platforms, including Intel, AMD, NVIDIA, and ATI chips. unlike PyCUDA which can be run on NVIDIA chips only:

Python + CUDA = PyCUDA

Python + OpenCL = PyOpenCL

NUMBA/NumbaPro:

NUMBA : NumbaPro or recently Numba (NumbaPro has been deprecated, and its code generation features have been moved into open-source Numba.) is an Open Source NumPy-aware optimizing compiler for Python sponsored by Anaconda, Inc. It uses the remarkable LLVM compiler infrastructure to compile Python syntax to machine code. Numba supports compilation of Python to run on either CPU or GPU hardware and it's fundamentally written in Python. it's easy to install and implement.

As @Wang has mentioned, Pycuda is faster than Numba.

like image 172
HISI Avatar answered Oct 09 '22 11:10

HISI


numbapro now is numba on BSD license which is free also.

according to this report pyOpenCL and pyCUDA is 5 times faster than numba

like image 36
Wang Avatar answered Oct 09 '22 11:10

Wang