CUDA 编程相关的开源库
CUDA 编程相关的开源库非常丰富,涵盖了高性能计算、深度学习、图像处理、线性代数、优化算法等多个领域。
1. 通用 GPU 计算库
-
CUDA Toolkit (NVIDIA官方):
包含 CUDA 运行时库、编译器(nvcc
)、调试工具(cuda-gdb
、Nsight
)、数学库(如cuBLAS
、cuFFT
)等。
🔗 CUDA Toolkit - Free Tools and Training | NVIDIA Developer -
Thrust:
CUDA 的 C++ STL 风格模板库,提供高性能的并行算法(如排序、归约、扫描)。
🔗 https://github.com/NVIDIA/thrust -
Kokkos:
跨平台的并行编程模型,支持 CUDA、HIP、OpenMP 等,适合科学计算。
🔗 https://github.com/kokkos/kokkos -
ArrayFire:
高性能通用 GPU 计算库,支持 CUDA/OpenCL,提供易用的数组操作接口。
🔗 https://arrayfire.com
2. 线性代数与数学运算
-
cuBLAS/cuSOLVER/cuSPARSE:
NVIDIA 官方库,提供 BLAS、LAPACK、稀疏矩阵运算等。
🔗 cuBLAS | NVIDIA Developer -
MAGMA:
混合 CPU-GPU 的线性代数库,支持密集矩阵运算。
🔗 MAGMA -
CUTLASS:
NVIDIA 的高性能 CUDA 矩阵乘法库,用于自定义深度学习内核优化。
🔗 https://github.com/NVIDIA/cutlass -
cuTensor (用于张量计算):
针对量子计算和科学计算的张量操作库。
🔗 cuTENSOR | NVIDIA Developer
3. 深度学习与神经网络
-
cuDNN:
NVIDIA 的深度学习加速库(闭源但免费)。
🔗 CUDA Deep Neural Network (cuDNN) | NVIDIA Developer -
TensorRT:
NVIDIA 的高性能深度学习推理库(部分开源)。
🔗 https://github.com/NVIDIA/TensorRT -
OpenAI Triton:
用于编写高效 GPU 内核的 Python DSL,支持 CUDA 后端。
🔗 https://github.com/openai/triton
4. 图像与信号处理
-
NPP (NVIDIA Performance Primitives):
提供图像和信号处理的 CUDA 加速函数。
🔗 NVIDIA Performance Primitives (NPP) | NVIDIA Developer -
OpenCV with CUDA:
OpenCV 的 CUDA 模块(cv::cuda
),支持图像处理加速。
🔗 https://opencv.org -
cuFFT:
NVIDIA 的快速傅里叶变换库。
🔗 cuFFT | NVIDIA Developer
5. 并行算法与数据结构
-
CUB:
CUDA 的底层并行原语库(如块级排序、归约)。
🔗 https://github.com/NVIDIA/cub -
Gunrock:
面向图的 GPU 计算框架。
🔗 https://github.com/gunrock/gunrock -
moderngpu:
高性能 GPU 排序、搜索等算法的模板库。
🔗 https://github.com/moderngpu/moderngpu
6. 调试与性能分析
-
Nsight Tools:
NVIDIA 的性能分析工具(集成在 CUDA Toolkit 中)。
🔗 Nsight Systems | NVIDIA Developer -
CUDA-MEMCHECK:
内存错误检测工具。
🔗 https://docs.nvidia.com/cuda/cuda-memcheck -
nvprof/nv-nsight-cu:
命令行和图形化性能分析工具。
7. 其他工具与框架
-
RAJA:
类似 Kokkos 的并行编程抽象层,支持 CUDA。
🔗 https://github.com/LLNL/RAJA -
SYCL (通过 DPC++ 或 hipSYCL):
跨平台异构编程框架,部分实现支持 CUDA 后端。
🔗 https://github.com/illuhad/hipSYCL -
Alpaka:
跨平台的并行内核抽象库。
🔗 https://github.com/alpaka-group/alpaka
8. 社区与学习资源
-
CUDA Samples:
NVIDIA 官方示例代码(GitHub 或 CUDA Toolkit 自带)。
🔗 https://github.com/NVIDIA/cuda-samples -
Awesome CUDA:
整理的 CUDA 资源列表。
🔗 https://github.com/Erkaman/awesome-cuda
选择建议
-
科学计算:MAGMA + Thrust + cuBLAS
-
深度学习:cuDNN + TensorRT + Triton
-
图像处理:OpenCV + NPP
-
快速开发:ArrayFire 或 Thrust