How do I force a program to use GPU when I run it?

System:    Kernel: 5.10.79-1-MANJARO x86_64 bits: 64 compiler: gcc v: 11.1.0 Desktop: GNOME 41.1
           Distro: Manjaro Linux base: Arch Linux
Machine:   Type: Laptop System: LENOVO product: 82B5 v: Lenovo Legion 5 15ARH05
           serial: <superuser required>
           Mobo: LENOVO model: LNVNB161216 v: SDK0J40688 WIN serial: <superuser required>
           UEFI-[Legacy]: LENOVO v: EUCN19WW date: 05/12/2020
Battery:   ID-1: BAT0 charge: 50.5 Wh (100.0%) condition: 50.5/60.0 Wh (84.2%) volts: 17.2
           min: 15.4 model: Celxpert L19C4PC0 status: Full
CPU:       Info: 8-Core model: AMD Ryzen 7 4800H with Radeon Graphics bits: 64 type: MT MCP
           arch: Zen 2 rev: 1 cache: L2: 4 MiB
           flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm
           bogomips: 92660
           Speed: 3502 MHz min/max: 1400/2900 MHz boost: enabled Core speeds (MHz): 1: 3502
           2: 4054 3: 1788 4: 1903 5: 1759 6: 1702 7: 3204 8: 2988 9: 4279 10: 4273 11: 1905
           12: 1903 13: 1906 14: 1898 15: 1683 16: 1907
Graphics:  Device-1: NVIDIA TU117M [GeForce GTX 1650 Ti Mobile] vendor: Lenovo driver: nvidia
           v: 470.86 bus-ID: 01:00.0
           Device-2: AMD Renoir vendor: Lenovo driver: amdgpu v: kernel bus-ID: 05:00.0
           Device-3: Chicony Integrated Camera type: USB driver: uvcvideo bus-ID: 1-3:2
           Display: x11 server: X.org 1.21.1.1 driver: loaded: amdgpu,nvidia
           resolution: <missing: xdpyinfo>
           OpenGL: renderer: AMD RENOIR (DRM 3.40.0 5.10.79-1-MANJARO LLVM 13.0.0)
           v: 4.6 Mesa 21.2.5 direct render: Yes
Audio:     Device-1: NVIDIA driver: snd_hda_intel v: kernel bus-ID: 01:00.1
           Device-2: AMD Raven/Raven2/FireFlight/Renoir Audio Processor vendor: Lenovo driver: N/A
           bus-ID: 05:00.5
           Device-3: AMD Family 17h HD Audio vendor: Lenovo driver: snd_hda_intel v: kernel
           bus-ID: 05:00.6
           Sound Server-1: ALSA v: k5.10.79-1-MANJARO running: yes
           Sound Server-2: JACK v: 1.9.19 running: no
           Sound Server-3: PulseAudio v: 15.0 running: yes
           Sound Server-4: PipeWire v: 0.3.40 running: no
Network:   Device-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet vendor: Lenovo
           driver: r8169 v: kernel port: 2000 bus-ID: 03:00.0
           IF: eno1 state: up speed: 1000 Mbps duplex: full mac: <filter>
           Device-2: Intel Wi-Fi 6 AX200 driver: iwlwifi v: kernel bus-ID: 04:00.0
           IF: wlp4s0 state: down mac: <filter>
Bluetooth: Device-1: Intel AX200 Bluetooth type: USB driver: btusb v: 0.8 bus-ID: 3-3:3
           Report: rfkill ID: hci0 rfk-id: 3 state: up address: see --recommends
Drives:    Local Storage: total: 476.94 GiB used: 272.67 GiB (57.2%)
           ID-1: /dev/nvme0n1 vendor: Samsung model: MZVLB512HBJQ-000L2 size: 476.94 GiB
           temp: 37.9 C
Partition: ID-1: / size: 459.79 GiB used: 272.67 GiB (59.3%) fs: ext4 dev: /dev/nvme0n1p1
Swap:      ID-1: swap-1 type: partition size: 8.8 GiB used: 4.8 MiB (0.1%) dev: /dev/nvme0n1p2
Sensors:   System Temperatures: cpu: 53.6 C mobo: N/A gpu: amdgpu temp: 39.0 C
           Fan Speeds (RPM): N/A
Info:      Processes: 377 Uptime: 5h 12m Memory: 15.07 GiB used: 4.36 GiB (28.9%) Init: systemd
           Compilers: gcc: 11.1.0 Packages: 1489 Client: gnome-shell v: 41.1 inxi: 3.3.09

I just installed Google Earth Pro using yay, but I realized that when I start it up it doesn’t use the GPU. I know that I can open up a terminal and use prime-run google-earth-pro to start the app with the GPU. How can I make it so that the app runs with the GPU when I click on the icon?

Hi @wildcard,

To do that, I believe you’d need to Right-click on the shortcut, and select Edit Application…. Then browse to the Application tab and insert prime-run in the front of the Command field.

Note: These instructions are based on KDE, so will not be the same for Gnome. However, the general gist would be the same.


Unfortunately, in Gnome there is no Edit Application when I right-click the shortcut.

By the way, how do you do write that in the little box thing?

What little box thing?

Edit:

Please see https://www.addictivetips.com/ubuntu-linux-tips/edit-program-shortcuts-in-gnome-shell/. Personally I’d go with the terminal option.

Edit 2:

Oh these:

Just wrap your text in <kbd></kbd> tags. Like this:

<kbd>Text</kbd>

so that it’s displayed like this:

Text

:wink:

In your reply the words “Edit Application…” are in a little box. How do you format that?

Thanks for the link. I did try to edit the .desktop file but I’m not sure how to edit the exec line. I’ve tried adding in prime-run but nothing seems to work.

Have you restarted? Either the session or your computer? Because, I might be wrong, but I almost think that’d be neccessary to rebuild the cache…otherwise, provide us with the contents of the .desktop file, wrapped in three backticks (```) before and after the text, for proper render formatting.

Hmm, no I haven’t tried restarting. Maybe that’s it. But I’m still not sure how to format the exec line properly.

[Desktop Entry]
Version=1.0
Name=Google Earth
GenericName=3D planet viewer
Comment=Explore, search and discover the planet
Exec=/opt/google/earth/pro/google-earth-pro %f
Terminal=false
MultipleArgs=false
Icon=google-earth-pro
Type=Application
Categories=Application;Network
MimeType=application/vnd.google-earth.kml+xml;application/vnd.google-earth.kmz;application/earthviewer;application/keyhole

In all theory you should just be able to change this line :point_down:

to

Exec=prime-run google-earth-pro

Or, well, that’s how I understand it, anyway.

I tried that, but I did not restart. I’ll try it again with restart this time.

Edit: I just tried it again, with a reboot this time, and still nothing.

If it still doesn’t work, then there could be another .desktop somewhere, probable in you home directory. You could check with:

find ~ -name '*google*.desktop'

Or well, that’s my thoughts anyway.

Edit:

If it’s not this, well, then I have no idea what else it could be. Sorry.

1 Like

That did it! It was in /.local/share/applications/ the whole time. I completely forgot about that. Changed the exec line and reboot and it works now! Thanks a lot!

1 Like

I would like to mention another option:

If you install switcheroo-control from the AUR and start the service (systemctl start switcheroo-control), then GNOME shell will show an option to select a different GPU when right clicking the icon in the dock or in the application grid.

1 Like

Awesome! Thanks!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.