Getting an error while installing nvidia driver on ec2 server

I’m trying to install nvidia driver on my aws-ec2 instance, it’s worked fine until I reboot my system, and get error saying nvidia-smi failed. I tried to uninstall and re-install but I am getting this weired error:

Errors were encountered while processing nvidia-dkms-470 nvidia-driver-470 E: Sub-process /usr/bin/dpkg returned an error code (1)

anyone might know how to fix this issue? thanks!