What user is your script running as? You will need that user to be logged in to the GUI when the script runs, and this will bind that GUI to the GPU use.
If the user is not “ubuntu” or “nvidia”, then you’ll need to be sure your user is a member of group “video” (see “grep video /etc/group”…root is already a member even when not listed).
Once the same user is logged in to the local GUI of the Jetson the script can be preceeded by the “DISPLAY=:0” and this will bind to the correct GPU.
FYI, one of the big problems of using a script which is part of boot is that most of the time the GUI won’t be up yet, and if it is, it won’t have the right user logged in yet. If the user is “root”, then you probably need to prefix the script command with "sudo -u <whoever_it_is_that_isnt_root> " to get it to run as that user.
If you don’t want to log in a user to a real GUI, then you need to install a virtual desktop (the command won’t care if you are bound to the framebuffer of a GPU connected to a real monitor or simply to a buffer with no real monitor).
The fact that you are running the script with “sudo” implies it must be root who logs in to the GUI…which is usually a problem since default sets root to not be available for GUI logins.
A way to be certain DISPLAY is set is to use it as a prefix on your command line. If my script is “whatever.sh”, then this would do the job:
I strongly suggest that you debug by running as user “ubuntu” or “nvidia” under a logged in local GUI. Running the script with sudo while logged in to a local GUI might give root permission to display there without the DISPLAY environment variable (I am thinking that a local console, from in the GUI, will pass through any GPU use to DISPLAY automatically and open security to not disallow it).
Note that rc.local cannot succeed for any application requiring the GUI. Don’t think of GUI as a graphical desktop, think of it as a buffer with an API for the GPU and security.
Does the script have to run sudo root? Does the script work from a local GUI command line start?