Bringing Existing Code to CUDA Using constexpr and std::pmrprinciples from introductory CUDA examples to an existing project that has a meaningful amount of non-trivial code. • Provide some guidance to people about to embark on using CUDA to speed up existing software float* y) { for (int i = 0; i < n; i++) y[i] = x[i] + y[i]; } TEST_CASE("cppcon-0", "[CUDA]") { int N = 1 << 20; float* x = new float[N]; float* y = new float[N]; for (int add_cpu(N, x, y); delete[] x; delete[] y; } An Even Easier Introduction to CUDA 4 |TEST_CASE("cppcon-1", "[CUDA]") { int N = 1 << 20; float* x; float* y; cudaMallocManaged(&x, N*sizeof(float));0 码力 | 51 页 | 3.68 MB | 6 月前3
C++高性能并行编程与优化 - 课件 - 08 CUDA 开启的 GPU 编程CUDA 开启的 GPU 编程 by 彭于斌( @archibate ) 往期录播: https://www.bilibili.com/video/BV1fa411r7zp 课程 PPT 和代码: https://github.com/parallel101/course 前置条件 • 学过 C/C++ 语言编程。 • 理解 malloc/free 之类的概念。 • 熟悉 STL 中的容器、函数模板等。 中的容器、函数模板等。 • 英伟达 GTX900 及以上显卡。 • CUDA 11 及以上。 • CMake 3.18 及以上。 我负责监督你学习 第 0 章: Hello, world! CMake 中启用 CUDA 支持 • 最新版的 CMake ( 3.18 以上),只需在 LANGUAGES 后面加上 CUDA 即可启用 。 • 然后在 add_executable 里直接加你 cn/docs/IO/51635/NVIDIA_CUDA_Programming_Guide_1.1_chs.pdf CUDA 编译器兼容 C++17 • CUDA 的语法,基本完全兼容 C++ 。包括 C+ +17 新特性,都可以用。甚至可以把任何一个 C++ 项目的文件后缀名全部改成 .cu ,都能编 译出来。 • 这是 CUDA 的一大好处, CUDA 和 C++ 的关 系就像 C++ 和0 码力 | 142 页 | 13.52 MB | 1 年前3
C++高性能并行编程与优化 - 课件 - 09 CUDA C++ 流体仿真实战CUDA C++ 流体仿真实 战 by 彭于斌( @archibate ) 往期录播: https://www.bilibili.com/video/BV16b4y1E74f 课程 PPT 和代码: https://github.com/parallel101/course CUDA 纹理对象 https://docs.nvidia.com/cuda/cuda-c-programming-guide/index g-guide/index.html#texture-and-surface-memory CUDA 多维数组:封装 • cudaMalloc3DArray 用于分配一个三维数组。 各维度上的大小通过 cudaExtent 指定,方 便起见我们的 C++ 封装类用了 uint3 表示 大小。 • GPU 的多维数组有特殊的数据排布来保障 访存的高效,和我们 CPU 那样简单地行主 序或列主序(如 序或列主序(如 a[x + nx * y] )的多维数组 不一样。 • 随后可用 cudaMemcpy3D 在 GPU 的三 维数组和 CPU 的三维数组之间拷贝数据。 CUDA 表面对象:封装 • 要访问一个多维数组,必须先创建一个表面对象 ( cudaSurfaceObject_t )。 • 考虑到多维数组始终是需要通过表面对象来访问的,这 里我们让表面对象继承自多维数组。 •0 码力 | 58 页 | 14.90 MB | 1 年前3
PyTorch Release Notesimage. The container also includes the following: ‣ Ubuntu 22.04 including Python 3.10 ‣ NVIDIA CUDA® 12.1.1 ‣ NVIDIA cuBLAS 12.1.3.1 ‣ NVIDIA cuDNN 8.9.3 ‣ NVIDIA NCCL 2.18.3 ‣ NVIDIA RAPIDS™ 23 Release 23.07 PyTorch RN-08516-001_v23.07 | 6 Driver Requirements Release 23.07 is based on CUDA 12.1.1, which requires NVIDIA Driver release 530 or later. However, if you are running on a data center R530). The CUDA driver's compatibility package only supports particular drivers. Thus, users should upgrade from all R418, R440, R460, and R520 drivers, which are not forward- compatible with CUDA 12.1. For0 码力 | 365 页 | 2.94 MB | 1 年前3
Bridging the Gap: Writing Portable Programs for CPU and GPUthe Gap: Writing Portable Programs for CPU and GPU using CUDA Thomas Mejstrik Sebastian Woblistin 2/66Content 1 Motivation Audience etc.. Cuda crash course Quiz time 2 Patterns Oldschool host device everywhere Conditional function body constexpr everything Disable Cuda warnings host device template 3 The dark path Function dispatch triple 4 Cuda proposal Conditional host device Forbid bad cross function dark path Cuda proposal Thank you Motivation 1 Motivation Audience etc.. Cuda crash course Quiz time 2 Patterns 3 The dark path 4 Cuda proposal5/66 Motivation Patterns The dark path Cuda proposal0 码力 | 124 页 | 4.10 MB | 6 月前3
Taro: Task graph-based Asynchronous Programming Using C++ CoroutinePolling D C 1 #include2 #include cuda.hpp> 3 4 taro::Taro taro{NUM_THREADS}; 5 auto cuda = taro.cuda_scheduler(NUM_STREAMS); 6 29Taro’s Programming Model – Example com/dian-lun-lin/taro A B Callback Wait Polling D C 7 auto task_a = taro.emplace([&]() { 8 cuda.wait([&](cudaStream_t stream) { 9 kernel_a1<<<32, 256, 0, stream>>>(); 10 }); // synchronize 11 7 auto task_a = taro.emplace([&]() { 8 cuda.wait([&](cudaStream_t stream) { 9 kernel_a1<<<32, 256, 0, stream>>>(); 10 }); // synchronize 11 }); CUDA stream for offloading GPU kernels 32Taro’s 0 码力 | 84 页 | 8.82 MB | 6 月前3
POCOAS in C++: A Portable Abstraction for Distributed Data Structuresvery fast intra-node transfers GPU GPU Fast Intra- Node Fabric DataGPU Communication Libraries CUDA-Aware MPI NVSHMEM ROC_SHMEM - Communication libraries offering increasing support for GPU-to-GPU will utilize both GPUDirect RDMA and NVLink GASNet-EX Memory KindsGPU Communication Libraries CUDA-Aware MPI NVSHMEM ROC_SHMEM - Communication libraries offering increasing support for GPU-to-GPU = BCL::broadcast(ptr, 0); ptr[BCL::rank()] = BCL::rank(); BCL::cuda::ptrptr = nullptr; if (BCL::rank() == 0) { ptr = BCL::cuda::alloc (BCL::nprocs()); } ptr = BCL::broadcast(ptr, 0); ptr[BCL::rank()] 0 码力 | 128 页 | 2.03 MB | 6 月前3
全连接神经网络实战. pytorch 版. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 2.1 基本网络结构 11 2.2 使用 cuda 来训练网络 13 3 更完善的神经网络 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 导入 pytorch 6 1.2 导入样本数据 7 本章节将神经网络训练之前的准备工作进行全面介绍。但我们并不介绍如何安装 pytorch,一是由 于不同版本的 pytorch 会依赖于不同的 cuda 工具,二是因为官网资料非常齐全,也有很多博客来 介绍,因此没有必要赘述。 1.1 导入 pytorch 首先我们需要明白一个术语:tensor。这个词被翻译为中文叫张量。1 维标量是一种 tensor; 的网络训练会自动帮你进行转换,所以我们不需要自己去操作,因此并不需要 设置 target_transf orm。 前两节的源码参见 chapter1.py。 2. 构建神经网络 2.1 基本网络结构 11 2.2 使用 cuda 来训练网络 13 本章描述如何构建神经网络模型。 2.1 基本网络结构 我们定义神经网络的结构。在 pytorch 中要想使用神经网络,需要继承 nn.Module: c l a s s0 码力 | 29 页 | 1.40 MB | 1 年前3
动手学深度学习 v2.03.1 创建和运行EC2实例 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 750 16.3.2 安装CUDA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 755 16.3.3 安装库以运行代码 环境: conda activate d2l 安装深度学习框架和d2l软件包 在安装深度学习框架之前,请先检查计算机上是否有可用的GPU。例如可以查看计算机是否装有NVIDIA GPU并已安装CUDA9。如果机器没有任何GPU,没有必要担心,因为CPU在前几章完全够用。但是,如果想 流畅地学习全部章节,请提早获取GPU并且安装深度学习框架的GPU版本。 我们可以按如下方式安装PyTorch的CPU或GPU版本: ow系统的命令行窗口中运行以下命令前, 需先将当前路径定位到刚下载的本书代码解压后的目录): jupyter notebook 9 https://developer.nvidia.com/cuda‐downloads 10 目录 现在可以在Web浏览器中打开http://localhost:8888(通常会自动打开)。由此,我们可以运行这本书中每个 部分的代码。在运行书籍代码、更新深0 码力 | 797 页 | 29.45 MB | 1 年前3
AnEditor Can Do That?CMake Presets support 3. ARM and ARM64 support (Raspberry Pi, Surface Pro X, Apple Silicon) 4. CUDA IntelliSense and GPU debuggingVisual Studio Code What’s new? 1. GitHub Codespaces (coding from your CMake Presets support 3. ARM and ARM64 support (Raspberry Pi, Surface Pro X, Apple Silicon) 4. CUDA IntelliSense and GPU debugging 5. Disassembly View while debugging Preview!Visual Studio Code What’s CMake Presets support 3. ARM and ARM64 support (Raspberry Pi, Surface Pro X, Apple Silicon) 4. CUDA IntelliSense and GPU debugging 5. Disassembly View while debugging Preview!Visual Studio Code What’s0 码力 | 71 页 | 2.53 MB | 6 月前3
共 263 条
- 1
- 2
- 3
- 4
- 5
- 6
- 27













