当我在控制台登录时,我的 OpenCL 程序可以找到 GPU 设备,但当我使用 ssh 远程登录时却找不到。此外,如果我在 ssh 会话中以 root 身份运行该程序,该程序可以找到 GPU。
该计算机是带有 GeForce 9400 GPU 的 Snow Leopard Mac。
如果我从控制台或以 root 身份运行程序(见下文),输出如下(注意“GeForce 9400”行):
2 devices found
Device #0 name = GeForce 9400
Device #1 name = Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz
但如果只是我,通过 ssh,没有 GeForce 9400 条目:
1 devices found
Device #0 name = Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz
我想在 GPU 上测试我的代码,而不必是 root。那可能吗?简化的 GPU 查找程序如下:
#include <stdio.h>
#include <OpenCL/opencl.h>
int main(int argc, char** argv) {
char dname[500];
size_t namesize;
cl_device_id devices[10];
cl_uint num_devices;
int d;
clGetDeviceIDs(0, CL_DEVICE_TYPE_ALL, 10, devices, &num_devices);
printf("%d devices found\n", num_devices);
for (d = 0; d < num_devices; ++d) {
clGetDeviceInfo(devices[d], CL_DEVICE_NAME, 500, dname, &namesize);
printf("Device #%d name = %s\n", d, dname);
}
return 0;
}
编辑:我发现在nvidia 的论坛上提出了基本相同的问题。不幸的是,唯一的答案是“这是错误的论坛”形式。