In
computing
Computing is any goal-oriented activity requiring, benefiting from, or creating computer, computing machinery. It includes the study and experimentation of algorithmic processes, and the development of both computer hardware, hardware and softw ...
, CUDA (Compute Unified Device Architecture) is a proprietary
parallel computing
Parallel computing is a type of computing, computation in which many calculations or Process (computing), processes are carried out simultaneously. Large problems can often be divided into smaller ones, which can then be solved at the same time. ...
platform and
application programming interface
An application programming interface (API) is a connection between computers or between computer programs. It is a type of software Interface (computing), interface, offering a service to other pieces of software. A document or standard that des ...
(API) that allows software to use certain types of
graphics processing units (GPUs) for accelerated general-purpose processing, an approach called general-purpose computing on GPUs. CUDA was created by
Nvidia in 2006. When it was first introduced, the name was an acronym for ''Compute Unified Device Architecture'',
but Nvidia later
dropped the common use of the acronym and now rarely expands it.
CUDA is a software layer that gives direct access to the GPU's virtual
instruction set
In computer science, an instruction set architecture (ISA) is an abstract model that generally defines how software controls the CPU in a computer or a family of computers. A device or program that executes instructions described by that ISA, s ...
and parallel computational elements for the execution of
compute kernels.
In addition to
drivers and runtime kernels, the CUDA platform includes compilers, libraries and developer tools to help programmers accelerate their applications.
CUDA is designed to work with programming languages such as
C,
C++,
Fortran,
Python and
Julia. This accessibility makes it easier for specialists in parallel programming to use GPU resources, in contrast to prior APIs like
Direct3D and
OpenGL
OpenGL (Open Graphics Library) is a Language-independent specification, cross-language, cross-platform application programming interface (API) for rendering 2D computer graphics, 2D and 3D computer graphics, 3D vector graphics. The API is typic ...
, which require advanced skills in graphics programming. CUDA-powered GPUs also support programming frameworks such as
OpenMP,
OpenACC and
OpenCL
OpenCL (Open Computing Language) is a software framework, framework for writing programs that execute across heterogeneous computing, heterogeneous platforms consisting of central processing units (CPUs), graphics processing units (GPUs), di ...
.
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 efficient manipulation of large blocks of data. This design is more effective than general-purpose
central processing unit
A central processing unit (CPU), also called a central processor, main processor, or just processor, is the primary Processor (computing), processor in a given computer. Its electronic circuitry executes Instruction (computing), instructions ...
(CPUs) for
algorithm
In mathematics and computer science, an algorithm () is a finite sequence of Rigour#Mathematics, mathematically rigorous instructions, typically used to solve a class of specific Computational problem, problems or to perform a computation. Algo ...
s in situations where processing large blocks of data is done in parallel, such as:
*
cryptographic hash functions
*
machine learning
Machine learning (ML) is a field of study in artificial intelligence concerned with the development and study of Computational statistics, statistical algorithms that can learn from data and generalise to unseen data, and thus perform Task ( ...
*
molecular dynamics
Molecular dynamics (MD) is a computer simulation method for analyzing the Motion (physics), physical movements of atoms and molecules. The atoms and molecules are allowed to interact for a fixed period of time, giving a view of the dynamics ( ...
simulations
*
physics engine
A physics engine is computer software that provides an approximate simulation of certain physical systems, typically classical dynamics, including rigid body dynamics (including collision detection), soft body dynamics, and fluid dynamics. I ...
s
Ian Buck, while at Stanford in 2000, created an 8K gaming rig using 32 GeForce cards, then obtained a
DARPA
The Defense Advanced Research Projects Agency (DARPA) is a research and development agency of the United States Department of Defense responsible for the development of emerging technologies for use by the military. Originally known as the Adva ...
grant to perform
general purpose parallel programming on GPUs. He then joined Nvidia, where since 2004 he has been overseeing CUDA development. In pushing for CUDA,
Jensen Huang aimed for the Nvidia GPUs to become a general hardware for scientific computing. CUDA was released in 2007. Around 2015, the focus of CUDA changed to neural networks.
Ontology
The following table offers a non-exact description for the
ontology
Ontology is the philosophical study of existence, being. It is traditionally understood as the subdiscipline of metaphysics focused on the most general features of reality. As one of the most fundamental concepts, being encompasses all of realit ...
of CUDA framework.
Programming abilities
The CUDA platform is accessible to software developers through CUDA-accelerated libraries,
compiler directives
In computer programming, a directive or pragma (from "pragmatic") is a language construct that specifies how a compiler (or other Translator (computing), translator) should process its input. Depending on the programming language, directives may o ...
such as
OpenACC, and extensions to industry-standard programming languages including
C,
C++,
Fortran and
Python. C/C++ programmers can use 'CUDA C/C++', compiled to
PTX with
nvcc, Nvidia's
LLVM
LLVM, also called LLVM Core, is a target-independent optimizer and code generator. It can be used to develop a Compiler#Front end, frontend for any programming language and a Compiler#Back end, backend for any instruction set architecture. LLVM i ...
-based C/C++ compiler, or by clang itself. Fortran programmers can use 'CUDA Fortran', compiled with the PGI CUDA Fortran compiler from
The Portland Group. Python programmers can use the cuNumeric library to accelerate applications on Nvidia GPUs.
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
OpenCL (Open Computing Language) is a software framework, framework for writing programs that execute across heterogeneous computing, heterogeneous platforms consisting of central processing units (CPUs), graphics processing units (GPUs), di ...
, Microsoft's
DirectCompute,
OpenGL
OpenGL (Open Graphics Library) is a Language-independent specification, cross-language, cross-platform application programming interface (API) for rendering 2D computer graphics, 2D and 3D computer graphics, 3D vector graphics. The API is typic ...
Compute Shader and
C++ AMP. Third party wrappers are also available for
Python,
Perl
Perl is a high-level, general-purpose, interpreted, dynamic programming language. Though Perl is not officially an acronym, there are various backronyms in use, including "Practical Extraction and Reporting Language".
Perl was developed ...
, Fortran,
Java
Java is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea (a part of Pacific Ocean) to the north. With a population of 156.9 million people (including Madura) in mid 2024, proje ...
,
Ruby
Ruby is a pinkish-red-to-blood-red-colored gemstone, a variety of the mineral corundum ( aluminium oxide). Ruby is one of the most popular traditional jewelry gems and is very durable. Other varieties of gem-quality corundum are called sapph ...
,
Lua,
Common Lisp
Common Lisp (CL) is a dialect of the Lisp programming language, published in American National Standards Institute (ANSI) standard document ''ANSI INCITS 226-1994 (S2018)'' (formerly ''X3.226-1994 (R1999)''). The Common Lisp HyperSpec, a hyperli ...
,
Haskell
Haskell () is a general-purpose, statically typed, purely functional programming language with type inference and lazy evaluation. Designed for teaching, research, and industrial applications, Haskell pioneered several programming language ...
,
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
A bullet is a kinetic projectile, a component of firearm ammunition that is shot from a gun barrel. They are made of a variety of materials, such as copper, lead, steel, polymer, rubber and even wax; and are made in various shapes and constru ...
. CUDA has also been used to accelerate non-graphical applications in
computational biology
Computational biology refers to the use of techniques in computer science, data analysis, mathematical modeling and Computer simulation, computational simulations to understand biological systems and relationships. An intersection of computer sci ...
,
cryptography
Cryptography, or cryptology (from "hidden, secret"; and ''graphein'', "to write", or ''-logy, -logia'', "study", respectively), is the practice and study of techniques for secure communication in the presence of Adversary (cryptography), ...
and other fields by an
order of magnitude or more.
CUDA provides both a low level
API
An application programming interface (API) is a connection between computers or between computer programs. It is a type of software interface, offering a service to other pieces of software. A document or standard that describes how to build ...
(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
Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
and
Linux
Linux ( ) is a family of open source Unix-like operating systems based on the Linux kernel, an kernel (operating system), operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically package manager, pac ...
.
Mac OS X
macOS, previously OS X and originally Mac OS X, is a Unix, Unix-based operating system developed and marketed by Apple Inc., Apple since 2001. It is the current operating system for Apple's Mac (computer), Mac computers. With ...
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):
* cuBLAS – CUDA Basic Linear Algebra Subroutines library
* CUDART – CUDA Runtime library
* cuFFT – CUDA Fast Fourier Transform library
* cuRAND – CUDA Random Number Generation library
* cuSOLVER – CUDA based collection of dense and sparse direct solvers
* cuSPARSE – CUDA Sparse Matrix library
* NPP – NVIDIA Performance Primitives library
* nvGRAPH – NVIDIA Graph Analytics library
* NVML – NVIDIA Management Library
* NVRTC – NVIDIA Runtime Compilation library for CUDA C++
CUDA 8.0 comes with these other software components:
* nView – NVIDIA nView Desktop Management Software
* NVWMI – NVIDIA Enterprise Management Toolkit
* GameWorks
PhysX – is a multi-platform game physics engine
CUDA 9.0–9.2 comes with these other components:
* CUTLASS 1.0 – custom linear algebra algorithms,
* NVIDIA Video Decoder was deprecated in CUDA 9.2; it is now available in NVIDIA Video Codec SDK
CUDA 10 comes with these other components:
* nvJPEG – Hybrid (CPU and GPU) JPEG processing
CUDA 11.0–11.8 comes with these other components:
* CUB is new one of more supported C++ libraries
* MIG multi instance GPU support
* nvJPEG2000 –
JPEG 2000
JPEG 2000 (JP2) is an image compression standard and coding system. It was developed from 1997 to 2000 by a Joint Photographic Experts Group committee chaired by Touradj Ebrahimi (later the JPEG president), with the intention of superseding their ...
encoder and decoder
Advantages
CUDA has several advantages over traditional general-purpose computation on GPUs (GPGPU) using graphics APIs:
* Scattered readscode can read from arbitrary addresses in memory.
* Unified virtual memory (CUDA 4.0 and above)
* Unified memory (CUDA 6.0 and above)
*
Shared memoryCUDA exposes a fast shared memory region that can be shared among threads. This can be used as a user-managed cache, enabling higher bandwidth than is possible using texture lookups.
* Faster downloads and readbacks to and from the GPU
* Full support for integer and bitwise operations, including integer texture lookups
Limitations
* Whether for the host computer or the GPU device, all CUDA source code is now processed according to C++ syntax rules.
This was not always the case. Earlier versions of CUDA were based on C syntax rules. As with the more general case of compiling C code with a C++ compiler, it is therefore possible that old C-style CUDA source code will either fail to compile or will not behave as originally intended.
* Interoperability with rendering languages such as OpenGL is one-way, with OpenGL having access to registered CUDA memory but CUDA not having access to OpenGL memory.
* Copying between host and device memory may incur a performance hit due to system bus bandwidth and latency (this can be partly alleviated with asynchronous memory transfers, handled by the GPU's DMA engine).
* Threads should be running in groups of at least 32 for best performance, with total number of threads numbering in the thousands. Branches in the program code do not affect performance significantly, provided that each of 32 threads takes the same execution path; the
SIMD execution model becomes a significant limitation for any inherently divergent task (e.g. traversing a
space partitioning data structure during
ray tracing).
* No emulation or fallback functionality is available for modern revisions.
* Valid C++ may sometimes be flagged and prevent compilation due to the way the compiler approaches optimization for target GPU device limitations.
* C++
run-time type information
In computer programming, run-time type information or run-time type identification (RTTI) is a feature of some programming languages (such as C++, Object Pascal, and Ada) that exposes information about an object's data type at runtime. Run-time ...
(RTTI) and C++-style exception handling are only supported in host code, not in device code.
* In
single-precision on first generation CUDA compute capability 1.x devices,
denormal numbers are unsupported and are instead flushed to zero, and the precision of both the division and square root operations are slightly lower than IEEE 754-compliant single precision math. Devices that support compute capability 2.0 and above support denormal numbers, and the division and square root operations are IEEE 754 compliant by default. However, users can obtain the prior faster gaming-grade math of compute capability 1.x devices if desired by setting compiler flags to disable accurate divisions and accurate square roots, and enable flushing denormal numbers to zero.
* Unlike
OpenCL
OpenCL (Open Computing Language) is a software framework, framework for writing programs that execute across heterogeneous computing, heterogeneous platforms consisting of central processing units (CPUs), graphics processing units (GPUs), di ...
, CUDA-enabled GPUs are only available from Nvidia as it is proprietary.
Attempts to implement CUDA on other GPUs include:
** Project Coriander: Converts CUDA C++11 source to OpenCL 1.2 C. A fork of CUDA-on-CL intended to run
TensorFlow.
** CU2CL: Convert CUDA 3.2 C++ to OpenCL C.
**
GPUOpen HIP: A thin abstraction layer on top of CUDA and
ROCm intended for AMD and Nvidia GPUs. Has a conversion tool for importing CUDA C++ source. Supports CUDA 4.0 plus C++11 and float16.
** ZLUDA is a drop-in replacement for CUDA on AMD GPUs and formerly Intel GPUs with near-native performance. The developer, Andrzej Janik, was separately contracted by both Intel and AMD to develop the software in 2021 and 2022, respectively. However, neither company decided to release it officially due to the lack of a business use case. AMD's contract included a clause that allowed Janik to release his code for AMD independently, allowing him to release the new version that only supports AMD GPUs.
** chipStar can compile and run CUDA/HIP programs on advanced OpenCL 3.0 or Level Zero platforms.
Example
This example code in
C++ loads a texture from an image into an array on the GPU:
texture tex;
void foo()
//end foo()
__global__ void kernel(float* odata, int height, int width)
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)
"""
)
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 , 5, 6, numpy.float32))
B = CUBLASMatrix(numpy.mat( 2, 3 , 5
The comma is a punctuation mark that appears in several variants in different languages. Some typefaces render it as a small line, slightly curved or straight, but inclined from the vertical; others give it the appearance of a miniature fille ...
, 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)
GPUs supported
Supported CUDA compute capability versions for CUDA SDK version and microarchitecture (by code name):
Note: CUDA SDK 10.2 is the last official release for macOS, as support will not be available for macOS in newer releases.
CUDA compute capability by version with associated GPU semiconductors and GPU card models (separated by their various application areas):
* –
OEM-only products
Version features and specifications
Data types
Floating-point types
Version support
Note: Any missing lines or empty entries do reflect some lack of information on that exact item.
Tensor cores
Note: Any missing lines or empty entries do reflect some lack of information on that exact item.
Technical specifications
Multiprocessor architecture
For more information read the Nvidia CUDA C++ Programming Guide.
Usages of CUDA architecture
* Accelerated rendering of 3D graphics
* Accelerated interconversion of video file formats
* Accelerated
encryption
In Cryptography law, cryptography, encryption (more specifically, Code, encoding) is the process of transforming information in a way that, ideally, only authorized parties can decode. This process converts the original representation of the inf ...
,
decryption
In cryptography, encryption (more specifically, encoding) is the process of transforming information in a way that, ideally, only authorized parties can decode. This process converts the original representation of the information, known as plai ...
and
compression
*
Bioinformatics
Bioinformatics () is an interdisciplinary field of science that develops methods and Bioinformatics software, software tools for understanding biological data, especially when the data sets are large and complex. Bioinformatics uses biology, ...
, e.g.
NGS DNA sequencing BarraCUDA
* Distributed calculations, such as predicting the native conformation of
proteins
Proteins are large biomolecules and macromolecules that comprise one or more long chains of amino acid residues. Proteins perform a vast array of functions within organisms, including catalysing metabolic reactions, DNA replication, re ...
* Medical analysis simulations, for example
virtual reality
Virtual reality (VR) is a Simulation, simulated experience that employs 3D near-eye displays and pose tracking to give the user an immersive feel of a virtual world. Applications of virtual reality include entertainment (particularly video gam ...
based on
CT and
MRI scan images
* Physical simulations, particularly in
fluid dynamics
In physics, physical chemistry and engineering, fluid dynamics is a subdiscipline of fluid mechanics that describes the flow of fluids – liquids and gases. It has several subdisciplines, including (the study of air and other gases in motion ...
*
Neural network
A neural network is a group of interconnected units called neurons that send signals to one another. Neurons can be either biological cells or signal pathways. While individual neurons are simple, many of them together in a network can perfor ...
training in
machine learning
Machine learning (ML) is a field of study in artificial intelligence concerned with the development and study of Computational statistics, statistical algorithms that can learn from data and generalise to unseen data, and thus perform Task ( ...
problems
*
Large Language Model inference
*
Face recognition
*
Volunteer computing
Volunteer computing is a type of distributed computing in which people donate their computers' unused resources to a research-oriented project, and sometimes in exchange for credit points. The fundamental idea behind it is that a modern desktop ...
projects, such as
SETI@home and other projects using
BOINC software
*
Molecular dynamics
Molecular dynamics (MD) is a computer simulation method for analyzing the Motion (physics), physical movements of atoms and molecules. The atoms and molecules are allowed to interact for a fixed period of time, giving a view of the dynamics ( ...
* Mining
cryptocurrencies
A cryptocurrency (colloquially crypto) is a digital currency designed to work through a computer network that is not reliant on any central authority, such as a government or bank, to uphold or maintain it.
Individual coin ownership records ...
*
Structure from motion (SfM) software
Comparison with competitors
CUDA competes with other GPU computing stacks:
Intel OneAPI and
AMD ROCm.
Whereas Nvidia's CUDA is closed-source, Intel's OneAPI and AMD's ROCm are open source.
Intel OneAPI
oneAPI is an initiative based in open standards, created to support software development for multiple hardware architectures. The oneAPI libraries must implement open specifications that are discussed publicly by the Special Interest Groups, offering the possibility for any developer or organization to implement their own versions of oneAPI libraries.
Originally made by Intel, other hardware adopters include Fujitsu and Huawei.
Unified Acceleration Foundation (UXL)
Unified Acceleration Foundation (UXL) is a new technology consortium working on the continuation of the OneAPI initiative, with the goal to create a new open standard accelerator software ecosystem, related open standards and specification projects through Working Groups and Special Interest Groups (SIGs). The goal is to offer open alternatives to Nvidia's CUDA. The main companies behind it are Intel, Google, ARM, Qualcomm, Samsung, Imagination, and VMware.
AMD ROCm
ROCm
is an open source software stack for
graphics processing unit (GPU) programming from
Advanced Micro Devices
Advanced Micro Devices, Inc. (AMD) is an American multinational corporation and technology company headquartered in Santa Clara, California and maintains significant operations in Austin, Texas. AMD is a Information technology, hardware and F ...
(AMD).
See also
*
SYCL – an open standard from
Khronos Group for programming a variety of platforms, including GPUs, with ''single-source'' modern C++, similar to higher-level CUDA Runtime API (''single-source'')
*
BrookGPU – the Stanford University graphics group's compiler
*
Array programming
In computer science, array programming refers to solutions that allow the application of operations to an entire set of values at once. Such solutions are commonly used in computational science, scientific and engineering settings.
Modern program ...
*
Parallel computing
Parallel computing is a type of computing, computation in which many calculations or Process (computing), processes are carried out simultaneously. Large problems can often be divided into smaller ones, which can then be solved at the same time. ...
*
Stream processing
In computer science, stream processing (also known as event stream processing, data stream processing, or distributed stream processing) is a programming paradigm which views Stream (computing), streams, or sequences of events in time, as the centr ...
*
rCUDA – an API for computing on remote computers
*
Molecular modeling on GPUs
*
Vulkan – low-level, high-performance 3D graphics and computing API
*
OptiX – ray tracing API by NVIDIA
*
CUDA binary (cubin) – a type of fat binary
*
Numerical Library Collection – by NEC for their vector processor
References
Further reading
*
*
External links
*
__FORCETOC__
{{DEFAULTSORT:Cuda
Computer physics engines
GPGPU
GPGPU libraries
Graphics hardware
Nvidia software
Parallel computing
Graphics cards
Video game hardware