Kernel extension for Mac is not automatically loading

Hi everybody,
I tried to load the kernel extension for Mac by following the steps given on the Psychtoolbox website. But it’s not automatically loading I think, at least nothing has happened in Matlab although I didn’t get an error message in the terminal window (see screenshot). Is there something else I need to do? Can I somehow test if the extension is recognized by the system? It seems to be downloaded in the right folder. I have OS Catalina.

Ohne Titel

Does kextstat | grep Psychtoolbox list it?
In which folder did you put it?
What graphics card is this?

-mario

Hi,
what do you mean with kextstat | grep Psychtoolbox ?
I specified in the terminal to load it in the psychotoolbox folder, PsychHardware and if I look there it says it has a kernel driver. Graphic card is: Intel HD Graphics 4000 1536 MB

Thanks a lot!

Oh,now i see, you were in your home directory while unzipping. That means you now have a useless PsychtoolboxKernelDriver.kext/ directory there.

In the terminal, you must first
cd /Library/Extensions/
into the /Library/Extensions/ subfolder.
Then do the unzip as you did.

Then the kextstat command i showed would tell you if the driver got successfully loaded or not.

That said, your machine has an Intel gfx chip, so Psychtoolbox will not use the driver by default, even if it detects it being loaded, because with Intel gfx, there could be a small chance that it will crash the machine or even damage it. This due to the design of Intel graphics hardware, nothing we could do about it. That said, so far no such case of damage is known to me and i have used the driver quite often with a Intel HD 4000 in a macMini 2012. You’d need to use the setenv(‘PSYCH_ALLOW_DANGEROUS’,‘1’) command in Matlab/Octave before first invocation of Screen to allow it to use the driver. You will see some status output of PTB to that effect if the driver was successfully loaded.

All that said, Apple works hard to make it more painful or borderline impossible to use the driver on “modern” macOS versions. If you read the help PsychtoolboxKernelDriver you’ll find that Catalina may throw more obstacles into your way. I expect the one of the next macOS versions to completely kill off our driver, so i strongly advise against upgrading to Catalina or any later version if avoidable.

I use the following script to install the kernel extension in Catalina (the first line you need to edit ptbroot to the path you installed PTB):

Catalina separated the System and User data into two separate drives, and the system drive is by default read-only, so:

  1. You must first disable SIP by rebooting into the Recovery terminal.
  2. Reboot to your normal system, then run this script (that remounts the system drive as writable and moves the kext to the correct location). One issue is that there is an older+signed and newer+unsigned extension, my script allows you to choose either but the older signed extension is probably the most likely to work.
  3. Then reboot to recovery and disable SIP again. Reboot to normal and test if extension is active with kextstat -b PsychtoolboxKernelDriver.

see here for general instructions…

I’m not sure if the remounting etc. is needed? /Library/Extensions/ is not on the read-only system partition if i remember correctly, and the driver should work just fine when installed there. At least i didn’t do this procedure on the one Catalina setup i have.

I’d first try simply installing into the /Library/Extensions/ folder and see if that works, or if disabling SIP etc. is already needed.

The older signed driver would work with Intel HD 4000 graphics, most recent Intel gpu’s status is unknown. The newer unsigned driver just adds support for some more recent AMD Polaris gpu’s. None of the drivers supports AMD Vega gpu’s or the latest AMD Navi gpu’s, so owners of especially expensive high-end Macs or of the MBP 2019 16" will be left out.

I had previously (IIRC around 10.12 or 10.13) had problems with kextload using \Library\Extensions\ which was why I settled on using \System\Library\Extensions to install the extension, then just adjusted for remounting when 10.15 came out. Anyway I removed my extension in \System and tried to put it into \Library\Extensions and it does load — but only the signed driver works unless you disable SIP.

So to the OP, try to install into \Library\Extensions as Mario suggests…

Thanks for your help!
So I typed now:
cd /Library/Extensions/
sudo unzip /Applications/Psychtoolbox/PsychHardware/PsychtoolboxKernelDriver64Bit).kext.zip
I did it also more than once and it asked me to overwrite it (all) and I did. Don’t know if that makes a difference. But unfortunately kextstat | grep Psychtoolbox does not list ist.

Try this:

sudo kextload /Library/Extensions/PsychtoolboxKernelDriver

What does it report? Any difference wrt. kextstat output?

It says “command not found” and “No such file or directory” when I skip sudo :frowning:

Ok, forgot you actually need to add a .kext file suffix:

sudo kextload /Library/Extensions/PsychtoolboxKernelDriver.kext

Yay! So now it seemed to work… it said that system policy prevents loading but my preferences opened up and I could allow it there… than I did it again and the error message didn’t pop up again and kextstat | grep Psychtoolbox does list it now! So does that mean that all is set? :slight_smile:

That’s a step forward. Now if you start Matlab and call Screen() the first time, it will print some message that it established a connection to the PsychtoolboxKernelDriver, but will not use it, because accessing the detected Intel gfx chip is deemed risky. Now you have to clear all and then add the setenv(‘PSYCH_ALLOW_DANGEROUS’,‘1’); command to the Matlab startup.m file - so it executes each time you start Matlab - or to the very top o each of your scripts, or manually. This signals that you are aware of the potential risk that using the driver on your machine could cause hardware malfunctions or potential damage - and a expensive trip to the Apple repair shop, but that you are willing to accept the risk. After that, calling Screen() should just confirm that the connection to the kernel driver has been established and the driver will be used.

The next test would be if you run PerceptualVBLSyncTest() or VBLSyncTest etc. if PTB complains about any timing or timestamping trouble. See help BeampositionQueries or help DisplayOutputMappings to figure out if they work for you and if the mapping of screens to display outputs is correct, and how to fix it. Or you post your full Matlab output of a run of, e.g., VBLSyncTest here for a quick look.

With the kernel driver, PTB will also be able to detect certain bugs in visual onset timing/timestamping that you’d normally only be able to detect with properly setup external measurement equipment, so you might get more warnings or errors with the driver – a good thing, as it will prevent you from screwing up data collection due to broken visual timing without noticing.

Assuming everything works - never a given on Apples awful Catalina OS - the driver would improve visual stimulus onset timestamping precision and thereby help to better visual timing.