Samples for CUDA Developers which demonstrates features in CUDA Toolkit. This version supports CUDA Toolkit 11.5.
This section describes the release notes for the CUDA Samples on GitHub only.
cuDLAHybridMode
. Demonstrate usage of cuDLA in hybrid mode.cuDLAStandaloneMode
. Demonstrate usage of cuDLA in standalone mode.cuDLAErrorReporting
. Demonstrate DLA error detection via CUDA.graphMemoryNodes
. Demonstrates memory allocations and frees within CUDA graphs using Graph APIs and Stream Capture APIs.graphMemoryFootprint
. Demonstrates how graph memory nodes re-use virtual addresses and physical memory.cdpQuadtree
. Demonstrates Quad Trees implementation using CUDA Dynamic Parallelism.simpleVulkan
, simpleVulkanMMAP
and vulkanImageCUDA
. Demonstrates use of SPIR-V shaders.streamOrderedAllocationIPC
. Demonstrates Inter Process Communication using one process per GPU for computation.simpleCUBLAS_LU
. Demonstrates batched matrix LU decomposition using cuBLAS API cublas<t>getrfBatched()
simpleVulkan
. Demonstrates use of timeline semaphore.cudaMallocHost()
.streamOrderedAllocation
. Demonstrates stream ordered memory allocation on a GPU using cudaMallocAsync and cudaMemPool family of APIs.streamOrderedAllocationP2P
. Demonstrates peer-to-peer access of stream ordered memory allocated using cudaMallocAsync and cudaMemPool family of APIs.cuda::pipeline
and cuda::barrier
interfaces.--threads
of nvcc
cuda compiler.cudaNvSciNvMedia
. Demonstrates CUDA-NvMedia interop via NvSciBuf/NvSciSync APIs.simpleGL
. Demonstrates interoperability between CUDA and OpenGL.watershedSegmentationNPP
. Demonstrates how to use the NPP watershed segmentation function.batchedLabelMarkersAndLabelCompressionNPP
. Demonstrates how to use the NPP label markers generation and label compression functions based on a Union Find (UF) algorithm including both single image and batched image versions.warpAggregatedAtomicsCG
.shfl_scan
sample.cudaOpenMP
. Demonstrates how to use OpenMP API to write an application for multiple GPUs.simpleZeroCopy
. Demonstrates how to use zero copy, kernels can read and write directly to pinned system memory.dmmaTensorCoreGemm
. Demonstrates double precision GEMM computation using the Double precision Warp Matrix Multiply and Accumulate (WMMA) API introduced with CUDA 11 in Ampere chip family tensor cores.bf16TensorCoreGemm
. Demonstrates __nv_bfloat16 (e8m7) GEMM computation using the __nv_bfloat16 WMMA API introduced with CUDA 11 in Ampere chip family tensor cores.tf32TensorCoreGemm
. Demonstrates tf32 (e8m10) GEMM computation using the tf32 WMMA API introduced with CUDA 11 in Ampere chip family tensor cores.globalToShmemAsyncCopy
. Demonstrates async copy of data from global to shared memory when on compute capability 8.0 or higher. Also demonstrates arrive-wait barrier for synchronization.simpleAWBarrier
. Demonstrates arrive wait barriers.simpleAttributes
. Demonstrates the stream attributes that affect L2 locality.warpAggregatedAtomicsCG
which can be used on compute capability 7.0 and above GPU architectures.binaryPartitionCG
. Demonstrates binary partition cooperative groups and reduction within the thread block.reduction
one which demonstrates reduce_add_sync intrinstic supported on compute capability 8.0 and another which uses cooperative_groups::reduce function which does thread_block_tile level reduction introduced from CUDA 11.0.cudaCompressibleMemory
. Demonstrates compressible memory allocation using cuMemMap API.simpleVulkanMMAP
. Demonstrates Vulkan CUDA Interop via cuMemMap APIs.concurrentKernels
. Demonstrates the use of CUDA streams for concurrent execution of several kernels on a GPU.simpleD3D11
. Demonstrates CUDA-D3D11 External Resource Interoperability APIs for updating D3D11 buffers from CUDA and synchronization between D3D11 and CUDA with Keyed Mutexes.simpleDrvRuntime
. Demonstrates CUDA Driver and Runtime APIs working together to load fatbinary of a CUDA kernel.vectorAddMMAP
. Demonstrates how cuMemMap API allows the user to specify the physical properties of their memory while retaining the contiguous nature of their access.memMapIPCDrv
. Demonstrates Inter Process Communication using cuMemMap APIs.cudaNvSci
. Demonstrates CUDA-NvSciBuf/NvSciSync Interop.jacobiCudaGraphs
. Demonstrates Instantiated CUDA Graph Update with Jacobi Iterative Method using different approaches.cuSolverSp_LinearSolver
. Demonstrates cuSolverSP's LU, QR and Cholesky factorization.MersenneTwisterGP11213
. Demonstrates the Mersenne Twister random number generator GP11213 in cuRAND.vulkanImageCUDA
. Demonstrates how to perform Vulkan image - CUDA Interop.nvJPEG_encoder
. Demonstrates encoding of jpeg images using NVJPEG Library.nvJPEG
sample.boxFilterNPP
. Demonstrates how to use NPP FilterBox function to perform a box filter.cannyEdgeDetectorNPP
. Demonstrates the nppiFilterCannyBorder_8u_C1R Canny Edge Detection image filter function.NV12toBGRandResize
. Demonstrates how to convert and resize NV12 frames to BGR planars frames using CUDA in batch.EGLStream_CUDA_Interop
. Demonstrates data exchange between CUDA and EGL Streams.cuSolverDn_LinearSolver
. Demonstrates cuSolverDN's LU, QR and Cholesky factorization.immaTensorCoreGemm
. Demonstrates integer GEMM computation using the Warp Matrix Multiply and Accumulate (WMMA) API for integers employing the Tensor Cores.simpleIPC
. Demonstrates Inter Process Communication with one process per GPU for computation.nvJPEG
. Demonstrates single and batched decoding of jpeg images using NVJPEG Library.bandwidthTest
. It measures the memcopy bandwidth of the GPU and memcpy bandwidth across PCI-e.reduction
. Demonstrates several important optimization strategies for Data-Parallel Algorithms like reduction.simpleCudaGraphs
. Demonstrates CUDA Graphs creation, instantiation and launch using Graphs APIs and Stream Capture APIs.conjugateGradientCudaGraphs
. Demonstrates conjugate gradient solver on GPU using CUBLAS and CUSPARSE library calls captured and called using CUDA Graph APIs.simpleVulkan
. Demonstrates Vulkan - CUDA Interop.simpleD3D12
. Demonstrates DX12 - CUDA Interop.UnifiedMemoryPerf
. Demonstrates performance comparision of various memory types involved in system.p2pBandwidthLatencyTest
. Demonstrates Peer-To-Peer (P2P) data transfers between pairs of GPUs and computes latency and bandwidth.systemWideAtomics
. Demonstrates system wide atomic instructions.simpleCUBLASXT
. Demonstrates CUBLAS-XT library which performs GEMM operations over multiple GPUs.conjugateGradientMultiDeviceCG
sample.This is the first release of CUDA Samples on GitHub:
vectorAdd_nvrtc
. Demonstrates runtime compilation library using NVRTC of a simple vectorAdd kernel.warpAggregatedAtomicsCG
. Demonstrates warp aggregated atomics using Cooperative Groups.deviceQuery
. Enumerates the properties of the CUDA devices present in the system.matrixMul
. Demonstrates a matrix multiplication using shared memory through tiled approach.matrixMulDrv
. Demonstrates a matrix multiplication using shared memory through tiled approach, uses CUDA Driver API.cudaTensorCoreGemm
. Demonstrates a GEMM computation using the Warp Matrix Multiply and Accumulate (WMMA) API introduced in CUDA 9, as well as the new Tensor Cores introduced in the Volta chip family.simpleVoteIntrinsics
which uses *_sync equivalent of the vote intrinsics _any, _all added since CUDA 9.0.shfl_scan
which uses *_sync equivalent of the shfl intrinsics added since CUDA 9.0.conjugateGradientMultiBlockCG
. Demonstrates a conjugate gradient solver on GPU using Multi Block Cooperative Groups.conjugateGradientMultiDeviceCG
. Demonstrates a conjugate gradient solver on multiple GPUs using Multi Device Cooperative Groups, also uses unified memory prefetching and usage hints APIs.simpleCUBLAS
. Demonstrates how perform GEMM operations using CUBLAS library.simpleCUFFT
. Demonstrates how perform FFT operations using CUFFT library.Download and install the CUDA Toolkit 11.5 for your corresponding platform. For system requirements and installation instructions of cuda toolkit, please refer to the Linux Installation Guide, and the Windows Installation Guide.
Using git clone the repository of CUDA Samples using the command below.
git clone https://github.com/NVIDIA/cuda-samples.git
Without using git the easiest way to use these samples is to download the zip file containing the current version by clicking the "Download ZIP" button on the repo page. You can then unzip the entire archive and use the samples.
The Windows samples are built using the Visual Studio IDE. Solution files (.sln) are provided for each supported version of Visual Studio, using the format:
*_vs<version>.sln - for Visual Studio <version>
Complete samples solution files exist at parent directory of the repo:
Each individual sample has its own set of solution files at:
<CUDA_SAMPLES_REPO>\Samples\<sample_dir>\
To build/examine all the samples at once, the complete solution files should be used. To build/examine a single sample, the individual sample solution files should be used.
The Linux samples are built using makefiles. To use the makefiles, change the current directory to the sample directory you wish to build, and run make:
$ cd <sample_dir>
$ make
The samples makefiles can take advantage of certain options:
TARGET_ARCH= - cross-compile targeting a specific architecture. Allowed architectures are x86_64, ppc64le, armv7l, aarch64.
By default, TARGET_ARCH is set to HOST_ARCH. On a x86_64 machine, not setting TARGET_ARCH is the equivalent of setting TARGET_ARCH=x86_64.
$ make TARGET_ARCH=x86_64
$ make TARGET_ARCH=ppc64le
$ make TARGET_ARCH=armv7l
$ make TARGET_ARCH=aarch64
See here for more details on cross platform compilation of cuda samples.
dbg=1 - build with debug symbols
$ make dbg=1
SMS="A B ..." - override the SM architectures for which the sample will be built, where "A B ..."
is a space-delimited list of SM architectures. For example, to generate SASS for SM 50 and SM 60, use SMS="50 60"
.
$ make SMS="50 60"
HOST_COMPILER=<host_compiler> - override the default g++ host compiler. See the Linux Installation Guide for a list of supported host compilers.
$ make HOST_COMPILER=g++
Some CUDA Samples rely on third-party applications and/or libraries, or features provided by the CUDA Toolkit and Driver, to either build or execute. These dependencies are listed below.
If a sample has a third-party dependency that is available on the system, but is not installed, the sample will waive itself at build time.
Each sample's dependencies are listed in its README's Dependencies section.
These third-party dependencies are required by some CUDA samples. If available, these dependencies are either installed on your system automatically, or are installable via your system's package manager (Linux) or a third-party website.
FreeImage is an open source imaging library. FreeImage can usually be installed on Linux using your distribution's package manager system. FreeImage can also be downloaded from the FreeImage website.
To set up FreeImage on a Windows system, extract the FreeImage DLL distribution into the folder ../../Common/FreeImage/Dist/x64
such that it contains the .h, .dll, and .lib files.
MPI (Message Passing Interface) is an API for communicating data between distributed processes. A MPI compiler can be installed using your Linux distribution's package manager system. It is also available on some online resources, such as Open MPI. On Windows, to build and run MPI-CUDA applications one can install MS-MPI SDK.
Some samples can only be run on a 64-bit operating system.
DirectX is a collection of APIs designed to allow development of multimedia applications on Microsoft platforms. For Microsoft platforms, NVIDIA's CUDA Driver supports DirectX. Several CUDA Samples for Windows demonstrates CUDA-DirectX Interoperability, for building such samples one needs to install Microsoft Visual Studio 2012 or higher which provides Microsoft Windows SDK for Windows 8.
DirectX 12 is a collection of advanced low-level programming APIs which can reduce driver overhead, designed to allow development of multimedia applications on Microsoft platforms starting with Windows 10 OS onwards. For Microsoft platforms, NVIDIA's CUDA Driver supports DirectX. Few CUDA Samples for Windows demonstrates CUDA-DirectX12 Interoperability, for building such samples one needs to install Windows 10 SDK or higher, with VS 2015 or VS 2017.
OpenGL is a graphics library used for 2D and 3D rendering. On systems which support OpenGL, NVIDIA's OpenGL implementation is provided with the CUDA Driver.
OpenGL ES is an embedded systems graphics library used for 2D and 3D rendering. On systems which support OpenGL ES, NVIDIA's OpenGL ES implementation is provided with the CUDA Driver.
Vulkan is a low-overhead, cross-platform 3D graphics and compute API. Vulkan targets high-performance realtime 3D graphics applications such as video games and interactive media across all platforms. On systems which support Vulkan, NVIDIA's Vulkan implementation is provided with the CUDA Driver. For building and running Vulkan applications one needs to install the Vulkan SDK.
OpenMP is an API for multiprocessing programming. OpenMP can be installed using your Linux distribution's package manager system. It usually comes preinstalled with GCC. It can also be found at the OpenMP website.
Screen is a windowing system found on the QNX operating system. Screen is usually found as part of the root filesystem.
X11 is a windowing system commonly found on *-nix style operating systems. X11 can be installed using your Linux distribution's package manager, and comes preinstalled on Mac OS X systems.
EGL is an interface between Khronos rendering APIs (such as OpenGL, OpenGL ES or OpenVG) and the underlying native platform windowing system.
EGLOutput is a set of EGL extensions which allow EGL to render directly to the display.
EGLSync is a set of EGL extensions which provides sync objects that are synchronization primitive, representing events whose completion can be tested or waited upon.
NvSci is a set of communication interface libraries out of which CUDA interops with NvSciBuf and NvSciSync. NvSciBuf allows applications to allocate and exchange buffers in memory. NvSciSync allows applications to manage synchronization objects which coordinate when sequences of operations begin and end.
NvMedia provides powerful processing of multimedia data for true hardware acceleration across NVIDIA Tegra devices. Applications leverage the NvMedia Application Programming Interface (API) to process the image and video data.
These CUDA features are needed by some CUDA samples. They are provided by either the CUDA Toolkit or CUDA Driver. Some features may not be available on your system.
CUFFT Callback Routines are user-supplied kernel routines that CUFFT will call when loading or storing data. These callback routines are only available on Linux x86_64 and ppc64le systems.
CDP (CUDA Dynamic Parallellism) allows kernels to be launched from threads running on the GPU. CDP is only available on GPUs with SM architecture of 3.5 or above.
Multi Block Cooperative Groups(MBCG) extends Cooperative Groups and the CUDA programming model to express inter-thread-block synchronization. MBCG is available on GPUs with Pascal and higher architecture.
Multi Device Cooperative Groups extends Cooperative Groups and the CUDA programming model enabling thread blocks executing on multiple GPUs to cooperate and synchronize as they execute. This feature is available on GPUs with Pascal and higher architecture.
CUBLAS (CUDA Basic Linear Algebra Subroutines) is a GPU-accelerated version of the BLAS library.
IPC (Interprocess Communication) allows processes to share device pointers.
CUFFT (CUDA Fast Fourier Transform) is a GPU-accelerated FFT library.
CURAND (CUDA Random Number Generation) is a GPU-accelerated RNG library.
CUSPARSE (CUDA Sparse Matrix) provides linear algebra subroutines used for sparse matrix calculations.
CUSOLVER library is a high-level package based on the CUBLAS and CUSPARSE libraries. It combines three separate libraries under a single umbrella, each of which can be used independently or in concert with other toolkit libraries. The intent ofCUSOLVER is to provide useful LAPACK-like features, such as common matrix factorization and triangular solve routines for dense matrices, a sparse least-squares solver and an eigenvalue solver. In addition cuSolver provides a new refactorization library useful for solving sequences of matrices with a shared sparsity pattern.
NPP (NVIDIA Performance Primitives) provides GPU-accelerated image, video, and signal processing functions.
NVGRAPH is a GPU-accelerated graph analytics library.
NVJPEG library provides high-performance, GPU accelerated JPEG decoding functionality for image formats commonly used in deep learning and hyperscale multimedia applications.
NVRTC (CUDA RunTime Compilation) is a runtime compilation library for CUDA C++.
Stream Priorities allows the creation of streams with specified priorities. Stream Priorities is only available on GPUs with SM architecture of 3.5 or above.
UVM (Unified Virtual Memory) enables memory that can be accessed by both the CPU and GPU without explicit copying between the two. UVM is only available on Linux and Windows systems.
FP16 is a 16-bit floating-point format. One bit is used for the sign, five bits for the exponent, and ten bits for the mantissa.
NVCC support of C++11 features.
We welcome your input on issues and suggestions for samples. At this time we are not accepting contributions from the public, check back here as we evolve our contribution model.
We use Google C++ Style Guide for all the sources https://google.github.io/styleguide/cppguide.html
Answers to frequently asked questions about CUDA can be found at http://developer.nvidia.com/cuda-faq and in the CUDA Toolkit Release Notes.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。