Installing NVIDIA driver and CUDA to Kali Linux

I am following this page to install CUDA in Kali Linux but after the installation is complete I am getting this error when I run 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 Kali installed on my laptop as a dual boot and here is the result of running
lspci -s 07:00.0 -v
on my machine:
07:00.0 3D controller: NVIDIA Corporation GK208M [GeForce GT 740M] (rev a1)
Subsystem: Lenovo GK208M [GeForce GT 740M]
Flags: bus master, fast devsel, latency 0, IRQ 10
Memory at b3000000 (32-bit, non-prefetchable) [size=16M]
Memory at a0000000 (64-bit, prefetchable) [size=256M]
Memory at b0000000 (64-bit, prefetchable) [size=32M]
I/O ports at 4000 [disabled] [size=128]
Expansion ROM at [disabled]
Capabilities: [60] Power Management version 3
Capabilities: [68] MSI: Enable- Count=1/1 Maskable- 64bit+
Capabilities: [78] Express Endpoint, MSI 00
Capabilities: [100] Virtual Channel
Capabilities: [128] Power Budgeting <?>
Capabilities: [600] Vendor Specific Information: ID=0001 Rev=1 Len=024 <?>
Capabilities: [900] Secondary PCI Express
Kernel modules: nvidia

More information is needed to get a clue.
Please run as root and attach the resulting file here.

Here it is.
nvidia-bug-report.log.gz (110.7 KB)

[ 772.425] (WW) NVIDIA(0): The NVIDIA GeForce GT 740M GPU installed in this system is
[ 772.425] (WW) NVIDIA(0): supported through the NVIDIA 470.xx Legacy drivers. Please
[ 772.425] (WW) NVIDIA(0): visit for more
[ 772.425] (WW) NVIDIA(0): information. The 495.29.05 NVIDIA driver will ignore this
[ 772.425] (WW) NVIDIA(0): GPU. Continuing probe…

Best you install the driver through the repository, not the .run file.
See this guide (for buster, but should work with sid as well (just change buster to sid in the sources file)).

Or even better this one.

Looks like you installed from the .run file. Before attempting a repo install, uninstall from the .run file with the --uninstall option! Otherwise you risk a messed up system.

I actually installed it using below command:
sudo apt install -y nvidia-driver nvidia-cuda-toolkit

How am supposed to uninstall?

apt purge
Just make sure you then install version 470 of the driver.

but it seems this version is not supported by my GPU 740M?

When I run:

apt install nvidia-driver firmware-misc-nonfree

again it installs The 495.29.05 I guess

apt search nvidia
and look for another version

I did but when I try to install CUDA there is no other version to be installed and it throws kernel version mismatch and replaces it after restart. By the way after installing the legacy drivers nvidia-smi still does not work

So you are trying to install full CUDA… guessing from the nvidia .run file? That would install another driver (if you do not omit that step).
You should just install cuda-toolkit instead.
What version of the legacy drivers did you install?
If you did a .run file installation again, I suggest you uninstall it with the --uninstall option. Then re-install the repo drivers. Then install cuda-toolkit.
If it does not work after that, create a new bug-report.

No, not from run file.
I did this:

apt install nvidia-legacy-390xx-driver firmware-misc-nonfree

apt install nvidia-cuda-dev nvidia-cuda-toolkit

Really no 470, 460, driver on debian available?