Ubuntu 20.04.3 uninstall and install AMD drivers

dpkg –list | grep amdgpu
ii amdgpu-pin 20.50-1234664 all Meta package to pin a specific amdgpu driver version.
ii amdgpu-pro-pin 20.50-1234664 all Meta package to pin a specific amdgpu pro driver version.
ii libdrm-amdgpu1:amd64 2.4.102-1ubuntu1~20.04.1 amd64 Userspace interface to amdgpu-specific kernel DRM services — runtime
ii rock-dkms 1:4.1-26 all amdgpu driver in DKMS format.
ii rock-dkms-firmware 1:4.1-26 all firmware blobs used by amdgpu driver in DKMS format
ii xserver-xorg-video-amdgpu 19.1.0-1 amd64 X.Org X server — AMDGPU display driver

$ sudo apt purge amdgpu-pin
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libomxil-bellagio-bin libomxil-bellagio0
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
amdgpu-pin*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 27.6 kB disk space will be freed.
Do you want to continue? [Y/n]
dpkg: warning: files list file for package 'libdrm-amdgpu1:amd64' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'libdrm-amdgpu1:i386' missing; assuming package has no files currently installed
(Reading database ... 346337 files and directories currently installed.)
Removing amdgpu-pin (21.30-1290604) ...
dpkg: warning: files list file for package 'libdrm-amdgpu1:amd64' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'libdrm-amdgpu1:i386' missing; assuming package has no files currently installed
(Reading database ... 346334 files and directories currently installed.)
Purging configuration files for amdgpu-pin (21.30-1290604) ...

How can we fix this?

dpkg: warning: files list file for package 'libdrm-amdgpu1:amd64' missing; assuming package has no files currently installed
dpkg: warning: files list file for package 'libdrm-amdgpu1:i386' missing; assuming package has no files currently installed
for package in $(apt-get upgrade 2>&1 | grep "warning: files list file for package '" | grep -Po "[^'\n ]+'" | grep -Po "[^']+"); do apt-get install --reinstall "$package"; done

In order to remove broken packages, or packages which weren’t fully installed we will run

sudo su
sudo apt-get clean && apt-get autoremove
sudo apt-get -f install
sudo dpkg --configure -a
# dpkg -r rock-dkms
(Reading database ... 170365 files and directories currently installed.)
Removing rock-dkms (1:4.1-26) ...

-------- Uninstall Beginning --------
Module: amdgpu
Version: 4.1-26
Kernel: 5.8.0-48-generic (x86_64)
-------------------------------------

...
# dpkg -r rock-dkms
(Reading database ... 170365 files and directories currently installed.)
Removing rock-dkms (1:4.1-26) ...

-------- Uninstall Beginning --------
Module: amdgpu
Version: 4.1-26
Kernel: 5.8.0-48-generic (x86_64)
-------------------------------------

Notice the rc before the rock-dkms

# dpkg --list | grep amdgpu
ii amdgpu-pin 20.50-1234664 all Meta package to pin a specific amdgpu driver version.
ii amdgpu-pro-pin 20.50-1234664 all Meta package to pin a specific amdgpu pro driver version.
ii libdrm-amdgpu1:amd64 2.4.102-1ubuntu1~20.04.1 amd64 Userspace interface to amdgpu-specific kernel DRM services -- runtime
rc rock-dkms 1:4.1-26 all amdgpu driver in DKMS format.
ii rock-dkms-firmware 1:4.1-26 all firmware blobs used by amdgpu driver in DKMS format
ii xserver-xorg-video-amdgpu 19.1.0-1 amd64 X.Org X server -- AMDGPU display driver
# dpkg --purge rock-dkms 
(Reading database ... 167742 files and directories currently installed.)
Purging configuration files for rock-dkms (1:4.1-26) ...


# dpkg --list | grep amdgpu
ii amdgpu-pin 20.50-1234664 all Meta package to pin a specific amdgpu driver version.
ii amdgpu-pro-pin 20.50-1234664 all Meta package to pin a specific amdgpu pro driver version.
ii libdrm-amdgpu1:amd64 2.4.102-1ubuntu1~20.04.1 amd64 Userspace interface to amdgpu-specific kernel DRM services -- runtime
ii xserver-xorg-video-amdgpu 19.1.0-1 amd64 X.Org X server -- AMDGPU display driver

Run one last time

$ /usr/bin/amdgpu-pro-uninstall
bash: /usr/bin/amdgpu-pro-uninstall: No such file or directory
$ /usr/bin/amdgpu-uninstall
bash: /usr/bin/amdgpu-uninstall: No such file or directory

Install the drivers for Ubuntu 20.04.3 https://www.amd.com/en/support/kb/release-notes/rn-amdgpu-unified-linux-21-40-2

wget http://repo.radeon.com/amdgpu-install/21.40.2/ubuntu/focal/amdgpu-install_21.40.2.40502-1_all.deb

sudo apt install ./21.40.2/ubuntu/focal/amdgpu-install_21.40.2.40502-1_all.deb 

amdgpu-install --opencl=legacy -y