CUDA 检查硬件配置

#include 
#include 
#include 
#include "cuda_runtime.h"
#include "device_launch_parameters.h"

using namespace std;

cudaError_t cudaStatus;

int main() {
    int dev = 0;
    cudaDeviceProp devProp;
    
    cudaStatus = cudaGetDeviceCount(&dev);
    for (int i = 0; i < dev; i++) {
        cudaGetDeviceProperties(&devProp, i);
        cout << "使用GPU device " << dev << ": " << devProp.name << endl; 
        cout << "SM的数量:" << devProp.multiProcessorCount << endl; 
        cout << "每个线程块的共享内存大小:" << devProp.sharedMemPerBlock / 1024.0 << " KB" << endl; 
        cout << "每个线程块的最大线程数:" << devProp.maxThreadsPerBlock << endl; 
        cout << "每个EM的最大线程数:" << devProp.maxThreadsPerMultiProcessor << endl; 
        cout << "每个EM的最大线程束数:" << devProp.maxThreadsPerMultiProcessor / 32 << endl;
    }

    return 0;
}
CUDA 检查硬件配置_第1张图片

参考链接:
https://blog.csdn.net/xiaohu2022/article/details/79599947

你可能感兴趣的:(CUDA 检查硬件配置)