Run a program on your dedicated AMD graphics card on Linux
I've recently figured out how to run a program on my dedicated AMD R7 M445 graphics card in Ubuntu 17.04, and since it's taken me far too long to around figuring it out, I thought I'd note it down here for future reference - if it helps you too, let me know in the comments below!
It's actually really simple. First, check that your dedicated AMD graphics card shows up with
If it's anything like my setup, you'll get a pair of rows like this (though they might not be next to each other):
00:02.0 VGA compatible controller: Intel Corporation HD Graphics 620 (rev 02) 01:00.0 Display controller: Advanced Micro Devices, Inc. [AMD/ATI] Topaz XT [Radeon R7 M260/M265 / M340/M360 / M440/M445] (rev c3)
Thankfully, my dedicated AMD card is showing (better than it did in previous versions of ubuntu, too, which thought it was an M225!). Next, we need to check that the
amdgpu kernel module is loaded with a quick
lsmod | grep -i amd
On my laptop, I get this:
amdkfd 139264 1 amd_iommu_v2 20480 1 amdkfd amdgpu 1564672 1 i2c_algo_bit 16384 2 amdgpu,i915 ttm 98304 1 amdgpu drm_kms_helper 151552 2 amdgpu,i915 drm 352256 9 amdgpu,i915,ttm,drm_kms_helper
Yay! It's loaded. Now to do a test to see if we can run anything on it:
glxinfo | grep "OpenGL renderer" DRI_PRIME=1 glxinfo | grep "OpenGL renderer"
The above runs
glxinfo twice: Once on the integrated graphics card, and once on the dedicated graphics card. The key here is the
DRI_PRIME=1 environment variable - this tells the amdgpu driver that this process should run on the dedicated graphics and not the integrated graphics card. On my machine, I get this output:
OpenGL renderer string: Mesa DRI Intel(R) HD Graphics 620 (Kabylake GT2) OpenGL renderer string: Gallium 0.4 on AMD ICELAND (DRM 3.9.0 / 4.10.0-33-generic, LLVM 4.0.0)
As you can see, the latter invocation of the command ran on the dedicated AMD graphics card, and the former on the integrated graphics. So simple!
Now that we've verified that it works, we can do it with any program:
Did this you find this helpful? Did it work (or not)? Let me know in the comments!