plex2

intel

參考來源

Intel Gpu
https://gist.github.com/scyto/e4e3de35ee23fdb4ae5d5a3b85c16ed3

Host

安裝

1
2
apt update && apt install pve-headers-$(uname -r)
apt install git sysfsutils dkms build-* unzip -y

新增 apt sources.list intel non-free

1
nano /etc/apt/sources.list

添加以下

1
2
3
4
5
#non-free firmwares
deb http://deb.debian.org/debian bookworm non-free-firmware

#non-free drivers and components
deb http://deb.debian.org/debian bookworm non-free

存檔後執行

1
apt update && apt install intel-media-va-driver-non-free intel-gpu-tools vainfo

複製 proxmox 安裝中缺少的驅動程式,並將在 dmesg 中刪除此檔的 -2 錯誤

1
2
3
wget -r -nd -e robots=no -A '*.bin' --accept-regex '/plain/' https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/i915/adlp_dmc.bin

cp adlp_dmc.bin /lib/firmware/i915/

編譯並安裝新驅動程式
克隆 github 專案

1
2
cd ~
git clone https://github.com/strongtz/i915-sriov-dkms.git

修改 dkms.conf

1
2
cd i915-sriov-dkms
nano dkms.conf

更改這兩行,如下所示:

1
2
PACKAGE_NAME="i915-sriov-dkms"
PACKAGE_VERSION="6.5"

保存檔案
編譯和安裝驅動程式

1
2
3
cd ~
mv i915-sriov-dkms/ /usr/src/i915-sriov-dkms-6.5
dkms install --force -m i915-sriov-dkms -v 6.5

驗證模組是否已安裝

1
dkms status

卸載 dkms i915

1
dkms remove i915-sriov-dkms/6.5

修改 grub

1
nano /etc/default/grub

修改這一行,如原本有其他新增,保持原本的不變,新增上去

1
GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on iommu=pt i915.enable_guc=3 i915.max_vfs=7"

存檔退出,更新grub

1
2
3
4
update-grub
update-initramfs -u
#or
update-initramfs -c -k all

如update-initramfs -u
出現以下錯誤

1
2
3
W: Possible missing firmware /lib/firmware/i915/mtl_gsc_102.0.0.1511.bin for module i915
W: Possible missing firmware /lib/firmware/i915/mtl_huc_8.4.3_gsc.bin for module i915
W: Possible missing firmware /lib/firmware/i915/mtl_guc_70.6.4.bin for module i915

https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/i915/

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
cd ~ && mkdir less && cd less
wget https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/i915/mtl_huc_gsc.bin -O mtl_huc_8.4.3_gsc.bin
wget https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/i915/mtl_guc_70.bin -O mtl_guc_70.6.4.bin
wget https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/i915/mtl_gsc_1.bin -O mtl_gsc_102.0.0.1511.bin

cp mtl_gsc_102.0.0.1511.bin mtl_huc_8.4.3_gsc.bin mtl_guc_70.6.4.bin /lib/firmware/i915/
###以下未優化

cd ~;mkdir less;cd less

wget https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/i915/mtl_huc_gsc.bin
cp mtl_huc_gsc.bin mtl_huc_8.4.3_gsc.bin
wget https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/i915/mtl_guc_70.bin
cp mtl_guc_70.bin mtl_guc_70.6.4.bin
wget https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/i915/mtl_gsc_1.bin
cp mtl_gsc_1.bin mtl_gsc_102.0.0.1511.bin

cp mtl_gsc_102.0.0.1511.bin /lib/firmware/i915/
cp mtl_huc_8.4.3_gsc.bin /lib/firmware/i915/
cp mtl_guc_70.6.4.bin /lib/firmware/i915/

補完驅動

1
2
3
update-initramfs -u
#or
update-initramfs -c -k all

zfs uefi

1
nano /etc/kernel/cmdline

修改

1
root=ZFS=rpool/ROOT/pve-1 boot=zfs intel_iommu=on iommu=pt i915.enable_guc=3 i915.max_vfs=7

查找PCIe總線並更新 sysfs.conf

1
lspci | grep VGA

各代intel cpu 支援的gpu虛擬化列表
https://www.intel.com.tw/content/www/tw/zh/support/articles/000093216/graphics/processor-graphics.html
只有10代以上支援VGPU
應該輸出

1
00:02.0 VGA compatible controller: Intel Corporation CoffeeLake-H GT2 [UHD Graphics 630] (rev 02)

取最左邊的數組,並按如下方式添加到 sysfs.conf 中
注意,總線路徑上的所有後續零都是必需的

1
echo "devices/pci0000:00/0000:00:02.0/sriov_numvfs = 7" > /etc/sysfs.conf

存檔退出 reboot

檢查設備

1
dmesg | grep i915

最後兩行應如下所示:

1
2
[    7.591662] [drm] Initialized i915 1.6.0 20201103 for 0000:00:02.7 on minor 7
[    7.591818] i915 0000:00:02.0: Enabled 7 VFs

如果沒有輸出,請仔細檢查所有步驟
使用 VAInfo 進行驗證
/cardN N為0-7(VGPU編號),平台不同數量不同 10代1 13代7

1
vainfo --display drm --device /dev/dri/cardN

檢查是否可以監控 VF 如果沒有,有問題

1
2
3
intel_gpu_top -d drm:/dev/dri/renderD128

ls -l /dev/dri

在 Proxmox 中配置 vGPU 池
Datacenter(資料中心) > Resource Mappings
按兩下PCI設備add
將池命名為vGPU-Pool
映射 pve 1 的所有 7 個 VF,但不映射根設備,即 0000:00:02.x 而不是 0000:00:02
點擊create
在創建的池 lcikc 上,vGPU-Pool 旁邊的加號按鈕
選擇節點上的映射 = PVE 2,AD 所有設備,然後按兩下創建
對 PVE3 重複上述步驟

注意:具有PCI直通設備的計算機無法即時遷移,必須將其關閉,離線遷移到新節點,然後啟動

每次在PROXMOX中更新內核時,都應該執行以下操作
update the kernel using proxox ui

1
2
dkms install -m i915-sriov-dkms -v 6.5 --force
reboot

在不帶 vGPU 的情況下啟動VM,並將顯示設置為預設值 安裝 VirtIO 驅動程式 關閉虛擬機並將顯示更改為 VirtIO-GPU 將CPU類型更改為“host” 現在將 vGPU 池添加為 PCI 設備 創建 VM 時,添加 PCI 設備並添加 poool,如下所示: 現在啟動到 VM 並安裝英特爾提供的最新 IrisXe 驅動程式 現在,無論通過 webcolse VNC、SPICE 還是 RDP 用戶端連接,都應該有圖形加速

按照指南操作,在設備管理器中看到
Microsoft 基本顯示適配器 - 如果在 VM 設置中使用“顯示”
Intel iGPU - 直通
有 2 個(或更多)選項來使用 iGPU。因為 Windows 11 自行決定使用哪種圖形

編輯windiws11 VM conf 檔並添加

1
args: -cpu Cooperlake,hv_relaxed,hv_spinlocks=0x1fff,hv_vapic,hv_time,+vmx

舊 cpu 6-10

直通包括獨顯+開啟內顯GVT-G
https://home.gamer.com.tw/creationDetail.php?sn=5516262

开启iommu和GVT-g支持
https://www.xh86.me/?p=741

1
nano /etc/kernel/cmdline

不要換行,往後加指令

1
root=ZFS=rpool/ROOT/pve-1 boot=zfs intel_iommu=on iommu=pt pcie_acs_override=downstream video=efifb:off,vesafb:off i915.enable_guc=3 i915.max_vfs=2

指令解釋:
intel_iommu=on
最白話的設定,開啟IOMMU
iommu=pt
聽說是加強IOMMU的性能,也有人說不加也沒差,因為懶得比較,我就沒拿掉
pcie_acs_override=downstream
這個似乎是加強PCIE裝置的分組,我個人理解是:
沒加這行=分組後直通顯卡會包含繪圖裝置跟聲音裝置,直通一個另一個會跟著被直通
加入這行=分組後可以把繪圖裝置跟聲音裝置分別直通給不同VM
video=efifb:off,vesafb:off
包刮了video的兩個設定:
efifb:off是efi開機後載入fb0的設定,off的話當然就是不要開啟啦XD
vesafb:off是vesa程序載入fb0的設定,我也不知道是啥,反正很多人在直通時把這行也加上去了,沒試過不加,總之就跟著加了,也是設定不要開啟

modprobe.d裡面的conf檔做設定

1
nano /etc/modprobe.d/user.conf

檔案內容,直接用註解的方式解釋每個在做啥:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# 黑名單,不讓程式開機就載入下面的驅動程式,顯卡才能夠直通
# A卡的驅動,我不想改就沒拿掉了
# N卡的linux內建基本驅動
# N卡的驅動
# 主機板聲音卡的驅動程式
# blacklist to stop driver loading
blacklist radeon
blacklist nouveau
blacklist nvidia
blacklist snd_hda_intel

# code43迴避方式
# 聽說VM會出現code 43,是由於顯卡知道自己在虛擬環境而發error
# 用下面的指令讓顯卡不發error
# 不確定,總之我是這樣認為~
# kvm config to avoid code 43
options kvm ignore_msrs=1
#options report_ignored_msrs=0
#報錯修改為下面
options kvm report_ignored_msrs=N

# 允許vfio模組發出中斷,應該是這樣
# 因為之後會載入去給PCIE裝置,這邊要設定允許
# IOMMU interrupts
options vfio_iommu_type1 allow_unsafe_interrupts=1

# GVT-G配置
# gvt: 看自己要不要玩GVT-G,要=1,不要=0
# guc: 是否開啟低功耗什麼的,有GVT-G只能=0,否則想開=2/3 (3要看CPU是否支援huc)
# INTEL Graphic config
options i915 enable_gvt=1
#options i915 enable_guc=0

# 設定ZFS只能使用這麼多記憶體
# 設定邏輯就是預設2G + ((儲存空間每1T)=1G) * (16+1+1) = 20G,然後換算成byte
# ZFS config
#options zfs zfs_arc_max=21474836480

此篇結束!

Xeon e3 v5-6 core 5-7

參考
https://www.xh86.me/?p=741
intel gvt-g技術,目前只支援第五代,第六代和第七代英特爾core處理器以及E3 v4,E3 v5和E3 v6 Xeon處理器
開啟iommu和GVT-g 參考2
https://cetteup.com/216/how-to-use-an-intel-vgpu-for-plexs-hardware-accelerated-streaming-in-a-proxmox-vm/

1
2
3
4
#grub
nano /etc/default/grub
#or zfs uefi
nano /etc/kernel/cmdline

修改

1
2
3
4
#grub
GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=on i915.enable_gvt=1"
#zfs uefi
root=ZFS=rpool/ROOT/pve-1 boot=zfs intel_iommu=on iommu=pt i915.enable_gvt=1

增加直通内核模塊

1
2
3
4
5
echo vfio >> /etc/modules
echo vfio_iommu_type1 >> /etc/modules
echo vfio_pci >> /etc/modules
echo vfio_virqfd >> /etc/modules
echo kvmgt >> /etc/modules

查看顯卡編號(示例:編號需修改成自己的)

1
2
lspci -n -s 00:02.0
00:02.0 0380: 8086:3e90

將 8086:3e90 加入直通

1
echo "options vfio-pci ids=8086:3e90" > /etc/modprobe.d/vfio.conf

更新grub與開機載入模塊

1
2
update-grub
update-initramfs -c -k all

驗證 (02為intel gpu 如不同換成設備編號)

1
ls /sys/bus/pci/devices/0000:00:02.0/mdev_supported_types/



Licensed under CC BY-NC-SA 4.0
Built with Hugo
Theme Stack designed by Jimmy