TOP

NVML查询显卡信息(五)
2017-10-12 17:59:02 】 浏览:12165
Tags:NVML 查询 显卡 信息

compute processes on the GPU
printf("\n"); unsigned int infoCount; nvmlProcessInfo_t infos[999]; result = nvmlDeviceGetComputeRunningProcesses(device, &infoCount, infos); if (NVML_SUCCESS != result) { printf("Failed to get ComputeRunningProcesses for device %i: %s\n", i, nvmlErrorString(result)); } else { HANDLE handle; //定义CreateToolhelp32Snapshot系统快照句柄 handle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);//获得系统快照句柄 PROCESSENTRY32 *info; //定义PROCESSENTRY32结构字指 //PROCESSENTRY32 结构的 dwSize 成员设置成 sizeof(PROCESSENTRY32) info = new PROCESSENTRY32; info->dwSize = sizeof(PROCESSENTRY32); //调用一次 Process32First 函数,从快照中获取进程列表 Process32First(handle, info); //重复调用 Process32Next,直到函数返回 FALSE 为止 printf("------ Information about running compute processes on the GPU ------- \n"); for (int i = 0; i < infoCount; i++) { printf("PID: %d 显存占用:%lld bytes ", infos[i].pid, infos[i].usedGpuMemory); while (Process32Next(handle, info) != FALSE) { if (info->th32ProcessID == infos[i].pid) { //printf(" %s\n", info->szExeFile); HANDLE hProcess = NULL; //打开目标进程 hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, info->th32ProcessID); if (hProcess == NULL) { printf("\nOpen Process fAiled:%d\n", GetLastError()); break; } char strFilePath[MAX_PATH]; GetModuleFileNameEx(hProcess, NULL, strFilePath, MAX_PATH); printf(" %s\n", strFilePath); CloseHandle(hProcess); break; } } } delete info; CloseHandle(handle); } //BAR1 memory printf("\n"); printf("------ Clocks ------- \n"); unsigned int max_clock; result = nvmlDeviceGetMaxClockInfo(device, NVML_CLOCK_GRAPHICS, &max_clock); if (NVML_SUCCESS != result) { printf("device %i nvmlDeviceGetMaxClockInfo Failed : %s\n", i, nvmlErrorString(result)); } unsigned int clock; result = nvmlDeviceGetClockInfo(device, NVML_CLOCK_GRAPHICS, &clock); if (NVML_SUCCESS != result) { printf("Failed to get NVML_CLOCK_GRAPHICS info for device %i: %s\n", i, nvmlErrorString(result)); } else { printf("GRAPHICS: %6d Mhz max clock :%d \n", clock, max_clock); } result = nvmlDeviceGetMaxClockInfo(device, NVML_CLOCK_SM, &max_clock); if (NVML_SUCCESS != result) { printf("Failed to get max NVML_CLOCK_SM for device %i: %s\n", i, nvmlErrorString(result)); } result = nvmlDeviceGetClockInfo(device, NVML_CLOCK_SM, &clock); if (NVML_SUCCESS != result) { printf("Failed to get current NVML_CLOCK_SM for device %i: %s\n", i, nvmlErrorString(result)); } else { printf(" SM: %6d Mhz max clock :%d \n", clock, max_clock); } result = nvmlDeviceGetMaxClockInfo(device, NVML_CLOCK_MEM, &max_clock); if (NVML_SUCCESS != result) { printf("Failed to get max NVML_CLOCK_MEM for device %i: %s\n", i, nvmlErrorString(result)); } result = nvmlDeviceGetClockInfo(device, NVML_CLOCK_MEM, &clock); if (NVML_SUCCESS != result) { printf("Failed to get current NVML_CLOCK_MEM for device %i: %s\n", i, nvmlErrorString(result)); } else { printf(" MEM: %6d Mhz max clock :%d \n", clock, max_clock); } result = nvmlDeviceGetMaxClockInfo(device, NVML_CLOCK_VIDEO, &max_clock); if (NVML_
NVML查询显卡信息(五) https://www.cppentry.com/bencandy.php?fid=49&id=151626

首页 上一页 2 3 4 5 6 下一页 尾页 5/6/6
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇c++ 端口扫描程序 下一篇进程查杀