./nvml_lib:符号查找错误:./nvml_lib:未定义符号:nvmlDeviceGetComputeRunningProcesses_v3
nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Tue_May__3_18:49:52_PDT_2022
Cuda compilation tools, release 11.7, V11.7.64
Build cuda_11.7.r11.7/compiler.31294372_0
Device Driver Version: 470.141.03
NVML Version: 11.470.141.03
Unbuntu 18.04
#include <stdio.h>
#include <stdlib.h>
#include <nvml.h>
int
main(int argc, char* argv[])
{
int i;
unsigned int deviceCount;
nvmlReturn_t result;
char version[64], pname[256];
nvmlProcessInfo_t infos[32];
nvmlDevice_t device;
unsigned int infoCount;
if ((result = nvmlDeviceGetHandleByIndex_v2(0, &device)) != NVML_SUCCESS) {
fprintf(stderr, "error: nvmlDeviceGetHandleByIndex_v2 %d\n", result);
return 1;
}
if ((result = nvmlDeviceGetComputeRunningProcesses_v3(device, &infoCount, infos)) != NVML_SUCCESS) {
fprintf(stderr, "error: Get Compute Running Processes error: d\n", result);
return 1;
}
}
用“_v2”替换“_v3”会产生编译器错误。删除“_v3”会产生相同的运行时错误。
符号 nvmlDeviceGetComputeRunningProcesses_v3 在设备驱动程序版本 470.141.03 中不可用。切换到支持 CUDA 11 的最旧版本的 nvcc,并且能够使用旧的“_v2”调用进行编译和链接。
nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2020 NVIDIA Corporation
Built on Mon_Oct_12_20:09:46_PDT_2020
Cuda compilation tools, release 11.1, V11.1.105
Build cuda_11.1.TC455_06.29190527_0
nm --dynamic /usr/lib/x86_64-linux-gnu/libnvidia-ml.so.1 | grep -i runningprocess
0000000000050e10 T nvmlDeviceGetComputeRunningProcesses
0000000000051010 T nvmlDeviceGetComputeRunningProcesses_v2
0000000000051370 T nvmlDeviceGetGraphicsRunningProcesses
0000000000051570 T nvmlDeviceGetGraphicsRunningProcesses_v2
00000000000518d0 T nvmlDeviceGetMPSComputeRunningProcesses
0000000000051ad0 T nvmlDeviceGetMPSComputeRunningProcesses_v2