PsychtoolboxKernelDriver

I'm running PTB in R2012b on a Mid 2010 MacPro (OS 10.7.5) with two GPUs (dual ATI Radeon HD 5770 1024MB). I'm using a single window on a VIEWPixx (the other GPU is just showing me MATLAB on a 27" Cinema Display).

After seeing messages advising me to try the PsychtoolboxKernelDriver many times, and trying to rule out other potential causes of periodic crashes, I decided to implement it. Now that I've done that, I see a message that says something about two instances of the driver being used #0 and #1 perhaps (forgive my lack of clarity on this point, I'm running a subject right now and I don't want to interrupt data collection, but I saw the message go by when I started my script).

I'm curious, what's this about? I see the following in the help for the driver:

"The driver only works with one single graphics card at a time. On a
single-gpu system it will just work. On a MacBookPro hybrid-graphics
system with an integrated intel gpu and a discrete NVidia or AMD gpu, it
will automatically switch to use the proper gpu. On a multi-gpu system
with multiple discrete gpu's, e.g., MacPro with multiple graphics cards
installed, it will use the default gpu zero by default. You can ask it use a
different gpu by calling the command PsychTweak('UseGPUIndex', gpuidx);
to select gpu 'gpuidx' - numbering starts at zero. Then call clear
Screen, so Screen() actually picks up the new setting. Simultaneous use
of multiple gpu's is not supported at this time."

This suggests to me that the driver should only be using one GPU, so what's with the two instances message? is this because the GFX card is dual-head?

Everything's working swimmingly (no crashes yet; *fingers-crossed*), so I'm not worried or anything, but I'd like to understand exactly what's going on.

Thanks for any help / advice in advance!
Update:

Here's what I was vague about before:

PTB-INFO: Connection to Psychtoolbox kernel support driver instance #0 (Revision 0) established.
PTB-INFO: Connection to Psychtoolbox kernel support driver instance #1 (Revision 0) established.

Can anybody tell me what this means and how it relates to the point made in the help file that the "driver only works with one single graphics card at a time."

--- In psychtoolbox@yahoogroups.com, "braindemonium" <hermanj@...> wrote:
>
> I'm running PTB in R2012b on a Mid 2010 MacPro (OS 10.7.5) with two GPUs (dual ATI Radeon HD 5770 1024MB). I'm using a single window on a VIEWPixx (the other GPU is just showing me MATLAB on a 27" Cinema Display).
>
> After seeing messages advising me to try the PsychtoolboxKernelDriver many times, and trying to rule out other potential causes of periodic crashes, I decided to implement it. Now that I've done that, I see a message that says something about two instances of the driver being used #0 and #1 perhaps (forgive my lack of clarity on this point, I'm running a subject right now and I don't want to interrupt data collection, but I saw the message go by when I started my script).
>
> I'm curious, what's this about? I see the following in the help for the driver:
>
> "The driver only works with one single graphics card at a time. On a
> single-gpu system it will just work. On a MacBookPro hybrid-graphics
> system with an integrated intel gpu and a discrete NVidia or AMD gpu, it
> will automatically switch to use the proper gpu. On a multi-gpu system
> with multiple discrete gpu's, e.g., MacPro with multiple graphics cards
> installed, it will use the default gpu zero by default. You can ask it use a
> different gpu by calling the command PsychTweak('UseGPUIndex', gpuidx);
> to select gpu 'gpuidx' - numbering starts at zero. Then call clear
> Screen, so Screen() actually picks up the new setting. Simultaneous use
> of multiple gpu's is not supported at this time."
>
> This suggests to me that the driver should only be using one GPU, so what's with the two instances message? is this because the GFX card is dual-head?
>
> Everything's working swimmingly (no crashes yet; *fingers-crossed*), so I'm not worried or anything, but I'd like to understand exactly what's going on.
>
> Thanks for any help / advice in advance!
>
Sure. The driver itself works in principle with as many gpu's as there are installed. For each powered on gpu, one dedicated instance of the driver is created and running. Because your machine has two gpus, two instances of the driver (instance #0 and #1) are created and detected by ptb's Screen() mex file at startup. However ptb itself currently has no way of figuring out, which driver instance is responsible for handling which gpu for which connected display on a multi-gpu setup, ie., on a MacPro. Ironically, the same OSX graphics system bugs which require the kernel driver in the first place to get a useable system seem to prevent me from implementing some robust method to solve this auto-detection of gpu's and driver assignments -- A little hello from Murphy's law. There also isn't any infrastructure in place for manually configuring the mapping of display screens to gpus and thereby driver instances. There is one global internal variable that stores which gpu/driver instance should be used for a ptb session, so for all practical purposes, ptb can only work with one driver instance at a time on osx.

On a hybrid graphics laptop (Macbook or MacBookPro) with automatic graphics switching, ptb has heuristics to find out, which of the two gpu's (intel integrated low perf/low power, or nvidia/amd/ati discrete high perf/high power) is active during a session, so it can automatically select which driver instance it should use, Intel or NVidia/AMD.

On your setup this is not possible. Therefore there is this PsychTweak('UseGPUIndex') command for you to manually select which gpu to use. If stuff works you selected the correct one. If it spews lots of errors or timing warnings etc. you probably selected the wrong one, or got unlucky and errors for a wrong selection cancelled each other out. If you run your stimulus display on a resolution different from the non-stimulus displays you should notice quickly if the wrong gpu is operated by the PsychtoolboxKernelDriver, e.g, because the detected video refresh interval or vblank endline from beamposition query contradicts the display settings.

We don't have any multi-gpu MacPro's here, so i can't develop anything more clever or test it. I don't think they provide any good value, given how unbelievably broken multi-display and multi-gpu support seems to be with many (most?) OSX versions.

I also can't really test our hybrid-graphics switching support anymore, since the update from OSX 10.7.4 to 10.7.5 broke most of the ability of "gfxCardStatus" to select which gpu to use on my 2010 MacBookPro (Strong work, fruit company!), but i think that still works fine.

But what kind of crashes are you referring to? The driver can fix a couple of problems but it is neither meant to cause nor prevent any crashes. Unless you refer to regular errors as "crashes".

-mario

--- In psychtoolbox@yahoogroups.com, "braindemonium" <hermanj@...> wrote:
>
> Update:
>
> Here's what I was vague about before:
>
> PTB-INFO: Connection to Psychtoolbox kernel support driver instance #0 (Revision 0) established.
> PTB-INFO: Connection to Psychtoolbox kernel support driver instance #1 (Revision 0) established.
>
> Can anybody tell me what this means and how it relates to the point made in the help file that the "driver only works with one single graphics card at a time."
>
> --- In psychtoolbox@yahoogroups.com, "braindemonium" <hermanj@> wrote:
> >
> > I'm running PTB in R2012b on a Mid 2010 MacPro (OS 10.7.5) with two GPUs (dual ATI Radeon HD 5770 1024MB). I'm using a single window on a VIEWPixx (the other GPU is just showing me MATLAB on a 27" Cinema Display).
> >
> > After seeing messages advising me to try the PsychtoolboxKernelDriver many times, and trying to rule out other potential causes of periodic crashes, I decided to implement it. Now that I've done that, I see a message that says something about two instances of the driver being used #0 and #1 perhaps (forgive my lack of clarity on this point, I'm running a subject right now and I don't want to interrupt data collection, but I saw the message go by when I started my script).
> >
> > I'm curious, what's this about? I see the following in the help for the driver:
> >
> > "The driver only works with one single graphics card at a time. On a
> > single-gpu system it will just work. On a MacBookPro hybrid-graphics
> > system with an integrated intel gpu and a discrete NVidia or AMD gpu, it
> > will automatically switch to use the proper gpu. On a multi-gpu system
> > with multiple discrete gpu's, e.g., MacPro with multiple graphics cards
> > installed, it will use the default gpu zero by default. You can ask it use a
> > different gpu by calling the command PsychTweak('UseGPUIndex', gpuidx);
> > to select gpu 'gpuidx' - numbering starts at zero. Then call clear
> > Screen, so Screen() actually picks up the new setting. Simultaneous use
> > of multiple gpu's is not supported at this time."
> >
> > This suggests to me that the driver should only be using one GPU, so what's with the two instances message? is this because the GFX card is dual-head?
> >
> > Everything's working swimmingly (no crashes yet; *fingers-crossed*), so I'm not worried or anything, but I'd like to understand exactly what's going on.
> >
> > Thanks for any help / advice in advance!
> >
>
Mario --

The crashes are awfully non-specific, I wish I could describe them better, but the best I can do is: MATLAB stops responding, and if I look in activity monitor, the CPU usage spikes from it's normal 40-50% up to 300%, and I have to force-quit it. I only occasionally get dump-files, and they haven't seemed very similar from crash-to-crash. Since I was getting the notices advising me to use the kernel driver, I thought I'd start there. It's really quite frustrating as I can't seem to nail them down. My plan is to call up Mathworks & ask them for advice on "advanced" debugging, since I'm having no success with my usual debugging techniques (try/catch, using "disp" to show me exactly at what line of code I'm at at any given moment, et cetera).

That aside, I'd love some more advice on how to use "PsychTweak('UseGPUIndex')" as every time I've tried so far, I've not been able to get anywhere. If I don't use it, I don't get any errors or weird behaviors, but if I try to use it, I'm informed I've got a timing error.

I'm also advised to check out DisplayOutputMappings, and thereby to using Screen('Preference', 'ScreenToHead'). I tried every combination that seemed to make sense: since my 2 gfxcards have 3 output ports, I'm assuming I've got 3 heads, so I'm further assuming there are 6 possible combinations of output & crtc to try. However, all of these gave me a flashing exclamation point and the timing error remained.

Any advice? Is there a way to query which output/crtc ptb "thinks" it's using? Or to look at output/crtc info at a system-level?

Thanks in advance for any assistance, you rock!


--- In psychtoolbox@yahoogroups.com, "Mario" <mario.kleiner@...> wrote:
>
>
>
> Sure. The driver itself works in principle with as many gpu's as there are installed. For each powered on gpu, one dedicated instance of the driver is created and running. Because your machine has two gpus, two instances of the driver (instance #0 and #1) are created and detected by ptb's Screen() mex file at startup. However ptb itself currently has no way of figuring out, which driver instance is responsible for handling which gpu for which connected display on a multi-gpu setup, ie., on a MacPro. Ironically, the same OSX graphics system bugs which require the kernel driver in the first place to get a useable system seem to prevent me from implementing some robust method to solve this auto-detection of gpu's and driver assignments -- A little hello from Murphy's law. There also isn't any infrastructure in place for manually configuring the mapping of display screens to gpus and thereby driver instances. There is one global internal variable that stores which gpu/driver instance should be used for a ptb session, so for all practical purposes, ptb can only work with one driver instance at a time on osx.
>
> On a hybrid graphics laptop (Macbook or MacBookPro) with automatic graphics switching, ptb has heuristics to find out, which of the two gpu's (intel integrated low perf/low power, or nvidia/amd/ati discrete high perf/high power) is active during a session, so it can automatically select which driver instance it should use, Intel or NVidia/AMD.
>
> On your setup this is not possible. Therefore there is this PsychTweak('UseGPUIndex') command for you to manually select which gpu to use. If stuff works you selected the correct one. If it spews lots of errors or timing warnings etc. you probably selected the wrong one, or got unlucky and errors for a wrong selection cancelled each other out. If you run your stimulus display on a resolution different from the non-stimulus displays you should notice quickly if the wrong gpu is operated by the PsychtoolboxKernelDriver, e.g, because the detected video refresh interval or vblank endline from beamposition query contradicts the display settings.
>
> We don't have any multi-gpu MacPro's here, so i can't develop anything more clever or test it. I don't think they provide any good value, given how unbelievably broken multi-display and multi-gpu support seems to be with many (most?) OSX versions.
>
> I also can't really test our hybrid-graphics switching support anymore, since the update from OSX 10.7.4 to 10.7.5 broke most of the ability of "gfxCardStatus" to select which gpu to use on my 2010 MacBookPro (Strong work, fruit company!), but i think that still works fine.
>
> But what kind of crashes are you referring to? The driver can fix a couple of problems but it is neither meant to cause nor prevent any crashes. Unless you refer to regular errors as "crashes".
>
> -mario
>
> --- In psychtoolbox@yahoogroups.com, "braindemonium" <hermanj@> wrote:
> >
> > Update:
> >
> > Here's what I was vague about before:
> >
> > PTB-INFO: Connection to Psychtoolbox kernel support driver instance #0 (Revision 0) established.
> > PTB-INFO: Connection to Psychtoolbox kernel support driver instance #1 (Revision 0) established.
> >
> > Can anybody tell me what this means and how it relates to the point made in the help file that the "driver only works with one single graphics card at a time."
> >
> > --- In psychtoolbox@yahoogroups.com, "braindemonium" <hermanj@> wrote:
> > >
> > > I'm running PTB in R2012b on a Mid 2010 MacPro (OS 10.7.5) with two GPUs (dual ATI Radeon HD 5770 1024MB). I'm using a single window on a VIEWPixx (the other GPU is just showing me MATLAB on a 27" Cinema Display).
> > >
> > > After seeing messages advising me to try the PsychtoolboxKernelDriver many times, and trying to rule out other potential causes of periodic crashes, I decided to implement it. Now that I've done that, I see a message that says something about two instances of the driver being used #0 and #1 perhaps (forgive my lack of clarity on this point, I'm running a subject right now and I don't want to interrupt data collection, but I saw the message go by when I started my script).
> > >
> > > I'm curious, what's this about? I see the following in the help for the driver:
> > >
> > > "The driver only works with one single graphics card at a time. On a
> > > single-gpu system it will just work. On a MacBookPro hybrid-graphics
> > > system with an integrated intel gpu and a discrete NVidia or AMD gpu, it
> > > will automatically switch to use the proper gpu. On a multi-gpu system
> > > with multiple discrete gpu's, e.g., MacPro with multiple graphics cards
> > > installed, it will use the default gpu zero by default. You can ask it use a
> > > different gpu by calling the command PsychTweak('UseGPUIndex', gpuidx);
> > > to select gpu 'gpuidx' - numbering starts at zero. Then call clear
> > > Screen, so Screen() actually picks up the new setting. Simultaneous use
> > > of multiple gpu's is not supported at this time."
> > >
> > > This suggests to me that the driver should only be using one GPU, so what's with the two instances message? is this because the GFX card is dual-head?
> > >
> > > Everything's working swimmingly (no crashes yet; *fingers-crossed*), so I'm not worried or anything, but I'd like to understand exactly what's going on.
> > >
> > > Thanks for any help / advice in advance!
> > >
> >
>
--- In psychtoolbox@yahoogroups.com, "braindemonium" <hermanj@...> wrote:
>
> Mario --
>
> The crashes are awfully non-specific, I wish I could describe them better, but the best I can do is: MATLAB stops responding, and if I look in activity monitor, the CPU usage spikes from it's normal 40-50% up to 300%, and I have to force-quit it. I only occasionally get dump-files, and they haven't seemed very similar from crash-to-crash. Since I was getting the notices advising me to use the kernel driver, I thought I'd start there. It's really quite frustrating as I can't seem to nail them down. My plan is to call up Mathworks & ask them for advice on "advanced" debugging, since I'm having no success with my usual debugging techniques (try/catch, using "disp" to show me exactly at what line of code I'm at at any given moment, et cetera).
>

When does it happen? At the end of a session, or anywhere? One thing i saw causing such hangs and crashes sporadically is our CVDisplayLink shutdown code when closing an onscreen window on OSX. Our code is perfectly fine, apparently that part of OSX is just pretty buggy as well. Given that the CVDisplayLink timestamping is just inferior band-aid to be used when one is too lazy to install the PsychtoolboxKernelDriver, and it doesn't work very well or reliable on many setups in the first place, i'll likely disable or remove that code soon and leave the kernel driver as the only option to get good timing.


> That aside, I'd love some more advice on how to use "PsychTweak('UseGPUIndex')" as every time I've tried so far, I've not been able to get anywhere. If I don't use it, I don't get any errors or weird behaviors, but if I try to use it, I'm informed I've got a timing error.
>

If stuff works when you don't use that command, then why do you want to use it? If stuff works then that simply means the default settings are correct for your setup, ie., the toolbox is connecting to the proper gpu/driver instance.

> I'm also advised to check out DisplayOutputMappings, and thereby to using Screen('Preference', 'ScreenToHead'). I tried every combination that seemed to make sense: since my 2 gfxcards have 3 output ports, I'm assuming I've got 3 heads, so I'm further assuming there are 6 possible combinations of output & crtc to try. However, all of these gave me a flashing exclamation point and the timing error remained.
>

But only if you play around with PsychTweak, right? So just don't play around with it?

> Any advice? Is there a way to query which output/crtc ptb "thinks" it's using? Or to look at output/crtc info at a system-level?
>

If we could look at it on the system-level we wouldn't need this hacks, but would simply algorithmically look at the system-level and setup stuff automagically.

> Thanks in advance for any assistance, you rock!
>
>
> --- In psychtoolbox@yahoogroups.com, "Mario" <mario.kleiner@> wrote:
> >
> >
> >
> > Sure. The driver itself works in principle with as many gpu's as there are installed. For each powered on gpu, one dedicated instance of the driver is created and running. Because your machine has two gpus, two instances of the driver (instance #0 and #1) are created and detected by ptb's Screen() mex file at startup. However ptb itself currently has no way of figuring out, which driver instance is responsible for handling which gpu for which connected display on a multi-gpu setup, ie., on a MacPro. Ironically, the same OSX graphics system bugs which require the kernel driver in the first place to get a useable system seem to prevent me from implementing some robust method to solve this auto-detection of gpu's and driver assignments -- A little hello from Murphy's law. There also isn't any infrastructure in place for manually configuring the mapping of display screens to gpus and thereby driver instances. There is one global internal variable that stores which gpu/driver instance should be used for a ptb session, so for all practical purposes, ptb can only work with one driver instance at a time on osx.
> >
> > On a hybrid graphics laptop (Macbook or MacBookPro) with automatic graphics switching, ptb has heuristics to find out, which of the two gpu's (intel integrated low perf/low power, or nvidia/amd/ati discrete high perf/high power) is active during a session, so it can automatically select which driver instance it should use, Intel or NVidia/AMD.
> >
> > On your setup this is not possible. Therefore there is this PsychTweak('UseGPUIndex') command for you to manually select which gpu to use. If stuff works you selected the correct one. If it spews lots of errors or timing warnings etc. you probably selected the wrong one, or got unlucky and errors for a wrong selection cancelled each other out. If you run your stimulus display on a resolution different from the non-stimulus displays you should notice quickly if the wrong gpu is operated by the PsychtoolboxKernelDriver, e.g, because the detected video refresh interval or vblank endline from beamposition query contradicts the display settings.
> >
> > We don't have any multi-gpu MacPro's here, so i can't develop anything more clever or test it. I don't think they provide any good value, given how unbelievably broken multi-display and multi-gpu support seems to be with many (most?) OSX versions.
> >
> > I also can't really test our hybrid-graphics switching support anymore, since the update from OSX 10.7.4 to 10.7.5 broke most of the ability of "gfxCardStatus" to select which gpu to use on my 2010 MacBookPro (Strong work, fruit company!), but i think that still works fine.
> >
> > But what kind of crashes are you referring to? The driver can fix a couple of problems but it is neither meant to cause nor prevent any crashes. Unless you refer to regular errors as "crashes".
> >
> > -mario
> >
> > --- In psychtoolbox@yahoogroups.com, "braindemonium" <hermanj@> wrote:
> > >
> > > Update:
> > >
> > > Here's what I was vague about before:
> > >
> > > PTB-INFO: Connection to Psychtoolbox kernel support driver instance #0 (Revision 0) established.
> > > PTB-INFO: Connection to Psychtoolbox kernel support driver instance #1 (Revision 0) established.
> > >
> > > Can anybody tell me what this means and how it relates to the point made in the help file that the "driver only works with one single graphics card at a time."
> > >
> > > --- In psychtoolbox@yahoogroups.com, "braindemonium" <hermanj@> wrote:
> > > >
> > > > I'm running PTB in R2012b on a Mid 2010 MacPro (OS 10.7.5) with two GPUs (dual ATI Radeon HD 5770 1024MB). I'm using a single window on a VIEWPixx (the other GPU is just showing me MATLAB on a 27" Cinema Display).
> > > >
> > > > After seeing messages advising me to try the PsychtoolboxKernelDriver many times, and trying to rule out other potential causes of periodic crashes, I decided to implement it. Now that I've done that, I see a message that says something about two instances of the driver being used #0 and #1 perhaps (forgive my lack of clarity on this point, I'm running a subject right now and I don't want to interrupt data collection, but I saw the message go by when I started my script).
> > > >
> > > > I'm curious, what's this about? I see the following in the help for the driver:
> > > >
> > > > "The driver only works with one single graphics card at a time. On a
> > > > single-gpu system it will just work. On a MacBookPro hybrid-graphics
> > > > system with an integrated intel gpu and a discrete NVidia or AMD gpu, it
> > > > will automatically switch to use the proper gpu. On a multi-gpu system
> > > > with multiple discrete gpu's, e.g., MacPro with multiple graphics cards
> > > > installed, it will use the default gpu zero by default. You can ask it use a
> > > > different gpu by calling the command PsychTweak('UseGPUIndex', gpuidx);
> > > > to select gpu 'gpuidx' - numbering starts at zero. Then call clear
> > > > Screen, so Screen() actually picks up the new setting. Simultaneous use
> > > > of multiple gpu's is not supported at this time."
> > > >
> > > > This suggests to me that the driver should only be using one GPU, so what's with the two instances message? is this because the GFX card is dual-head?
> > > >
> > > > Everything's working swimmingly (no crashes yet; *fingers-crossed*), so I'm not worried or anything, but I'd like to understand exactly what's going on.
> > > >
> > > > Thanks for any help / advice in advance!
> > > >
> > >
> >
>

Hi all,


I'm running Mac OS Sierra with PTB 3.0.14.  I'm having a hard time telling if the PsychtoolboxKernelDriver is actually running.  I can see that it installed correctly to Library/Extensions.  Also, when I open the Activity Monitor, I can see a process called 'pkd'.  Is that it?


Thanks.