Ubuntu 20.04 - NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver

Issue : Ubuntu 20.04 - NVIDIA-SMI has failed because it couldn’t communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.
OS : Ubuntu 20.04
Kernel : 5.15.0-52-generic
dkms status : nvidia, 520.61.05, 5.15.0-52-generic, x86_64: installed

dpkg -l | grep nvidia

ii  libnvidia-cfg1-520:amd64                      520.61.05-0ubuntu1                   amd64        NVIDIA binary OpenGL/GLX configuration library
ii  libnvidia-common-520                          520.61.05-0ubuntu1                   all          Shared files used by the NVIDIA libraries
ii  libnvidia-compute-520:amd64                   520.61.05-0ubuntu1                   amd64        NVIDIA libcompute package
ii  libnvidia-compute-520:i386                    520.61.05-0ubuntu1                   i386         NVIDIA libcompute package
ii  libnvidia-decode-520:amd64                    520.61.05-0ubuntu1                   amd64        NVIDIA Video Decoding runtime libraries
ii  libnvidia-decode-520:i386                     520.61.05-0ubuntu1                   i386         NVIDIA Video Decoding runtime libraries
ii  libnvidia-encode-520:amd64                    520.61.05-0ubuntu1                   amd64        NVENC Video Encoding runtime library
ii  libnvidia-encode-520:i386                     520.61.05-0ubuntu1                   i386         NVENC Video Encoding runtime library
ii  libnvidia-extra-520:amd64                     520.61.05-0ubuntu1                   amd64        Extra libraries for the NVIDIA driver
ii  libnvidia-fbc1-520:amd64                      520.61.05-0ubuntu1                   amd64        NVIDIA OpenGL-based Framebuffer Capture runtime library
ii  libnvidia-fbc1-520:i386                       520.61.05-0ubuntu1                   i386         NVIDIA OpenGL-based Framebuffer Capture runtime library
ii  libnvidia-gl-520:amd64                        520.61.05-0ubuntu1                   amd64        NVIDIA OpenGL/GLX/EGL/GLES GLVND libraries and Vulkan ICD
ii  libnvidia-gl-520:i386                         520.61.05-0ubuntu1                   i386         NVIDIA OpenGL/GLX/EGL/GLES GLVND libraries and Vulkan ICD
ii  nvidia-compute-utils-520                      520.61.05-0ubuntu1                   amd64        NVIDIA compute utilities
ii  nvidia-dkms-520                               520.61.05-0ubuntu1                   amd64        NVIDIA DKMS package
ii  nvidia-driver-520                             520.61.05-0ubuntu1                   amd64        NVIDIA driver metapackage
ii  nvidia-kernel-common-520                      520.61.05-0ubuntu1                   amd64        Shared files used with the kernel module
ii  nvidia-kernel-source-520                      520.61.05-0ubuntu1                   amd64        NVIDIA kernel source package
ii  nvidia-modprobe                               520.61.05-0ubuntu1                   amd64        Load the NVIDIA kernel driver and create device files
ii  nvidia-prime                                  0.8.16~0.20.04.2                     all          Tools to enable NVIDIA's Prime
ii  nvidia-settings                               520.61.05-0ubuntu1                   amd64        Tool for configuring the NVIDIA graphics driver
ii  nvidia-utils-520                              520.61.05-0ubuntu1                   amd64        NVIDIA driver support binaries
ii  screen-resolution-extra                       0.18build1                           all          Extension for the nvidia-settings control panel
ii  xserver-xorg-video-nvidia-520                 520.61.05-0ubuntu1                   amd64        NVIDIA binary Xorg driver

cat /lib/modprobe.d/blacklist-nvidia.conf

# Do not modify
# This file was generated by nvidia-prime
blacklist nvidia
blacklist nvidia-drm
blacklist nvidia-modeset
alias nvidia off
alias nvidia-drm off
alias nvidia-modeset off

Whenever I select prime-select nvidia, my OS is unable to boot up. It gives a blank screen. I have to everytime switch back to prime-select intel to get the display back on.
Laptop Acer-Nitro5 GPU RTX 3050Ti and Intel Integrated GPU.

I recently reinstalled nvidia-driver-520, it was working fine until I restarted the system when the nvidia-smi error cropped up. This keeps happening after every reboot.
Any help would be greatly appreciated.
Can someone please help me out why this is happening?

Please try switching to on-demand mode
Please run nvidia-bug-report.sh as root and attach the resulting nvidia-bug-report.log.gz file to your post.

Attaching the nvidia-bug-report.log.gz
nvidia-bug-report.log.gz (144.8 KB).
When I tried to switch to on-demand using prime-select and run the nvidia-bug-report.log.gz, the whole screen went blank, and the display froze.
The nvidia-bug-report.log.gz could only be run on intel mode.

Please remove nomodeset kernel parameter

I removed teh nomodeset from the /etc/default/grub and updated the grub.

sudo update-grub

I tried running

sudo nvidia-bug-report.sh

after switching it to on-demand in prime-select.
The screen froze and went black again.

My bad, I forgot to reboot before running the bug report.sh.
Attaching the nvidia-bug-report.sh
nvidia-bug-report.log.gz (312.8 KB)
.
nvidia-smi is now working fine.
Thanks for your timely help.

There is some issue with the display right now.


It seems like some display issue.

Please delete /etc/X11/xorg.conf and uninstall the xorg-video-intel driver.

Also, please update your firmware package manually.
https://packages.ubuntu.com/de/jammy/linux-firmware

Updated the firmware and deleted the /etc/X11/xorg.conf file and also removed the xorg-video-intel driver. The system is now stable and nvidia-smi seems to be working fine.
Thank you for the efforts.