How to program CUDA with Python
#An introduction to CUDA in Python #Coding directly in Python functions that will be executed on GPU may allow # to remove bottlenecks while keeping the code short and simple. In this introduction, # we show one way to use CUDA in Python, and explain some basic principles of CUDA programming. #We choose to use the Open Source package Numba. # Numba is a just-in-time compiler for Python that allows in particular to write CUDA kernels. # Numba is freely available at https://github.com/numba/numba. #Note that there are other packages, such as PyCUDA, that also allow to launch CUDA kernels in Python. #Preliminary #Let’s define first some vocabulary: #a CUDA kernel is a function that is executed on the GPU, #the GPU and its memory are called the device, #the CPU and its memory are called the host. #Now let’s check the versions used in this notebook: import sys import numba import numpy print ( "Python version:" , sys.version) print ( "Numba version:" , numba. __version__...