NVIDIA-470 driver installed in Ubuntu 20.04 but NVIDIA-SMI failed

My Dell laptop has Ubuntu 20.04 LTS with updated running kernel (uname-a) as Linux aditya 5.14.2-051402-generic #202109080331 SMP Wed Sep 8 07:35:12 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux.

The command lspci -k |grep -EA3 VGA|3D|Display shows
`00:02.0 VGA compatible controller: Intel Corporation HD Graphics 620 (rev 02)
DeviceName: Onboard IGD
Subsystem: Dell HD Graphics 620
Kernel driver in use: i915

01:00.0 3D controller: NVIDIA Corporation GM108M [GeForce 940MX] (rev a2)
Subsystem: Dell GM108M [GeForce 940MX]
Kernel modules: nvidiafb, nouveau
02:00.0 Network controller: Intel Corporation Wireless 3165 (rev 79)[nvidia-bug-report.log.compact|attachment](upload://dG4WNXwBoCG0kdYUnHiwctyyXhK.compact) (143.8 KB)

When I ran ubuntu-drivers devices I got nvidia-driver0470 as recommended. I have nouveau as blacklisted in /etc/modprobe.d/blacklist.conf and /etc/modprobe.d/nvidia-installer-disable-nouveau.conf which also has options nouveau modeset=0.

I used sudo ubuntu-drivers autoinstall to install recommended driver and then re-installed nvidia-prime. I checked whether nvidia is active using prime-select. I renamed the file /etc/X11/xorg.conf as /etc/X11/xorg.conf-ORIG.

Then I rebooted.

The Ubuntu booted and I could log in the system normally. In a terminal I checked nvidia-smi and it states `vega@aditya:~ 11:31 PM $ nvidia-smi
NVIDIA-SMI has failed because it couldn’t communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.

vega@aditya:~ 11:31 PM $`
Please let me know how to resolve the issue.