CUDA Driver Instllation faiulre

I try to install CUDA on my Ubuntu environment, but I always get error “dpkg: error processing package nvidia-dkms-550”

Ubuntu 22.04.2
Kernal: 6.2.0-26
GCC:11.4.0
GLIBC:2.35

update-initramfs: deferring update (trigger activated)
INFO:Enable nvidia
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/put_your_quirks_here
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/lenovo_thinkpad
DEBUG:Parsing /usr/share/ubuntu-drivers-common/quirks/dell_latitude
Removing old nvidia-550.54.14 DKMS files…
Loading new nvidia-550.54.14 DKMS files…
Error! DKMS tree already contains: nvidia-550.54.14
You cannot add the same module/version combo more than once.
dpkg: error processing package nvidia-dkms-550 (–configure):
*** installed nvidia-dkms-550 package post-installation script subprocess returned error exit status 3***
Setting up cuda-profiler-api-12-4 (12.4.99-1) …
Setting up cuda-demo-suite-12-4 (12.4.99-1) …
Setting up cuda-nvdisasm-12-4 (12.4.99-1) …
Setting up cuda-nvvm-12-4 (12.4.99-1) …
Setting up cuda-nvprune-12-4 (12.4.99-1) …
Setting up nsight-systems-2023.4.4 (2023.4.4.54-234433681190v0) …
update-alternatives: using /opt/nvidia/nsight-systems/2023.4.4/target-linux-x64/ nsys to provide /usr/local/bin/nsys (nsys) in manual mode
update-alternatives: using /opt/nvidia/nsight-systems/2023.4.4/host-linux-x64/ns ys-ui to provide /usr/local/bin/nsys-ui (nsys-ui) in manual mode
Setting up cuda-nvtx-12-4 (12.4.99-1) …
Setting up cuda-cuxxfilt-12-4 (12.4.99-1) …
Setting up nsight-compute-2024.1.0 (2024.1.0.13-1) …
Setting up cuda-nsight-12-4 (12.4.99-1) …
Setting up cuda-driver-dev-12-4 (12.4.99-1) …
Setting up cuda-nvprof-12-4 (12.4.99-1) …
Setting up cuda-cuobjdump-12-4 (12.4.99-1) …
Setting up cuda-toolkit-12-4-config-common (12.4.99-1) …
Setting alternatives
update-alternatives: using /usr/local/cuda-12.4 to provide /usr/local/cuda (cuda ) in auto mode
update-alternatives: using /usr/local/cuda-12.4 to provide /usr/local/cuda-12 (c uda-12) in auto mode
Setting up libnvjitlink-12-4 (12.4.99-1) …
Setting up cuda-nsight-systems-12-4 (12.4.0-1) …
Setting up cuda-nvrtc-12-4 (12.4.99-1) …
Setting up cuda-sanitizer-12-4 (12.4.99-1) …
Setting up libcurand-12-4 (10.3.5.119-1) …
dpkg: dependency problems prevent configuration of nvidia-driver-550:
nvidia-driver-550 depends on nvidia-dkms-550 (<= 550.54.14-1); however:
Package nvidia-dkms-550 is not configured yet.
nvidia-driver-550 depends on nvidia-dkms-550 (>= 550.54.14); however:
Package nvidia-dkms-550 is not configured yet.

This looks like you already installed the 550 driver from ubuntu repo and are now trying to install the full “cuda” meta package, also containing the driver. So you’re trying to install the same driver twice.
Please either uninstall the ubuntu driver or instead install the “cuda-toolkit” metapackge instead of “cuda”.

@generix Thanks for your reply.
Actually the root problem I meet is when I run the nvidia-smi. It raises below error.

NVIDIA-SMI has failed because it couldn’t communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.

That’s why I want to reinstall cuda-driver again to fix the problem. But unfortunately, I can’t get this cuda-driver refreshed because of below error. And now I am blocked.
“installed nvidia-dkms-550 package post-installation script subprocess returned error exit status 3”

Please try reinstalling kernel headers
sudo apt install --reinstall linux-headers-$(uname -r)
and post any errors.

Please also post the output of dkms status

@generix You are right, the dkms error is because of I have already installed the driver.

When I firstly install driver, I meet an issue as below
SSL error:FFFFFFFF80000002:system library::No such file or directory: …/crypto/bio/bss_file.c:67

And then I try to fix this issue by this command
update-secureboot-policy --new-key

And then I uninstall nvidia driver with below command
apt purge ~nnvidia
apt autoremove
apt clean
rm -fr /var/lib/dkms/nvidia

After all of these operation, I reinstall nvidia driver, this time I get successed.