安装好exsi以后,找到管理----硬件-----PCI设备,勾选想要直通的显卡,然后点击“切换直通”
切换以后可以看到列表中的直通列显示为活动就对了。
然后编辑虚拟机设置,CPU关闭硬件虚拟化(向客户机操作系统公开硬件辅助的虚拟化)
内存勾选锁定(预留所有客户机内存,全部锁定)
,虚拟机选项----引导选项-----关闭UEFU安全引导(这个必须要关,很重要)
添加其他设备-------PCI设备,在配置界面的最底部会多出来一个“新PCI设备”,选择想要直通的设备,
依次添加想要直通的显卡
看其他文章建议,将声卡也一块加进去,那就把声卡也加进去避免出现未知问题。下图是我正常工作以后的截图:
我这里安装的是ubuntu 22.04,内核是5.19.0-32,安装过程中不要勾选(安装第三方显卡或WIFI 驱动那个复选框),安装完系统以后在安装英伟达驱动前务必先apt update更新包,再apt upgrade升级所有包,特别是和核心有关的包都升级到最新版以后再开始安装英伟达驱动。
参考文章:https://linuxconfig.org/how-to-install-the-nvidia-drivers-on-manjaro-linux
Nvidia-smi "No devices were found" - VMWare ESXI Ubuntu Server 20.04.03 with RTX3070 - #38 by frostywite - Linux - NVIDIA Developer Forums
到Official Drivers | NVIDIA 这里下载对应的设备驱动.run文件,之前英伟达官方网站的deb安装方式不行,没法加参数-m =kernel-open去安装驱动,不是虚拟机下面的没问题,虚拟化下面的目前看只能通过.run文件加参数-m=kernel-open安装。
按照下面的方法进行安装:
sudo apt install libglvnd-core-dev libglvnd-dev build-essential
先执行一遍.run文件,目的是按照提示让驱动程序去创建/etc/modprobe.d/blacklist-nvidia-nouveau.conf这些文件,上传下载得到的.run文件到ubuntu 22,chmod +x 赋予可执行权限,然后
./NVIDIA-Linux-x86_64-550.107.02.run -m=kernel-open
如果安装的是ubuntu server系统,按照提示直接安装完reboot就可以用了,如下:
如果是ubuntu desktop,需要按照下面的方法安装
nano /etc/modprobe.d/blacklist-nvidia-nouveau.conf
blacklist nouveau
options nouveau modeset=0
nano /etc/modprobe.d/nvidia.conf
options nvidia NVreg_OpenRmEnableUnsupportedGpus=1
sudo update-initramfs -u
Reboot
上传下载得到的.run文件到ubuntu 22,chmod +x 赋予可执行权限,然后
./NVIDIA-Linux-x86_64-550.107.02.run -m=kernel-open
所有能选择yes的都选择yes,安装完成以后reboot,执行nvidia-smi,可以看到下面的画面:
-----------------------------------------------------------------------------------------------------------------------------
下面的资料是来回折腾尝试配置的时候的资料,不用看了,按照上面的方法安装就可以用了。
1. Go to: /etc/modprobe.d/
2. Make a file: blacklist-nvidia-nouveau.conf
3. Put this in the file:
blacklist nouveau
options nouveau modeset=0
4. Make a other “nvidia.conf” file and put this in the file: options nvidia NVreg_OpenRmEnableUnsupportedGpus=1
5. Updat kernel init ram fs: sudo update-initramfs -u
6. Reboot
7. Go to the Nvidia site to the page to download the driver that you want.
8. Copy the URL of the download butten and past it behind wget to download it to the current folder
9. Sudo chmod 700 the file
10. Run the install file: sudo .\filename.run
a. For open source: sudo .\filename.run -m=kernel-open
b. Watch out! See that the nvidia.conf file exist in the modprobe folder and you have rebooted (and run the update-initramfs commando). Then only the GTX/RTX/QUADRO cards wil work!
11. After the instalation reboot the server
12. Test with nvidia-smi
13. Great succes!
pciPassthru.use64bitMMIO配置为TRUE
VMkernel.Boot.disableACSCheck配置为TRUE
pciPassthru.64bitMMIOSizeGB配置为64 #我这里测试没有配置这个也能工作
nano /etc/modprobe.d/blacklist.conf 在文件的最后添加以下内容后重启
blacklist nouveau
blacklist rivafb
blacklist nvidiafb
blacklist rivatv
blacklist nv
如果你前面的步骤没有禁用uefi安全启动,安装驱动的时候会有下面的提示:会要求你输入两遍密码,记住输入的密码,过一会重启以后要用。
重启以后会出现下面这样的界面,选择第二个Enroll MOK,选择continue,一直到要你输入密码后reboot
都安装好以后如果提示找不到设备,可以敲以下命令进行排查
nvidia-smi 这个现在我执行是提示没有设备
root@vgpu1:~# lspci | grep NVIDIA
03:00.0 VGA compatible controller: NVIDIA Corporation GA102 [GeForce RTX 3090] (rev a1)
03:00.1 Audio device: NVIDIA Corporation GA102 High Definition Audio Controller (rev a1)
03:01.0 VGA compatible controller: NVIDIA Corporation GA102 [GeForce RTX 3090] (rev a1)
03:01.1 Audio device: NVIDIA Corporation GA102 High Definition Audio Controller (rev a1)
root@vgpu1:~# lsmod | grep nvidia
nvidia_uvm 4677632 0
nvidia_drm 98304 0
nvidia_modeset 1343488 1 nvidia_drm
nvidia 54030336 2 nvidia_uvm,nvidia_modeset
drm_kms_helper 200704 2 vmwgfx,nvidia_drm
drm 581632 8 vmwgfx,drm_kms_helper,nvidia,drm_ttm_helper,nvidia_drm,ttm
root@vgpu1:~# dmesg | grep nvidia
[ 6.244921] audit: type=1400 audit(1723624822.923:4): apparmor="STATUS" operation="profile_load" profile="unconfined" name="nvidia_modprobe" pid=785 comm="apparmor_parser"
[ 6.244926] audit: type=1400 audit(1723624822.923:5): apparmor="STATUS" operation="profile_load" profile="unconfined" name="nvidia_modprobe//kmod" pid=785 comm="apparmor_parser"
[ 6.898620] nvidia: loading out-of-tree module taints kernel.
[ 6.898632] nvidia: module license 'NVIDIA' taints kernel.
[ 7.046885] nvidia-nvlink: Nvlink Core is being initialized, major device number 236
[ 7.048732] nvidia 0000:03:00.0: enabling device (0000 -> 0003)
[ 7.049766] nvidia 0000:03:00.0: vgaarb: changed VGA decodes: olddecodes=io+mem,decodes=none:owns=none
[ 7.099483] nvidia 0000:03:01.0: enabling device (0000 -> 0003)
[ 7.100327] nvidia 0000:03:01.0: vgaarb: changed VGA decodes: olddecodes=io+mem,decodes=none:owns=none
[ 7.220493] nvidia-modeset: Loading NVIDIA Kernel Mode Setting Driver for UNIX platforms 550.54.15 Tue Mar 5 21:59:57 UTC 2024
[ 7.257032] [drm] [nvidia-drm] [GPU ID 0x00000300] Loading driver
[ 8.143173] [drm:nv_drm_load [nvidia_drm]] *ERROR* [nvidia-drm] [GPU ID 0x00000300] Failed to allocate NvKmsKapiDevice
[ 8.143332] [drm:nv_drm_register_drm_device [nvidia_drm]] *ERROR* [nvidia-drm] [GPU ID 0x00000300] Failed to register device
[ 8.143448] [drm] [nvidia-drm] [GPU ID 0x00000301] Loading driver
[ 9.024981] [drm:nv_drm_load [nvidia_drm]] *ERROR* [nvidia-drm] [GPU ID 0x00000301] Failed to allocate NvKmsKapiDevice
[ 9.025120] [drm:nv_drm_register_drm_device [nvidia_drm]] *ERROR* [nvidia-drm] [GPU ID 0x00000301] Failed to register device
[ 9.111670] nvidia_uvm: module uses symbols nvUvmInterfaceDisableAccessCntr from proprietary module nvidia, inheriting taint.
[ 9.141323] nvidia-uvm: Loaded the UVM driver, major device number 234.
root@vgpu1:~# lshw -c video
*-display
description: VGA compatible controller
product: SVGA II Adapter
vendor: VMware
physical id: f
bus info: pci@0000:00:0f.0
logical name: /dev/fb0
version: 00
width: 32 bits
clock: 33MHz
capabilities: vga_controller bus_master cap_list rom fb
configuration: depth=32 driver=vmwgfx latency=64 resolution=1176,885
resources: irq:16 ioport:840(size=16) memory:f0000000-f7ffffff memory:ff000000-ff7fffff memory:c0000-dffff
*-display:0
description: VGA compatible controller
product: GA102 [GeForce RTX 3090]
vendor: NVIDIA Corporation
physical id: 0
bus info: pci@0000:03:00.0
version: a1
width: 64 bits
clock: 33MHz
capabilities: pm msi pciexpress vga_controller bus_master cap_list
configuration: driver=nvidia latency=248
resources: irq:17 memory:fc000000-fcffffff memory:c0000000-cfffffff memory:d2000000-d3ffffff ioport:d80(size=128)
*-display:1
description: VGA compatible controller
product: GA102 [GeForce RTX 3090]
vendor: NVIDIA Corporation
physical id: 26
bus info: pci@0000:03:01.0
version: a1
width: 64 bits
clock: 33MHz
capabilities: pm msi pciexpress vga_controller bus_master cap_list
configuration: driver=nvidia latency=248
resources: irq:18 memory:fb000000-fbffffff memory:b0000000-bfffffff memory:d0000000-d1ffffff ioport:d00(size=128)
root@vgpu1:~# lspci | grep NVIDIA
03:00.0 VGA compatible controller: NVIDIA Corporation GA102 [GeForce RTX 3090] (rev a1)
03:00.1 Audio device: NVIDIA Corporation GA102 High Definition Audio Controller (rev a1)
03:01.0 VGA compatible controller: NVIDIA Corporation GA102 [GeForce RTX 3090] (rev a1)
03:01.1 Audio device: NVIDIA Corporation GA102 High Definition Audio Controller (rev a1)
sudo journalctl -b
如果需要卸载旧的驱动或者删除有问题的驱动,可以尝试将下面的内容存为shell 脚本去执行
sudo nvidia-uninstall
sudo apt purge -y '^nvidia-*' '^libnvidia-*'
sudo rm -r /var/lib/dkms/nvidia
sudo apt -y autoremove
sudo update-initramfs -c -k `uname -r`
sudo update-grub2
read -p "Press any key to reboot... " -n1 -s
sudo reboot