基于该文章主要是一些经验总结(如果能算经验的话....);
1、前言:
硬件详情:笔记本电脑(rtx4060)+外接显示器
安装完ubuntu22后,外接显示屏发现啥也没发生;输入nvidia-smi没反应
2、安装最新驱动:
一开始是# 卸载驱动
# 卸载驱动
sudo apt-get --purge remove nvidia*
sudo apt autoremove
sudo apt-get --purge remove "*nvidia*"
然后使用
ubuntu-drivers devices
得到
== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
modalias : pci:v000010DEd000028E0sv0000103Csd00008BABbc03sc00i00
vendor : NVIDIA Corporation
driver : nvidia-driver-525-server - distro non-free
driver : nvidia-driver-535 - distro non-free recommended
driver : nvidia-driver-525 - distro non-free
driver : nvidia-driver-545-open - distro non-free
driver : nvidia-driver-535-open - distro non-free
driver : nvidia-driver-525-open - distro non-free
driver : nvidia-driver-535-server - distro non-free
driver : nvidia-driver-535-server-open - distro non-free
driver : nvidia-driver-545 - distro non-free
driver : xserver-xorg-video-nouveau - distro free builtin
按照recommend的driver安装,然后屁也没发生,;输入nvidia-smi还是原样;按照
https://blog.youkuaiyun.com/m0_63252914/article/details/134400519
说的运行
sudo modprobe nvidia
# 用于加载和卸载NVIDIA设备驱动程序。nvidia-modprobe的作用是
# 加载或卸载用于支持NVIDIA GPU的内核模块。通过执行nvidia-modprobe命令,
# 系统会加载与NVIDIA GPU相关的内核模块,使得系统能够正常识别和使用NVIDIA GPU。
还是屁也没发生;
3、解决:
3.1:安装驱动
进入Nvidia驱动官网官方驱动 | NVIDIA 下载官方驱动,然后sudo bash 运行后,它说找不到对应的kernel-source,但之前初装ubuntu的安装的linux6.2内核可以找到kernel-source可以安装驱动;
强迫症发作就是想要在linux6.6内核中安装驱动.....查了半天说在/usr/src/kernel下面。。。emmm完全没有这个东西,只有显示这些,指定其中一个文件夹后发现也没用;
linux-headers-6.1.81-060181 linux_source
linux-headers-6.2.0-36-generic nvidia-535.161.07
linux-headers-6.6.21-060621 nvidia-550.54.14
linux-hwe-6.2-headers-6.2.0-36 python3.10
又查了半天说是在/lib/modules下面指定对应内核,然后发现这些文件夹;
指定文件夹后说:
The kernel header file
'/lib/modules/6.6.21-060621-generic/include/linux/kernel.h' does not
exist. The most likely reason for this is that the kernel source
path '/lib/modules/6.6.21-060621-generic' is incorrect. 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.
我之前是按照 How to change your Ubuntu Kernel? | E2E Networks documentation 安装的linux内核,然后发现之前原生安装的内核里面的文件夹有build文件夹且文件容量大很多,也就是说其他那些文件夹没有进行make(那他们都去哪了....);
然后我按照How To Build Linux Kernel {Step-By-Step} | phoenixNAP KB 来重新安装linux内核,一步一步....最后得到的/lib/modules/下的6.6.21文件夹里面有build....然后指定对应的kernel-source-path,最后安装成功.....输入nvidia-smi后有显示;
然后成功显示了两个屏幕,然后重启,然后只有外接的显示屏有显示....笔记本的显示屏反而没了,拔了显示器接口后,干脆就黑屏.....wtf...
3.2配置文件修改:
参考了这篇文章https://blog.youkuaiyun.com/m0_63252914/article/details/134400519
3.2.1查看显卡:
:/usr/src$ lspci | grep VGA
00:02.0 VGA compatible controller: Intel Corporation Device a788 (rev 04)
01:00.0 VGA compatible controller: NVIDIA Corporation Device 28e0 (rev a1)
3.2.2修改Xorg配置文件;
输入
Section "Device"
Identifier "Device0"
Driver "modesetting"
VendorName "Intel Corporation"
BusID "PCI:00:02:0"
EndSection
Section "Device"
Identifier "Device1"
Driver "nvidia"
VendorName "Nvidia Corporation"
BusID "PCI:1:0:0"
EndSection
终于可以两个显示器显示了....nmd终于搞定了(大概?)对linux实在不太熟悉