I'm trying setup my Lenovo Legion 5 Pro w/ Ubuntu 20.04.3 LTS machine so that I can use my GPU (Nvidia Geforce RTX 3070 8GB) for machine learning, for example with PyTorch. However, even after re-installing the NVidia drivers several times, it looks like it is still not visible, as running nvidia-smi gives the following:
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 looked at several solutions out there (this, this, this, this) and nothing works until now. But I think that the problem is caused by the kernel I'm using.
Running nvcc --version gives the following output:
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Sun_Jul_28_19:07:16_PDT_2019
Cuda compilation tools, release 10.1, V10.1.243
ls /usr/src | grep nvidia
outputs nvidia-470.86
When I try to run these commands from here, i.e.
sudo apt install dkms
sudo dkms install -m nvidia -v 470.86
I get the following error:
Error! Your kernel headers for kernel 5.16.2-051602-generic cannot be found.
Please install the linux-headers-5.16.2-051602-generic package,
or use the --kernelsourcedir option to tell DKMS where it's located
Now, linux-headers-5.16.2-051602-generic
doesn't exist, but I already have linux-headers-generic
installed.
Do you have any suggestions about what I could try to fix this?
Thanks a lot!