Announcement

Collapse
No announcement yet.

How does Kubuntu detects that a game is running and uses the Nvidia GPU ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How does Kubuntu detects that a game is running and uses the Nvidia GPU ?

    My system info are at the bottom

    I installed some games on my machine from Ubuntu repositories using Discover:
    https://play0ad.com/
    https://wz2100.net/

    both those games are from Ubuntu repos, not flathub or snap or else.

    When i run those games, they are somehow detected that they are games and are using the Nvidia GPU. I knew that they are using the Nvidia cuz i launched nvtop and monitored the spike in the processing and memory usage with Nvidia.


    Now some other game (Airshipper) i installed as a standalone binary
    https://veloren.net/download/
    and it is somehow also using the Nvidia GPU when running the game (Veloren)


    However some other game https://www.thedarkmod.com/main/ does not want to automatically use Nvidia when i run it. First I had to create a desktop entry for the binary and define the working directory and this is just to easily run the game:

    Click image for larger version

Name:	Screenshot_20231023_154011.png
Views:	173
Size:	65.7 KB
ID:	674663
    Click image for larger version

Name:	Screenshot_20231023_154054.png
Views:	154
Size:	49.5 KB
ID:	674664

    Next I had to use the following line as an environment variable to use the Nvidia GPU:

    Code:
    __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia


    Now i have 2 questions

    1. What mechanism does Kubuntu use to detect that i am running a game and start using the Nvidia ? How does Kubuntu knows ?

    2. is there a way to let Kubuntu automatically run games using Nvidia without having to add those env variables mentioned above ?


    My system info:
    Code:
    System:
      Kernel: 6.5.0-9-generic arch: x86_64 bits: 64 compiler: N/A clocksource: tsc
        available: acpi_pm parameters: BOOT_IMAGE=/vmlinuz-6.5.0-9-generic
        root=/dev/mapper/vgkubuntu-root ro quiet splash vt.handoff=7
      Desktop: KDE Plasma v: 5.27.8 tk: Qt v: 5.15.10 wm: kwin_x11 vt: 2
        dm: SDDM Distro: Ubuntu 23.10 (Mantic Minotaur)
    Machine:
      Type: Laptop System: ASUSTeK product: ROG Strix G614JU_G614JU v: 1.0
        serial: <superuser required>
      Mobo: ASUSTeK model: G614JU v: 1.0 serial: <superuser required>
        UEFI: American Megatrends LLC. v: G614JU.318 date: 07/28/2023
    Battery:
      ID-1: BAT0 charge: 85.4 Wh (100.0%) condition: 85.4/90.0 Wh (94.9%)
        volts: 17.4 min: 16.0 model: AS3GYFG3KC R220358 type: Unknown
        serial: <filter> status: full
    CPU:
      Info: model: 13th Gen Intel Core i9-13980HX bits: 64 type: MST AMCP
        arch: Raptor Lake gen: core 13 level: v3 note: check built: 2022+
        process: Intel 7 (10nm) family: 6 model-id: 0xB7 (183) stepping: 1
        microcode: 0x119
      Topology: cpus: 1x cores: 24 mt: 8 tpc: 2 st: 16 threads: 32 smt: enabled
        cache: L1: 2.1 MiB desc: d-16x32 KiB, 8x48 KiB; i-8x32 KiB, 16x64 KiB
        L2: 32 MiB desc: 8x2 MiB, 4x4 MiB L3: 36 MiB desc: 1x36 MiB
      Speed (MHz): avg: 938 high: 1823 min/max: 800/5400:5600:4000 scaling:
        driver: intel_pstate governor: powersave cores: 1: 1600 2: 800 3: 800 4: 800
        5: 1414 6: 800 7: 800 8: 1823 9: 929 10: 800 11: 1425 12: 800 13: 800
        14: 1499 15: 901 16: 800 17: 800 18: 1232 19: 800 20: 800 21: 800 22: 800
        23: 800 24: 800 25: 800 26: 800 27: 800 28: 800 29: 800 30: 800 31: 800
        32: 800 bogomips: 154828
      Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
      Vulnerabilities:
      Type: gather_data_sampling status: Not affected
      Type: itlb_multihit status: Not affected
      Type: l1tf status: Not affected
      Type: mds status: Not affected
      Type: meltdown status: Not affected
      Type: mmio_stale_data status: Not affected
      Type: retbleed status: Not affected
      Type: spec_rstack_overflow status: Not affected
      Type: spec_store_bypass mitigation: Speculative Store Bypass disabled via
        prctl
      Type: spectre_v1 mitigation: usercopy/swapgs barriers and __user pointer
        sanitization
      Type: spectre_v2 mitigation: Enhanced / Automatic IBRS, IBPB:
        conditional, RSB filling, PBRSB-eIBRS: SW sequence
      Type: srbds status: Not affected
      Type: tsx_async_abort status: Not affected
    Graphics:
      Device-1: Intel Raptor Lake-S UHD Graphics vendor: ASUSTeK driver: i915
        v: kernel arch: Gen-13 process: Intel 7 (10nm) built: 2022+ ports:
        active: eDP-1 empty: DP-1, DP-2, HDMI-A-1, HDMI-A-2 bus-ID: 0000:00:02.0
        chip-ID: 8086:a788 class-ID: 0300
      Device-2: NVIDIA AD107M [GeForce RTX 4050 Max-Q / Mobile]
        vendor: ASUSTeK GN21-X2 driver: nvidia v: 535.113.01
        alternate: nvidiafb,nouveau,nvidia_drm non-free: 535.xx+
        status: current (as of 2023-08) arch: Lovelace code: AD1xx
        process: TSMC n4 (5nm) built: 2022-23+ ports: active: none
        empty: DP-3,HDMI-A-3,eDP-2 bus-ID: 0000:01:00.0 chip-ID: 10de:28e1
        class-ID: 0300
      Device-3: Sonix USB2.0 HD UVC WebCam driver: uvcvideo type: USB rev: 2.0
        speed: 480 Mb/s lanes: 1 mode: 2.0 bus-ID: 1-8:4 chip-ID: 322e:2122
        class-ID: 0e02
      Display: x11 server: X.Org v: 1.21.1.7 with: Xwayland v: 23.2.0
        compositor: kwin_x11 driver: X: loaded: modesetting,nvidia
        unloaded: fbdev,nouveau,vesa dri: iris gpu: i915 display-ID: :0 screens: 1
      Screen-1: 0 s-res: 1680x1050 s-dpi: 98 s-size: 436x273mm (17.17x10.75")
        s-diag: 514mm (20.25")
      Monitor-1: eDP-1 model: TL160ADMP03-0 built: 2022 res: 1680x1050 hz: 60
        dpi: 124 gamma: 1.2 size: 345x215mm (13.58x8.46") diag: 407mm (16")
        ratio: 16:10 modes: 2560x1600
      API: OpenGL v: 4.6 Mesa 23.2.1-1ubuntu3 renderer: Mesa Intel Graphics
        (RPL-S) direct-render: Yes
    Audio:
      Device-1: Intel vendor: ASUSTeK driver: snd_hda_intel v: kernel
        alternate: snd_sof_pci_intel_tgl bus-ID: 0000:00:1f.3 chip-ID: 8086:7a50
        class-ID: 0403
      Device-2: NVIDIA vendor: ASUSTeK driver: snd_hda_intel v: kernel
        bus-ID: 0000:01:00.1 chip-ID: 10de:22be class-ID: 0403
      API: ALSA v: k6.5.0-9-generic status: kernel-api
        tools: alsactl,alsamixer,amixer
      Server-1: PipeWire v: 0.3.79 status: active with: 1: pipewire-pulse
        status: active 2: wireplumber status: active tools: pw-cat,pw-cli,wpctl
    Network:
      Device-1: Intel driver: iwlwifi v: kernel port: N/A bus-ID: 0000:00:14.3
        chip-ID: 8086:7a70 class-ID: 0280
      IF: wlo1 state: up mac: <filter>
      Device-2: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet
        vendor: ASUSTeK driver: r8169 v: kernel port: 4000 bus-ID: 0000:6c:00.0
        chip-ID: 10ec:8168 class-ID: 0200
      IF: enp108s0 state: down mac: <filter>
    Bluetooth:
      Device-1: Intel driver: btusb v: 0.8 type: USB rev: 2.0 speed: 12 Mb/s
        lanes: 1 mode: 1.1 bus-ID: 1-14:5 chip-ID: 8087:0033 class-ID: e001
      Report: hciconfig ID: hci0 rfk-id: 0 state: down
        bt-service: enabled,running rfk-block: hardware: no software: yes
        address: <filter>
      Info: acl-mtu: 1021:4 sco-mtu: 96:6 link-policy: rswitch sniff
        link-mode: peripheral accept
    RAID:
      Hardware-1: Intel Volume Management Device NVMe RAID Controller Intel
        driver: vmd v: 0.6 port: N/A bus-ID: 0000:00:0e.0 chip-ID: 8086:a77f rev:
        class-ID: 0104
    Drives:
      Local Storage: total: 953.87 GiB used: 256.5 GiB (26.9%)
      SMART Message: Unable to run smartctl. Root privileges required.
      ID-1: /dev/nvme0n1 maj-min: 259:0 vendor: Micron model: 2400 MTFDKBA1T0QFM
        size: 953.87 GiB block-size: physical: 512 B logical: 512 B speed: 63.2 Gb/s
        lanes: 4 tech: SSD serial: <filter> fw-rev: V3MA003 temp: 33.9 C
        scheme: GPT
    Partition:
      ID-1: / raw-size: 929.41 GiB size: 913.75 GiB (98.31%)
        used: 256.37 GiB (28.1%) fs: ext4 dev: /dev/dm-1 maj-min: 252:1
        mapped: vgkubuntu-root
      ID-2: /boot raw-size: 1.67 GiB size: 1.61 GiB (96.26%)
        used: 129.6 MiB (7.9%) fs: ext4 dev: /dev/nvme0n1p2 maj-min: 259:2
      ID-3: /boot/efi raw-size: 512 MiB size: 511 MiB (99.80%)
        used: 6.1 MiB (1.2%) fs: vfat dev: /dev/nvme0n1p1 maj-min: 259:1
    Swap:
      Kernel: swappiness: 60 (default) cache-pressure: 100 (default) zswap: no
      ID-1: swap-1 type: partition size: 1.91 GiB used: 0 KiB (0.0%)
        priority: -2 dev: /dev/dm-2 maj-min: 252:2 mapped: vgkubuntu-swap_1
    Sensors:
      System Temperatures: cpu: 32.0 C mobo: N/A
      Fan Speeds (rpm): cpu: 2500
    Info:
      Processes: 497 Uptime: 52m wakeups: 2 Memory: total: 24 GiB note: est.
      available: 23.08 GiB used: 4.42 GiB (19.1%) Init: systemd v: 253
      target: graphical (5) default: graphical tool: systemctl Compilers:
      gcc: 13.2.0 alt: 12/13 Packages: 2326 pm: dpkg pkgs: 2311 libs: 1368
      tools: apt,apt-get,aptitude pm: flatpak pkgs: 8 pm: snap pkgs: 7 Shell: Bash
      v: 5.2.15 running-in: konsole inxi: 3.3.29
Working...
X