need help to install cuda on ubuntu 18.04 (dell xps 9570)

I have been trying to get cuda installed using the instruction guide. but I always get error message from nvidia-smi. The following are the sequence of command I tried. Can anyone explain why I can’t get it to work? Thanks,

1  gcc
2  sudo apt install gcc
3  lspci|grep -i nvidia
4  uname -m && cat /etc/*release
5  gcc --version
6  uname -r
7  sudo apt-get install linux-headers-$(uname -r)

10 sudo dpkg -i cuda-repo-ubuntu1804_10.1.105-1_amd64.deb
11 sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
12 sudo apt-get update
13 sudo apt-get install cuda-10-1
14 sudo nano /etc/modprobe.d/blacklist-nouveau.conf
15 sudo update-initramfs -u
16 reboot

then I changed $PATH and $LD_LIBRARY_PATH and verified nvcc version. But nvidia-smi is giving me the following errors.

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

later I re installed nvidia driver, but still got the same error. anyone knows why?
71 dpkg -l |grep nvidia
72 sudo dpkg -purge nvidia-*
73 sudo apt-get --purge remove cuda
74 sudo apt-get --purge remove nvidia*
75 nvidia-smi
76 reboot
77 sudo add-apt-repository ppa:graphics-drivers/ppa
78 sudo apt-get update
79 sudo apt-get install nvidia-driver-418
81 reboot
82 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.

I have gone through nvidia bug report and found below error message –

-> Kernel module compilation complete.
-> The target kernel has CONFIG_MODULE_SIG set, which means that it supports cryptographic signatures on kernel modules. On some systems, the kernel may refuse to load modules without a valid signature from a trusted key. This system also has UEFI Secure Boot enabled; many distributions enforce module signature verification on UEFI systems when Secure Boot is enabled. Would you like to sign the NVIDIA kernel module? (Answer: Install without signing)
ERROR: The kernel module failed to load, because it was not signed by a key that is trusted by the kernel. Please try installing the driver again, and sign the kernel module when prompted to do so.
ERROR: Unable to load the kernel module ‘nvidia.ko’. This happens most frequently when this kernel module was built against the wrong or improperly configured kernel sources, with a version of gcc that differs from the one used to build the target kernel, or if another driver, such as nouveau, is present and prevents the NVIDIA kernel module from obtaining ownership of the NVIDIA GPU(s), or no NVIDIA GPU installed in this system is supported by this NVIDIA Linux graphics driver release.

Please see the log entries ‘Kernel module load error’ and ’

Please disable Secure Boot option in BIOS settings and install driver.
Please share your results as well.

disable secure boot option fixes the problem. thanks,