CUDA

CUDA (an acronym for Compute Unified Device Architecture) is a parallel computing platform and application programming interface (API) model created by Nvidia. It allows software developers and software engineers to use a CUDA-enabled graphics processing unit (GPU) for general purpose processing an approach termed GPGPU (general-purpose computing on graphics processing units). The CUDA platform is a software layer that gives direct access to the GPU's virtual instruction set and parallel computational elements, for the execution of compute kernels.
The CUDA platform is designed to work with programming languages such as C, C++, and Fortran. This accessibility makes it easier for specialists in parallel programming to use GPU resources, in contrast to prior APIs like Direct3D and OpenGL, which required advanced skills in graphics programming. CUDA-powered GPUs also support programming frameworks such as OpenMP, OpenACC and OpenCL; and HIP by compiling such code to CUDA. When CUDA was first introduced by Nvidia, the name was an acronym for Compute Unified Device Architecture, but Nvidia subsequently dropped the common use of the acronym.
Background.
The graphics processing unit (GPU), as a specialized computer processor, addresses the demands of real-time high-resolution 3D graphics compute-intensive tasks. By 2012, GPUs had evolved into highly parallel multi-core systems allowing very efficient manipulation of large blocks of data. This design is more effective than general-purpose central processing unit (CPUs) for algorithms in situations where processing large blocks of data is done in parallel, such as:
Programming abilities.
The CUDA platform is accessible to software developers through CUDA-accelerated libraries, compiler directives such as OpenACC, and extensions to industry-standard programming languages including C, C++ and Fortran. C/C++ programmers can use 'CUDA C/C++', compiled to PTX with nvcc, Nvidia's LLVM-based C/C++ compiler. Fortran programmers can use 'CUDA Fortran', compiled with the PGI CUDA Fortran compiler from The Portland Group.
In addition to libraries, compiler directives, CUDA C/C++ and CUDA Fortran, the CUDA platform supports other computational interfaces, including the Khronos Group's OpenCL, Microsoft's DirectCompute, OpenGL Compute Shader and C++ AMP. Third party wrappers are also available for Python, Perl, Fortran, Java, Ruby, Lua, Common Lisp, Haskell, R, MATLAB, IDL, Julia, and native support in Mathematica.
In the computer game industry, GPUs are used for graphics rendering, and for game physics calculations (physical effects such as debris, smoke, fire, fluids); examples include PhysX and Bullet. CUDA has also been used to accelerate non-graphical applications in computational biology, cryptography and other fields by an order of magnitude or more.
CUDA provides both a low level API (CUDA Driver API, non single-source) and a higher level API (CUDA Runtime API, single-source). The initial CUDA SDK was made public on 15 February 2007, for Microsoft Windows and Linux. Mac OS X support was later added in version 2.0, which supersedes the beta released February 14, 2008. CUDA works with all Nvidia GPUs from the G8x series onwards, including GeForce, Quadro and the Tesla line. CUDA is compatible with most standard operating systems. 
CUDA 8.0 comes with the following libraries (for compilation & runtime, in alphabetical order):
CUDA 8.0 comes with these other software components:
CUDA 9.0–9.2 comes with these other components:
CUDA 10 comes with these other components:
Cuda 11 to 11.3 comes with these other components: 
Advantages.
CUDA has several advantages over traditional general-purpose computation on GPUs (GPGPU) using graphics APIs:
GPUs supported.
Supported CUDA level of GPU and card. See also at Nvidia:
'*' – OEM-only products
Version features and specifications.
Note: Any missing lines or empty entries do reflect some lack of information on that exact item.<br>
For more information see the article: and read Nvidia CUDA programming guide.
Example.
This example code in C++ loads a texture from an image into an array on the GPU:
texture<float, 2, cudaReadModeElementType> tex;
void foo()
 cudaArray* cu_array;
 // Allocate array
 cudaChannelFormatDesc description = cudaCreateChannelDesc<float>();
 cudaMallocArray(&cu_array, &description, width, height);
 // Copy image data to array
 cudaMemcpyToArray(cu_array, image, width*height*sizeof(float), cudaMemcpyHostToDevice);
 // Set texture parameters (default)
 tex.addressMode[0] = cudaAddressModeClamp;
 tex.addressMode[1] = cudaAddressModeClamp;
 tex.filterMode = cudaFilterModePoint;
 tex.normalized = false; // do not normalize coordinates
 // Bind the array to the texture
 cudaBindTextureToArray(tex, cu_array);
 // Run kernel
 dim3 blockDim(16, 16, 1);
 dim3 gridDim((width + blockDim.x - 1)/ blockDim.x, (height + blockDim.y - 1) / blockDim.y, 1);
 kernel«< gridDim, blockDim, 0 »>(d_data, height, width);
 // Unbind the array from the texture
 cudaUnbindTexture(tex);
} //end foo()
__global__ void kernel(float* odata, int height, int width)
 unsigned int x = blockIdx.x*blockDim.x + threadIdx.x;
 unsigned int y = blockIdx.y*blockDim.y + threadIdx.y;
 if (x < width && y < height) {
 float c = tex2D(tex, x, y);
 odata[y*width+x] = c;
Below is an example given in Python that computes the product of two arrays on the GPU. The unofficial Python language bindings can be obtained from "PyCUDA".
import pycuda.compiler as comp
import pycuda.driver as drv
import numpy
import pycuda.autoinit
mod = comp.SourceModule(
__global__ void multiply_them(float *dest, float *a, float *b)
 const int i = threadIdx.x;
 dest[i] = a[i] * b[i];
"""
multiply_them = mod.get_function("multiply_them")
a = numpy.random.randn(400).astype(numpy.float32)
b = numpy.random.randn(400).astype(numpy.float32)
dest = numpy.zeros_like(a)
multiply_them(drv.Out(dest), drv.In(a), drv.In(b), block=(400, 1, 1))
print(dest - a * b)
Additional Python bindings to simplify matrix multiplication operations can be found in the program "pycublas".
import numpy
from pycublas import CUBLASMatrix
A = CUBLASMatrix(numpy.mat(1, 2, 3], [4, 5, 6, numpy.float32))
B = CUBLASMatrix(numpy.mat(2, 3], [4, 5], [6, 7, numpy.float32))
C = A * B
print(C.np_mat())
while CuPy directly replaces NumPy:
import cupy
a = cupy.random.randn(400)
b = cupy.random.randn(400)
dest = cupy.zeros_like(a)
print(dest - a * b)