Unable to display image on external monitor AMD laptop

Authentication token: ANY4B-UP-2024827113311:2b28a796aa78935b57eba267c343dc7e405314cf628162f42acbd1aed89a1752

Hi PTB community and team, I am trying to set up psychtoolbox to display visual stimuli to mice for electrophysiology experiments and would like to set up a system with the least possible jitter between stimulus onset and an I/O signal to my acquisition system.

I have this laptop: https://www.bestbuy.com/site/asus-tuf-gaming-a16-16-165hz-gaming-laptop-fhd-amd-ryzen-7-7735hs-with-16gb-ddr5-memory-radeon-rx7700s-512gb-pcie-ssd-off-black/6560989.p?skuId=6560989
with AMD Ryzen 7 7735HS with Radeon Graphics and AMD Radeon™ RX 7700S. I have installed Ubuntu 22.04 on it with a low latency kernel (running 6.8.0-40-lowlatency). I have also installed the following AMD drivers: https://www.amd.com/en/support/download/linux-drivers.html, installed Matlab and installed 3.0.19 of Psychtoolbox from NeuroDebian. I have my laptop connected to an external LED monitor.

I am having trouble getting my stimulus to appear only on my external monitor. I have tried using the XOrgConfigCreator function and either it will have the stimulus spread over both screens or disable the external monitor. This happens without any psychtoolbox errors and the VBL settings are all consistent with my inbuilt laptop monitor.

PTB-INFO: This is Psychtoolbox-3 for GNU/Linux X11, under Matlab 64-Bit (Version 3.0.19 - Build date: Jun 22 2024).
PTB-INFO: OS support status: Linux 6.8.0-40-lowlatency Supported.
PTB-INFO: Type ‘PsychtoolboxVersion’ for more detailed version information.
PTB-INFO: Most parts of the Psychtoolbox distribution are licensed to you under terms of the MIT License, with
PTB-INFO: some restrictions. See file ‘License.txt’ in the Psychtoolbox root folder for the exact licensing conditions.
PTB-INFO: For information about paid support, support memberships and other commercial services, please type
PTB-INFO: ‘PsychPaidSupportAndServices’.
PTB-INFO: OpenGL-Renderer is AMD :: AMD Radeon Graphics (radeonsi, rembrandt, LLVM 17.0.6, DRM 3.57, 6.8.0-40-lowlatency) :: 4.6 (Compatibility Profile) Mesa 24.1.0-devel
PTB-INFO: VBL startline = 1200 , VBL Endline = -1
PTB-INFO: Measured monitor refresh interval from VBLsync = 6.068683 ms [164.780407 Hz]. (50 valid samples taken, stddev=0.000543 ms.)
PTB-INFO: Reported monitor refresh interval from operating system = 6.059945 ms [165.018005 Hz].
PTB-INFO: Small deviations between reported values are normal and no reason to worry.

My current config file made by PsychXOrgCreater is # Auto generated xorg.conf - Created by Psychtoolbox XOrgConfCreator below (which disables the external monitor)

Section “ServerFlags”
Option “AutoAddGPU” “false”
EndSection

Section “ServerLayout”
Identifier “PTB-Hydra”
Screen 0 “Screen0” 0 0
Screen 1 “Screen1” RightOf “Screen0”
EndSection

Section “Monitor”
Identifier “eDP-1”
EndSection

Section “Monitor”
Identifier “HDMI-A-1-0”
EndSection

Section “Device”
Identifier “Card0”
Driver “amdgpu”
Option “ZaphodHeads” “eDP-1”
Option “Monitor-eDP-1” “eDP-1”
Screen 0
EndSection

Section “Device”
Identifier “Card1”
Driver “amdgpu”
Option “ZaphodHeads” “HDMI-A-1-0”
Option “Monitor-HDMI-A-1-0” “HDMI-A-1-0”
Screen 1
EndSection

Section “Screen”
Identifier “Screen0”
Device “Card0”
Monitor “eDP-1”
EndSection

Section “Screen”
Identifier “Screen1”
Device “Card1”
Monitor “HDMI-A-1-0”
EndSection

I am not sure if I have one of the dual AMD GPUs as talked about in the HybridLaptops help and if changing one of those configuration files would help? I am also not sure if I need to download this driver in order to help toggle the GPU settings for this. Linux for ROG Notebooks

I do get this error: Gtk-Message: 11:26:31.154: Failed to load module “canberra-gtk-module” when I load ptb3-matlab (even after manually installing the package), but thought that this package was needed for sounds rather than visual stimulation.

Any advice on how to troubleshoot this would be greatly appreciated! Thank you!

It took a while to google this, but is seems this is a dual gpu laptop with an AMD Rembrandt iGPU and a AMD Navi 33 dGPU, iow. one of the systems where XOrgConfCreator will usually not work, as it can only deal with one gpu setups if one wants to use multiple X-Screens, which is why we explicitely don’t recommend dual-gpu laptops if avoidable - the setup is not as easy peasy.

My suspicion is that the laptop panel is connected to the iGPU by default, but your HDMI video output is connected to the higher performance dGPU.

Try the sample xorg.conf file inside the Psychtoolbox/PsychHardware/LinuxX11ExampleXorgConfs folder, named:

Psychtoolbox/PsychHardware/LinuxX11ExampleXorgConfs/DualAMD2XScreens_xorg.conf

copy it into your ~/.Psychtoolbox/XorgConfs/ folder, so it can be easily selected later on via XOrgConfSelector(). Then edit the copy. Specifically you need to change the BusID parameters, e.g., BusID "PCI:54@0:0:0" to proper values for your two AMD gpu’s, so the config file can uniquely identify which X-Screen should display on which graphics cards video output.

The Card0 section for X-Screen 0 should get the id of the integrated gpu, whereas the Card1 section for external stimulus X-Screen 1 should get the id of the discreate gpu. You can find the proper BusID in the Xorg log file via the following grep command in a terminal window:

grep PCI ~/.local/share/xorg/Xorg.0.log

E.g., an item “PCI:*(0@0:2:0) 1002:1681” would translate to a BusId parameter in the config file of
BusID "PCI:0@0:2:0"

Likely the iGPU for Card0 / X-Screen 0 will have the id 1002:1681, wheres the dGPU connected to your external monitor for Card1 / X-Screen1 will not have an * asterisk and an id of 1002:7480.

With a properly modified config file, you can then use XOrgConfSelector + logout + login to switch between dual-X-Screen config for visual stimulation with optimal performance and timing, or standard single-X-Screen config for simple general use.

There are likely other options that would get this laptop going, but they would either reduce performance, or increase general power consumption, or might be less flexible. E.g., according to docs, the USB-C ports on that laptop may support DisplayPort Alt Mode from the integrated iGPU, so one can connect a DisplayPort or HDMI external monitor with a USB-C to DP/HDMI adapter and then only use the integrated iGPU for internal and external display and rendering, which would work with XOrgConfCreator. Or the same, but use PRIME renderoffload as described in “help HybridGraphics”, to use the iGPU for all the displays, but the powerful dGPU for stimulus rendering - for maybe about 80% of the performance of the dual-gpu setup I described above with the custom manually mode xorg configuration file, but with dynamic power management that allows to power down the dGPU when not used by Psychtoolbox. Or you could use the gpu settings tool from “Linux for ROG Notebooks” - or possibly some laptop firmware settings - to turn your laptop into a bog standard single-gpu laptop that permanently only exposes and uses one gpu, either iGPU or dGPU for all operations.

Btw. I think it likely wasn’t necessary to install AMD drivers from the link you posted on an up to date Ubuntu 22.04.4-LTS. Your graphics card(s) should have worked fine with the Ubuntu default drivers as far as I can see, and I do not recommend installing such 3rd party drivers without good reason. That said, in this case they should probably not cause immediate problems either, just possibly make future distribution upgrades more cumbersome if using non-default drivers.

[75 minutes used out of 30 minutes paid. Paid support exhausted.]

Thank you so much for your help!

Since we wanted to use the same visual stim set up on multiple rigs, we strongly preferred using a laptop if possible and I tried my best to get a laptop that had an AMD processor and a good AMD GPU that was known to run linux and did not have hybrid graphics but this was the best that I could find. I then suspected the hybrid graphics while going through the set up and really appreciate your help getting this going!

The DualAMD2XScreens_xorg.conf file seems to be working!

My output from grep PCI ~/.local/share/xorg/Xorg.0.log
[1722032.950] (–) PCI: (3@0:0:0) 1002:7480:1043:1513 rev 193, Mem @ 0x7c00000000/8589934592, 0x7e00000000/268435456, 0xdc800000/1048576, I/O @ 0x0000f000/256, BIOS @ 0x???/131072
[1722032.950] (–) PCI:*(119@0:0:0) 1002:1681:1043:1513 rev 10, Mem @ 0x7e50000000/268435456, 0x7e60000000/2097152, 0xdc700000/524288, I/O @ 0x0000c000/256

And I edited the DualAMD2XScreen_xorg.conf to have:

Custom xorg.conf file for a dual AMD gpu system, a

Dell Alienware M17r5 with AMD (SmartAccessGraphics).

This is a laptop with two AMD gpu’s: A Rembrandt /

Yellow Carp iGPU muxed by default to the internal eDP

laptop panel, and a Navi22/ Navy Flounder Radeon RX

6700M dGPU which can be muxed to the eDP panel, but

by default just drives the external HDMI and USB-C/DP

outputs.

This config will assign the iGPU with the internal

laptop eDP panel to X-Screen 0 for the desktop GUI,

and the AMD dGPU is used to drive the visual stimulation

display on X-Screen 1 via the external video output(s).

Section “ServerLayout”
Identifier “Hydra-2XScreensOn2GPUs”
Screen 0 “Screen0” 0 0
Screen 1 “Screen1” RightOf “Screen0”
EndSection

Section “Device”
Identifier “Card0”
Driver “amdgpu”
BusID “PCI:119@0:0:0”
EndSection

Section “Device”
Identifier “Card1”
Driver “amdgpu”
BusID “PCI:3@0:0:0”
EndSection

Section “Screen”
Identifier “Screen0”
Device “Card0”
EndSection

Section “Screen”
Identifier “Screen1”
Device “Card1”
EndSection

I just wanted to confirm that this set up should work since I did have to put the BUS ID with the * on card 0 and the BUS ID without the * on card 1. I also wanted to see if there was a way of going back to the native AMD drivers now that I have added the ones I found online?

The reason why I ask is that every so often I am getting the following error:

PTB-ERROR: OpenML timestamping reports that flip completed before its requested target time [Target no earlier than 1726596024.598897 secs, completed at 1726596024.597733 secs]!
PTB-ERROR: Something is wrong with swap scheduling, a misconfiguration or potential graphics driver bug! Check your system setup!
PTB-ERROR: Switching to alternative fallback scheduling method.

Thanks again so much for your help! I really appreciate it!

Good. The config file you created should be correct and things seem to work.

Wrt. uninstalling the 3rd party AMD drivers, there should be an amdgpu-uninstall script on your machine that you can run + reboot to go back to the default Ubuntu drivers, but this is unlikely to be the culprit for the timestamping error you get occassionally. Those 3rd party AMD drivers are just more up to date / recent versions of the open-source drivers that Ubuntu ships with by default. Functionally they are not worse.

More likely is a slight problem with your computers clock, e.g., caused by using Network time protocol NTP for automatic time and date setting and sync across machines, in combination with local network issues: See this thread for discussion and tips for resolution: Inconsistent Clock Behavior on Laptop

Or, less likely, you specify a tWhen target stimulus onset time in Screen('Flip', ..., tWhen,...); that is so far into the future that substantial clock error accumulates. E.g., for flips that are dozens of seconds or minutes into the future.

-mario

Thanks so much for your help and pointing me to this article!

I have kept the 3rd party drivers as you noted that they are unlikely to be worse.

I did add PsychTweak(‘GetSecsClock’, 1); to the beginning of my script and now I am getting the following warning that the flip command seems to be missing:

INFO: PTB’s Screen(‘Flip’, 10) command seems to have missed the requested stimulus presentation deadline
INFO: a total of 19 times out of a total of 209 flips during this session.

INFO: This number is fairly accurate (and indicative of real timing problems in your own code or your system)
INFO: if you provided requested stimulus onset times with the ‘when’ argument of Screen(‘Flip’, window [, when]);
INFO: If you called Screen(‘Flip’, window); without the ‘when’ argument, this count is more of a ‘‘mild’’ indicator
INFO: of timing behaviour than a hard reliable measurement. Large numbers may indicate problems and should at least
INFO: deserve your closer attention. Cfe. ‘help SyncTrouble’, the FAQ section at www.psychtoolbox.org and the
INFO: examples in the PDF presentation in PsychDocumentation/Psychtoolbox3-Slides.pdf for more info and timing tips.

INFO: This number is fairly accurate (and indicative of real timing problems in your own code or your system)
INFO: if you provided requested stimulus onset times with the ‘when’ argument of Screen(‘Flip’, window [, when]);
INFO: If you called Screen(‘Flip’, window); without the ‘when’ argument, this count is more of a ‘‘mild’’ indicator
INFO: of timing behaviour than a hard reliable measurement. Large numbers may indicate problems and should at least
INFO: deserve your closer attention. Cfe. ‘help SyncTrouble’, the FAQ section at www.psychtoolbox.org and the
INFO: examples in the PDF presentation in PsychDocumentation/Psychtoolbox3-Slides.pdf for more info and timing tips.

However, when I comment out the PsychTweak function after closing and opening a new PTB - matlab session (I presume now using the default real clock), I do not get the same error when I close the screen after running 100 test trials. And the flip time before current time does not seem to come consistently.

I do always input a tWhen in my screen flip command and the duration is short - usually less than 1s.

I did try to look into my clock sync status:
visstim@VisStim01:~$ timedatectl timesync-status
Server: 185.125.190.57 (ntp.ubuntu.com)
Poll interval: 34min 8s (min: 32s; max 34min 8s)
Leap: normal
Version: 4
Stratum: 2
Reference: B7A08584
Precision: 1us (-25)
Root distance: 800us (max: 5s)
Offset: +431us
Delay: 235.180ms
Jitter: 134.048ms
Packet count: 119
Frequency: -14.143ppm

I am not sure if one of the other clocks would work better?

Thanks for your help, I really appreciate it!

Good. Suggests there was/is some NTP time-sync issue, which should be reduced or resolved by using the monotonic clock.

Yes, after a Matlab restart you use the default realtime “wall clock” again, which allows time sync across machines, but would be susceptible to NTP time sync issues. You should never see those warnings/errors if the clock works correctly, and the PsychTweak seems to have fixed that. If anything, it should make timing even more accurate.

Probably not. The reported missed flips by themselves would be on the high side for a Linux system, assuming they are all within on trial and you do timing in the way our docs and demos recommend it.

Could be suboptimal coding on your side. Or it could be that you do timing optimally within a trial, but don’t take care of consistent timing when transitioning from one trial to another, so you get up to about one apparent timing glitch at the start or end of each trial, because the first or last Flip of a trial is not properly aligned to the refresh timing of your display. I recommend checking the timestamps returned by ‘Flip’ itself to make sure they indicate correct/consistent timing inside a trial where it matters. Cfe. VBLSyncTest for strategies. Or run PerceptualVBLSyncTest, VBLSyncTest with different inter-frame-interval parameters or FlipTimingWithRtBoxPhotoDiodeTest to give the machine a good workout to see if there’s a problem on the machine side, on your coding side, or the missed flips are just false positives. E.g., if you had ~19 trials, such 19 false positive misses could be expected unless you coded very carefully.

-mario