NVIDIA: Failed to initialize the NVIDIA kernel module. Please see the

環境

困ったこと

PCを起動するとログイン画面にたどり着けなかった。
Ctrl-Alt-F2で、/var/log/Xorg.0.logを見ると以下の記述があった。

NVIDIA: Failed to initialize the NVIDIA kernel module. Please see the

やったこと

いろいろやったが、結論でいうとNVIDIAのドライバーが古くなっていた。
前にインストールした方法も覚えていないので、調べ直した。
NVIDIAのドライバーを入れていない場合も、同様の手順でできる。

ということで、

$ sudo wget http://jp.download.nvidia.com/XFree86/Linux-x86_64/450.57/NVIDIA-Linux-x86_64-450.57.run

ドライバーは最新バージョンを選択。
公式ドライバー | NVIDIAから調べる。

実行する。

$ sudo sh NVIDIA-Linux-x86_64-450.57.run

失敗。

ERROR: Unable to find the kernel source tree for the currently running kernel. Please make sure you have installed the kernel source files for your kernel and that they are properly configured; on Red Hat Linux systems, for example, be sure you have the 'kernel-source' or 'kernel-devel' RPM installed. If you know the correct kernel source files are installed, you may specify the kernel source path with the '--kernel-source-path' command line option.

以下のようなことを書いていたので、linux-headersをインストール。

https://www.nvidia.com/en-us/geforce/forums/geforce-graphics-cards/5/285883/problem-to-install-driver/

$ sudo apt -y install linux-headers-amd64

再度、実行するとうまく行った・

$ sudo sh NVIDIA-Linux-x86_64-450.57.run

NVIDIAのドライバのインストール | 逆襲のSlackware
を参考に設定した。

再起動して、完了。
うまくいった。
終わってから、はじめにNVIDIAのドライバーをインストールした記憶が蘇ってきた。

追記

$ sudo apt dist-upgrade

したのが原因かな

追記2

GPU の確認。

lspci | grep -i nvidia