Force to use AMD GPU on a laptop

Hi? I’m trying to force to use AMD GPU on my laptop and can’t do this.
In my system I have 2 cards:

01:00.0 Display controller: Advanced Micro Devices, Inc. [AMD/ATI] Mars [Radeon HD 8670A/8670M/8750M / R7 M370]
00:02.0 VGA compatible controller: Intel Corporation 4th Gen Core Processor Integrated Graphics Controller (rev 06) (prog-if 00 [VGA controller])

I already tried to block kernel module i915, but it dosen’t work - Gnome just won’t boot up:
boot.blacklistedKernelModules = [“i915”];

In my hardware-configuration.nix I add two rows:
boot.initrd.kernelModules = [ “amdgpu” ];
boot.kernelParams = [ “radeon.cik_support=0” “amdgpu.cik_support=1” ];

Can someone please help me?

1 Like

I think in your case you can just switch between the two using PRIME. When set up correctly, all you have to do to open apps using the AMD GPU is prefix the command with the DRI_PRIME=1 env variable.

Also, Welcome to NixOS :wave:

1 Like

Hey have you figured it out how to do it mine is also similar to you please provide the steps of you find it I’m pretty much noob in this kind of things

Since my laptop uses two Intel and AMD graphics cards, I need to use PRIME, but first I need to specify in the NixOS configuration files to use the amdgpu driver.

In configuration.nix, you must specify the driver for applications that use the X server:

services.xserver.videoDrivers = [ "amdgpu" ];

In the hardware-configuration.nix file, specify the use of the amdgpu module:

boot.initrd.kernelModules = [ "amdgpu" ];

Now we need to find out the ID of the video card. In the terminal, enter the command, remembering to install the lshw package beforehand:

sudo lshw -c display

We get the following response

       physical id: 0
       bus info: pci@0000:01:00.0
       version: 00
       width: 64 bits
       clock: 33MHz
       capabilities: pm pc pciexpress msi bus_master cap_list rom
       configuration: driver=radeon latency=0
       resources: irq:31 memory:b0000000-b7ffffffff memory:b8000000-b803ffffff ioport:4000(size=256) memory:b8040000-b805ffffff
       product: i915drmfb
       physical id: 2
       bus info: pci@0000:00:02.0
       logical name: /dev/fb0
       version: 06
       width: 64 bits
       clock: 33MHz
       capabilities: msi pm bus_master cap_list rom fb
       configuration: depth=32 driver=i915 latency=0 resolution=1366,768
       resources: irq:33 memory:b9000000-b93fffff memory:a0000000-afffffff ioport:5000(size=64) memory:c0000-dfff

Here we are interested in the bus info: pci@0000:01:00.0 line. We must set this value to the DRI_PRIME variable before launching the program.

To make sure that we have done everything correctly, we can just run glxinfo:

DRI_PRIME=pci-0000_01_00_00_0 glxinfo | grep 'OpenGL renderer'

If everything worked, then run the other programs by analogy. I installed PortProton via Flatpack and used Flatseal to pass a variable value to it.

1 Like

Hey thanks I followed your steps and everything is setup now but if I want to launch a game from steam what should I do like I don’t know the game executable file so how should I use DRI_PRIME=1 to launch it

I think you should add a variable DRI_PRIME=pci-0000_01_00_00_0 before launching game. It might been doing in game setting in Steam. Something like this:

To add the variable DRI_PRIME=pci-0000_01_00_00_0 when launching a game from Steam, you need to edit the game’s launch options. Here’s how you can do it:

  1. Open the Steam client and find the game you want to launch with the DRI_PRIME=pci-0000_01_00_00_0 variable.

  2. Right-click on the game in your Steam library and select “Properties”.

  3. In the Properties window, go to the “General” tab and find the “Set Launch Options” button.

  4. In the launch options window that appears, enter the following command:
    DRI_PRIME=pci-0000_01_00_00_0 %command%

  5. Click “OK” to save the changes.

Now, when you launch the selected game from Steam, it will use the DRI_PRIME=pci-0000_01_00_00_0 variable.

1 Like

Really thanks for your help in guiding me I did this

DRI_PRIME=pci-0000_01_00_00_0 mangohud %command%

but in mangohud it is showing cpu and openGL info does it only show this much information or it should also show something about the GPU.

I’m really sorry if it’s too silly question everything thing is still very new for me

1 Like

Sorry, can’t help with mangohud and other. I just don’t try it

It’s okay thanks anyway really it was really helpful

You can customize mangohud with goverlay