Zend certified PHP/Magento developer

gcc –version error prevent installation of Nvidia proprietary driver via DKMS on ubuntu 20.04

When trying to install nvidia proprietary driver on my 20.04 LTS host I ran into a problem that it would not install when using DKMS. It complained about mismatach between gcc version used for the kernel (9.3.0) and current gcc version (9.4.0). The problem occurred after upgrading to the latest kernel version. When running gcc –version it reports 9.4.0 but apt show gcc reports 9.3.0.

gcc --version
gcc (Ubuntu 9.4.0-1ubuntu1~20.04) 9.4.0

apt show gcc
Package: gcc
Version: 4:9.3.0-1ubuntu2

lsb_release -a
LSB Version:    core-11.1.0ubuntu2-noarch:security-11.1.0ubuntu2-noarch
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.4 LTS
Release:    20.04
Codename:   focal

uname -a
Linux xenon 5.4.0-104-generic #118-Ubuntu SMP Wed Mar 2 19:02:41 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

It seems to me that the problem is that the gcc package is 9.3.0 as shown by apt but reports 9.4.0.

Any suggestions ?