CUDA profile 大全 —— nsight computer & nsys & pytorch
Cuda API创建对象: #include <cuda_runtime.h> #include <cuda.h> #include <iostream> #include <string> // 获取当前机器的GPU数量 cudaError_t error_id = cudaGetDeviceCount(&deviceCount); for (int dev = 0; dev < deviceCount; ++dev) { cudaSetDevice(dev); // 初始化当前device的属性获取对象 cudaDeviceProp deviceProp; cudaGetDeviceProperties(&deviceProp, dev); printf("\nDevice %d: \"%s\"\n", dev, deviceProp.name);</code></pre><p style=""></p><p style="">拿到数据后可以查看对应feature</p><pre><code>printf(" Total amount of shared memory per block: %zu bytes\n", deviceProp.sharedMemPerBlock); printf(" Total shared memory per multiprocessor: %zu bytes\n", deviceProp.sharedMemPerMultiprocessor); printf(" Total number of registers available per block: %d\n", deviceProp.regsPerBlock); printf(" Warp size: %d\n", deviceProp.warpSize); printf(" Maximum number of threads per multiprocessor: %d\n", deviceProp.maxThreadsPerMultiProcessor); printf(" Maximum number of threads per block: %d\n", deviceProp.maxThreadsPerBlock); printf(" Max dimension size of a block size (x,y,z): (%d, %d, %d)\n", deviceProp.maxThreadsDim[0], deviceProp.maxThreadsDim[1], deviceProp.maxThreadsDim[2]); printf(" Max dimension size of a grid size (x,y,z): (%d, %d, %d)\n", deviceProp.maxGridSize[0], deviceProp.maxGridSize[1], deviceProp.maxGridSize[2]); ...