views:

443

answers:

4

My OpenCL program can find the GPU device when I am logged in at the console, but not when I am logged in remotely with ssh. Further, if I run the program as root in the ssh session, the program can find the GPU.

The computer is a Snow Leopard Mac with a GeForce 9400 GPU.

If I run the program (see below) from the console or as root, the output is as follows (notice the "GeForce 9400" line):

2 devices found
Device #0 name = GeForce 9400
Device #1 name = Intel(R) Core(TM)2 Duo CPU     P8700  @ 2.53GHz

but if it is just me, over ssh, there is no GeForce 9400 entry:

1 devices found
Device #0 name = Intel(R) Core(TM)2 Duo CPU     P8700  @ 2.53GHz

I would like to test my code on the GPU without having to be root. Is that possible? Simplified GPU finding program below:

#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;
}

EDIT: I found essentially the same question being asked on nvidia's forums. Unfortunately, the only answer was of the form "this is the wrong forum".

+1  A: 

On Windows, it seems that remote access to the GPU might not be possible, according to this forum thread.

That post is about Windows not Mac, and thus does not directly address this question. As no one has provided any answers yet, so this is the most relevant information I have found so far.

Christopher Bruns
A: 

OK, I don't know Jack about Snow Leopard or OpenCL, but...

I've heard that the Mac desktop is bases on a version of XWindows. In that case, this article: http://developer.amd.com/support/KnowledgeBase/Lists/KnowledgeBase/DispForm.aspx?ID=19 which discusses "how to modify the security settings to allow the remote session access to the X server running on the system". might be helpfull.

Since that article is about ATI Stream applications (instead of OpenCL) and Linux (instead of MacOS) it might not be helpfull, but take a look and judge for yourself.

Die in Sente
Thanks for the tip. I had not seen that document before. The solutions presented for Linux involve changing the permissions on /dev/nvidiactl. Unfortunately I could not find that device nor anything else suggestive on the Mac.The solutions for Windows boiled down to using VNC, which sounds like a great suggestion. Unfortunately I tried VNC to the Mac, and it still did not help. Same desktop on the console finds the GPU. Over VNC, no GPU found. Unless I'm root. Presumably there is a permission somewhere...
Christopher Bruns
The Mac desktop is not based on XWindows - the design and architecture is quite different. There is actually a separate package on the system disc called X11 you can install to support X applications (ie. many traditional Unix apps), which are hosted inside the native Mac windowing system.
gavinb
A: 

I expect the GPU resource is owned by the desktop session (which is always present, even if to show the login screen), which is why it is not available to remote sessions. Forcing the issue by changing permissions is subverting the system and is bound to lead to problems.

Have you tried running Screen Sharing to remotely access the Mac rather than ssh? That way you can run the app on the desktop as normal, and see your results (potentially with some latency, depending on your network connection).

gavinb
A: 

What's the status of the machine when you're trying to ssh to it? With my macs, if only the login screen is showing, I can't ssh to it, and if my user account is logged in at the desktop, then a program invoked by ssh can access the gpu. I haven't tried to create a new user account on my machine yet. You may want to set up auto-login for your account and then just require a password to wake from screensaver. That should give you acceptable security and still ensure that your user account has access to the GPU.