[HOWTO] Install amdgpu-pro on LMD 4

Write tutorials for LMDE here
More tutorials on https://github.com/orgs/linuxmint/discu ... /tutorials and (archive) on https://community.linuxmint.com/tutorial
Forum rules
Don't add support questions to tutorials; start your own topic in the appropriate sub-forum instead. Before you post please read forum rules
Post Reply
mrproper

[HOWTO] Install amdgpu-pro on LMD 4

Post by mrproper »

UPDATE: Warning the driver from AMD fail to compile with the latest kernels (any posterior to 4.19.0-11)

Small guide to install the driver for AMD Radeons from the AMd's web.
  • The drivers works for Debian Buster without modification since the version 19.30 https://wiki.debian.org/AMDGPUDriverOnStretchAndBuster2
    but in LMD 4 installing the package witch the kernel module fails to compile. This is caused by the detection of the OS in the makefile who configure gcc like an Ubuntu OS instead Debian OS

    Code: Select all

    ifeq ("linuxmint",$(OS_NAME))
    OS_NAME="ubuntu"
    To bypass this problem I modified temporally /etc/os-release changing the ID=linuxmint by ID=debian

    Code: Select all

    PRETTY_NAME="LMDE 4 (debbie)"
    NAME="LMDE"
    VERSION_ID="4"
    VERSION="4 (debbie)"
    ID=debian
    ID_LIKE=debian
    HOME_URL="https://www.linuxmint.com/"
    SUPPORT_URL="https://forums.linuxmint.com/"
    BUG_REPORT_URL="http://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/"
    PRIVACY_POLICY_URL="https://www.linuxmint.com/"
    VERSION_CODENAME=debbie
    DEBIAN_CODENAME=buster
  • Restore /etc/os-release

    Code: Select all

    PRETTY_NAME="LMDE 4 (debbie)"
    NAME="LMDE"
    VERSION_ID="4"
    VERSION="4 (debbie)"
    ID=linuxmint
    ID_LIKE=debian
    HOME_URL="https://www.linuxmint.com/"
    SUPPORT_URL="https://forums.linuxmint.com/"
    BUG_REPORT_URL="http://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/"
    PRIVACY_POLICY_URL="https://www.linuxmint.com/"
    VERSION_CODENAME=debbie
    DEBIAN_CODENAME=buster
  • The kernel module is compiled every time a new kernel version is installed, failing to compile with the default makefile. This is why I modified the makefile in /usr/src/amdgpu-5.4.7.53-1048554/Makefile (change the number according you package) bypassing the OS detection by add OS_NAME="debian" in the line 28

    Code: Select all

    define get_rhel_version
    	find -L $(kdir) -name 'version.h' -exec grep $(1) {} + | sort -u | awk -F ' ' '{print $$NF}'
    endef
    RHEL_MAJOR := $(shell $(call get_rhel_version,RHEL_MAJOR))
    RHEL_MINOR := $(shell $(call get_rhel_version,RHEL_MINOR))
    
    ifneq (,$(RHEL_MAJOR))
    OS_NAME = "rhel"
    OS_VERSION = "$(RHEL_MAJOR).$(RHEL_MINOR)"
    else ifneq (,$(wildcard /etc/os-release))
    OS_NAME = "$(shell sed -n 's/^ID=\(.*\)/\1/p' /etc/os-release | tr -d '\"')"
    # On CentOS/RHEL, users could have installed a kernel not distributed from RHEL
    ifeq ("centos",$(OS_NAME))
    OS_NAME="custom-rhel"
    else ifeq ("rhel",$(OS_NAME))
    OS_NAME="custom-rhel"
    else
    ifeq ("linuxmint",$(OS_NAME))
    OS_NAME="ubuntu"
    endif
    OS_VERSION = $(shell sed -n 's/^VERSION_ID=\(.*\)/\1/p' /etc/os-release)
    endif
    else
    OS_NAME = "unknown"
    OS_VERSION = "0.0"
    endif
    
    OS_NAME="debian"
    
    ifneq ($(findstring $(OS_NAME), "ubuntu" "sled" "sles" "opensuse" "opensuse-leap" "amzn" "custom-rhel" "fedora"),)
    DRM_VER=$(shell sed -n 's/^VERSION = \(.*\)/\1/p' $(kdir)/Makefile)
    DRM_PATCH=$(shell sed -n 's/^PATCHLEVEL = \(.*\)/\1/p' $(kdir)/Makefile)
    else ifeq ("debian", $(OS_NAME))
    real_kdir=$(shell echo $(kdir) | sed "s/build/source/")
    DRM_VER=$(shell sed -n 's/^VERSION = \(.*\)/\1/p' $(real_kdir)/Makefile)
    DRM_PATCH=$(shell sed -n 's/^PATCHLEVEL = \(.*\)/\1/p' $(real_kdir)/Makefile)
    else ifeq ("rhel",$(OS_NAME))
    ifneq ($(OS_VERSION),"8.0")
    DRM_VER=$(shell sed -n 's/^RHEL_DRM_VERSION = \(.*\)/\1/p' $(kdir)/Makefile)
    DRM_PATCH=$(shell sed -n 's/^RHEL_DRM_PATCHLEVEL = \(.*\)/\1/p' $(kdir)/Makefile)
    else
    DRM_VER=$(shell sed -n 's/^VERSION = \(.*\)/\1/p' $(kdir)/Makefile)
    DRM_PATCH=$(shell sed -n 's/^PATCHLEVEL = \(.*\)/\1/p' $(kdir)/Makefile)
    endif
    endif
    
    subdir-ccflags-y += \
    	-DDRM_VER=$(DRM_VER) \
    	-DDRM_PATCH=$(DRM_PATCH) \
    	-DDRM_SUB="0"
    
    ifeq ("ubuntu",$(OS_NAME))
    subdir-ccflags-y += -DOS_NAME_UBUNTU
    else ifeq ("rhel",$(OS_NAME))
    subdir-ccflags-y += -DOS_NAME_RHEL
    else ifeq ("steamos",$(OS_NAME))
    subdir-ccflags-y += -DOS_NAME_STEAMOS
    else ifeq ("opensuse",$(OS_NAME))
    subdir-ccflags-y += -DOS_NAME_SLE
    else ifeq ("sled",$(OS_NAME))
    subdir-ccflags-y += -DOS_NAME_SLE
    else ifeq ("sles",$(OS_NAME))
    subdir-ccflags-y += -DOS_NAME_SLE
    else ifeq ("amzn",$(OS_NAME))
    subdir-ccflags-y += -DOS_NAME_AMZ
    else ifeq ("debian",$(OS_NAME))
    subdir-ccflags-y += -DOS_NAME_DEBIAN
    else
    subdir-ccflags-y += -DOS_NAME_UNKNOWN
    endif
    
    subdir-ccflags-y += \
    	-DOS_VERSION_MAJOR=$(shell echo $(OS_VERSION).0 | cut -d. -f1) \
    	-DOS_VERSION_MINOR=$(shell echo $(OS_VERSION).0 | cut -d. -f2)
    
    ifeq ($(OS_NAME),"opensuse-leap")
    ifeq ($(OS_VERSION),"15.1")
    subdir-ccflags-y += -DOS_NAME_SUSE_15
    endif
    endif
    
    ifeq ($(OS_NAME),"opensuse-leap")
    ifeq ($(OS_VERSION),"15.1")
    subdir-ccflags-y += -DOS_NAME_SUSE_15_1
    endif
    endif
    
    ifeq ($(OS_NAME),"sled")
    ifeq ($(OS_VERSION),"15")
    subdir-ccflags-y += -DOS_NAME_SUSE_15
    endif
    endif
    
    ifeq ($(OS_NAME),"sled")
    ifeq ($(OS_VERSION),"15.1")
    subdir-ccflags-y += -DOS_NAME_SUSE_15_1
    endif
    endif
    
    ifeq ($(OS_NAME),"sles")
    ifeq ($(OS_VERSION),"15")
    subdir-ccflags-y += -DOS_NAME_SUSE_15
    endif
    endif
    
    ifeq ($(OS_NAME),"sles")
    ifeq ($(OS_VERSION),"15.1")
    subdir-ccflags-y += -DOS_NAME_SUSE_15_1
    endif
    endif
    
    ifeq ($(OS_NAME),"opensuse")
    ifeq ($(OS_VERSION),"42.3")
    subdir-ccflags-y += -DOS_NAME_SUSE_42_3
    endif
    endif
    
    ifeq ($(OS_NAME),"sled")
    ifeq ($(OS_VERSION),"12.3")
    subdir-ccflags-y += -DOS_NAME_SLE_12_3
    endif
    endif
    
    ifeq ($(OS_NAME),"sles")
    ifeq ($(OS_VERSION),"12.3")
    subdir-ccflags-y += -DOS_NAME_SLE_12_3
    endif
    endif
    
    ifeq ($(OS_NAME),"ubuntu")
    OS_BUILD_NUM = $(shell echo $(KERNELRELEASE) | cut -d '-' -f 2)
    subdir-ccflags-y += -DUBUNTU_BUILD_NUM=$(OS_BUILD_NUM)
    OS_OEM = "$(shell echo $(KERNELRELEASE) | cut -d '-' -f 3)"
    ifeq ($(OS_OEM),"oem")
    subdir-ccflags-y += -DOS_NAME_UBUNTU_OEM
    endif
    ifeq ($(OS_VERSION),"14.04")
    subdir-ccflags-y += -DOS_NAME_UBUNTU_1404
    else
    subdir-ccflags-y += -DOS_NAME_UBUNTU_1604
    endif
    endif
    
    ifeq ($(OS_NAME),"rhel")
    ifeq ($(OS_VERSION),"6.8")
    subdir-ccflags-y += -DOS_NAME_RHEL_6
    else ifeq ($(OS_VERSION),"6.9")
    subdir-ccflags-y += -DOS_NAME_RHEL_6
    else ifeq ($(OS_VERSION),"6.10")
    subdir-ccflags-y += -DOS_NAME_RHEL_6
    else ifeq ($(OS_VERSION),"7.2")
    subdir-ccflags-y += -DOS_NAME_RHEL_7_2
    else ifeq ($(OS_VERSION),"7.3")
    subdir-ccflags-y += -DOS_NAME_RHEL_7_3
    else ifeq ($(OS_VERSION),"7.4")
    subdir-ccflags-y += -DOS_NAME_RHEL_7_4
    subdir-ccflags-y += -DOS_NAME_RHEL_7_X
    else ifeq ($(OS_VERSION),"7.5")
    subdir-ccflags-y += -DOS_NAME_RHEL_7_5
    subdir-ccflags-y += -DOS_NAME_RHEL_7_X
    else ifeq ($(OS_VERSION),"7.6")
    subdir-ccflags-y += -DOS_NAME_RHEL_7_6
    subdir-ccflags-y += -DOS_NAME_RHEL_7_X
    else ifeq ($(OS_VERSION),"7.7")
    subdir-ccflags-y += -DOS_NAME_RHEL_7_7
    subdir-ccflags-y += -DOS_NAME_RHEL_7_X
    else ifeq ($(OS_VERSION),"8.0")
    subdir-ccflags-y += -DOS_NAME_RHEL_8_0
    endif
    ifneq ($(RHEL_MAJOR),8)
    subdir-ccflags-y += \
    	-include /usr/src/kernels/$(KERNELRELEASE)/include/drm/drm_backport.h
    endif
    endif
    
    subdir-ccflags-y += -include $(src)/config/config.h
    DKMS_INCLUDE_PREFIX = \
    	-I$(src)/include \
    	-I$(src)/include/drm \
    	-I$(src)/include/uapi \
    	-include $(src)/include/kcl/kcl_version.h \
    	-include $(src)/include/rename_symbol.h
    
    export OS_NAME OS_VERSION DKMS_INCLUDE_PREFIX
    
    export CONFIG_HSA_AMD=y
    export CONFIG_DRM_TTM=m
    export CONFIG_DRM_TTM_DMA_PAGE_POOL=y
    export CONFIG_DRM_AMDGPU=m
    export CONFIG_DRM_SCHED=m
    export BUILD_AS_DKMS=y
    export CONFIG_DRM_AMDGPU_CIK=y
    export CONFIG_DRM_AMDGPU_SI=y
    export CONFIG_DRM_AMDGPU_USERPTR=y
    export CONFIG_DRM_AMD_DC=y
    export CONFIG_DRM_AMD_DC_DCN1_0=y
    export CONFIG_DRM_AMD_DC_DCN1_01=y
    export CONFIG_DRM_AMD_DC_DCN2_0=y
    export CONFIG_DRM_AMD_DC_DCN2_1=y
    
    subdir-ccflags-y += -DCONFIG_HSA_AMD
    subdir-ccflags-y += -DCONFIG_DRM_TTM_DMA_PAGE_POOL
    subdir-ccflags-y += -DBUILD_AS_DKMS
    subdir-ccflags-y += -DCONFIG_DRM_AMDGPU_CIK
    subdir-ccflags-y += -DCONFIG_DRM_AMDGPU_SI
    subdir-ccflags-y += -DCONFIG_DRM_AMDGPU_USERPTR
    subdir-ccflags-y += -DCONFIG_DRM_AMD_DC
    subdir-ccflags-y += -DCONFIG_DRM_AMD_DC_DCN1_0
    subdir-ccflags-y += -DCONFIG_DRM_AMD_DC_DCN1_01
    subdir-ccflags-y += -DCONFIG_DRM_AMD_DC_DCN2_0
    subdir-ccflags-y += -DCONFIG_DRM_AMD_DC_DCN2_1
    
    obj-m += scheduler/ amd/amdgpu/ ttm/ amd/amdkcl/
I am writing this because I could not find how to do it anywhere in the web and in the hope it may be useful to somebody.
Last edited by mrproper on Sat Dec 05, 2020 6:47 pm, edited 1 time in total.
User avatar
cpedretti
Level 3
Level 3
Posts: 199
Joined: Tue Mar 10, 2020 12:06 am

Re: [HOWTO] Install amdgpu-pro on LMD 4

Post by cpedretti »

Nice tutorial, but it exist another method.


Update your kernel to the latest first before install the latest firmware, we need to be root:

Code: Select all

apt update

Code: Select all

apt search linux-image

Select your kernel to install it, in my case the latest:

Code: Select all

apt install linux-image-5.6.0-0.bpo.2-amd64 linux-headers-5.6.0-0.bpo.2-amd64 -y

Get the latest firmware:

Code: Select all

apt install git -y

Code: Select all

cd /tmp

Code: Select all

git clone git://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git

Code: Select all

cd linux-firmware/

Code: Select all

cp -va amdgpu/ /lib/firmware/

You need to update the initramfs to compile the firmware with the new kernel:

Code: Select all

update-initramfs -u

Reboot to take effects

Code: Select all

reboot
Enjoy! :D


Source
AMD Ryzen 7 3700X - 32GB DDR4 RGB White - RTX4060TI O8GB White- SSD NVME Crucial P5 500GB - Mobo Gigabyte AORUS ELITE B550 V2 - PSU Corsair RM750 White - Case Corsair 5000D Airflow White 7 fans AF120 ARGB - AIO Corsair H100I Cappelix 240 White
mrproper

Re: [HOWTO] Install amdgpu-pro on LMD 4

Post by mrproper »

Cool way to get the latest driver, but you should note:
  • This install the open source driver
  • You must activate the backports packages from your repository to install the latest kernel
User avatar
cpedretti
Level 3
Level 3
Posts: 199
Joined: Tue Mar 10, 2020 12:06 am

Re: [HOWTO] Install amdgpu-pro on LMD 4

Post by cpedretti »

mrproper wrote: Thu Jul 16, 2020 8:19 am Cool way to get the latest driver, but you should note:
  • This install the open source driver
  • You must activate the backports packages from your repository to install the latest kernel
Yep you need the last kernel to install the last open source amdgpu drivers.

Per default the backport sources are activate in my packages.list, i don't use the default repository.
AMD Ryzen 7 3700X - 32GB DDR4 RGB White - RTX4060TI O8GB White- SSD NVME Crucial P5 500GB - Mobo Gigabyte AORUS ELITE B550 V2 - PSU Corsair RM750 White - Case Corsair 5000D Airflow White 7 fans AF120 ARGB - AIO Corsair H100I Cappelix 240 White
Post Reply

Return to “Tutorials”