ESXI版本:8.0 Update 3
显卡型号:Nvidia 2060(8GB版本)
操作系统版本:Ubuntu24.04
- 关键问题1:ESXI的直通显卡设置
这里我们使用的是ESXI 8.0版本,直通设置需要单独在【导航器】-【主机】-【管理】-【硬件】-【PCI设备】这里做切换,拉到下面找到这个显卡硬件,需要“切换直通”
- 关键问题2:虚拟机的设置,以及相关的参数设置
- 虚拟机选项】-【引导选项】,这里必须设置为不启用UEFI安全引导,把勾去掉。或者干脆直接选“BIOS”,否则驱动程序可能由于安全保护机制导致安装失败(这个主要是为了保护内核安全的设置,这里必须去掉)
在ubuntu里面,可以用这个命令确认一下,你当前是否是内核保护状态,如果是enabled,则是,这种状态可能导致驱动程序安装不成功:
mokutil --sb-state
如果是显示:SecureBoot enabled,那么这种有可能是不行的;
如果显示: SecureBoot disabled,那么这种可以;
- 【虚拟机选项】-【高级】-【配置参数】,这里必须添加如下参数:
hypervisor.cpuid.v0 False
pciPassthru.use64bitMMIO True
pciPassthru.64bitMMIOSizeGB 32 (单张显卡,值为32;如果是多张显卡,设置值为64。)
关键问题3:ubuntu屏蔽nouveau,以及驱动安装相关的一些操作
- (1)编辑blacklist.conf文件:
sudo vim /etc/modprobe.d/blacklist.conf
末尾添加如下代码:
blacklist nouveau
options nouveau modeset=0
- 编辑nvidia.conf文件
sudo vim /etc/modprobe.d/nvidia.conf
末尾添加如下代码:
options nvidia NVreg_OpenRmEnableUnsupportedGpus=1
- 更新以上配置生效
sudo update-initramfs -u
- 重启机器
# sudo reboot
- 检查是否生效:如果执行以下命令没有任何输出,那么就代表成功屏蔽了nouveau
lsmod |grep nouveau
----END
关键问题4:安装驱动
- 提示如下错误需要关闭
关闭gdm服务:
# systemctl stop gdm
- 再安装驱动就简单了,可以从官网下载对应的驱动版本 ,然后传到Ubuntu上面来,执行安装命令即可(找驱动和上传文件的步骤就不赘述了):
- 安装编译开发工具
sudo apt install build-essential pkg-config libglvnd-dev
该步骤安装的gcc版本可能和kernel编译用的gcc版本不匹配从而导致,显卡驱动安装失败,需要参考如下页面处理该问题
“ubuntu安装nvidia显卡驱动提示An error occurred while performing the step: “Building kernel modules“.”
- 安装nvida显卡驱动
sudo chmod +x NVIDIA-Linux-x86_64-550.135.run
sudo ./NVIDIA-Linux-x86_64-550.135.run -m=kernel-open
sudo ./NVIDIA-Linux-x86_64-550.135.run -no-x-check -no-nouveau-check -no-opengl-files -m=kernel-open
Would you like to run the nvidia-xconfig utility to automatically update your X configuration file so that the
NVIDIA X driver will be used when you restart X? Any pre-existing X configuration file will be backed up.
选择
安装驱动过程中遇到的问题:
1.If you plan to no longer use the NVIDIA deriver, you should make sure that no X screens are configured to use the NVIDIA X driver X driver in your X configuration file. If you used nvidia-xconfig to configure X, it may have created a backup of your original configuration. Would you like to run 'nvidia-xconfig --restore-original-backup' to attempt restoration of the original X configuration file?
no
2.Would you like to run the nvidia-xconfig utility to automatically updata your X onfiguration file so that the NVIDIA X driver will be used when you restart X? Any pre-existing X configuration file will be backed up.
yes
3.Would you like to register the kernel module souces with DKMS? This will allow DKMS to automatically build a new module, if you install a different kernel later?
no
Installation of the NVIDIA Accelerated Graphics Driver for Linux-x86_64 (version: 550.135) is now complete.
Please update your xorg.conf file as appropriate; see the file /usr/share/doc/NVIDIA_GLX-1.0/README.txt for
details.
- 重启虚拟机,检查终于出来了
# nvida-smi