daemonfreaks.com

FreeBSDでeGPUを使う

posted by jun-g at Sun, 28 May 2023 10:30 JST

先日購入したIntel NUC13 Pro のセットアップ続き、その2。

NUC13はThunderbolt4をサポートしていて、かつFreeBSDもThunderboltをサポートしていて、そして手元に都合良くNVIDIA RTX3060の入ったeGPUがあります。ということで内蔵GPUがサポートされるまでこれを使います。

まずは準備。ドライバーをインストールして起動時にカーネルモジュールを読み込む用にセット。

$ su -
Password:
# pkg install nvidia-driver
...
# sysrc kld_list=nvidia-modeset

再起動した後のdmesg。

# dmesg|grep nvidia
nvidia1: <NVIDIA GeForce RTX 3060> on vgapci1
vgapci1: child nvidia1 requested pci_enable_io
vgapci1: child nvidia1 requested pci_enable_io
nvidia-modeset: Loading NVIDIA Kernel Mode Setting Driver for UNIX platforms  515.86.01  Wed Oct 26 08:52:34 UTC 2022

eGPUは無事に認識されました。が、コンソールは引き続きNUC13本体から接続したモニター上に表示されてます。

次にXの設定。先日作ったscfbを使う設定ファイルを退避して起動してみます。

# cd /usr/local/etc/X11/xorg.conf.d
# mv driver-scfb.conf driver-scfb.conf.bak
# startx

が、起動しません…。 Handbookのビデオカードの設定ページ を読むと:

1つ以上のビデオカードが存在する場合には、 BusID 行のコメントを外し、 希望するカードを選択するように設定できます。 ビデオカードバス ID は、 pciconf -lv | grep -B3 display で表示できます。

と書いてありましたので、その通りにします。

# pciconf -lv | grep -B3 display
vgapci0@pci0:0:2:0: class=0x030000 rev=0x04 hdr=0x00 vendor=0x8086 device=0xa7a0 subvendor=0x8086 subdevice=0x3037
    vendor     = 'Intel Corporation'
    device     = 'Raptor Lake-P [Iris Xe Graphics]'
    class      = display
--
vgapci1@pci0:4:0:0: class=0x030000 rev=0xa1 hdr=0x00 vendor=0x10de device=0x2504 subvendor=0x10de subdevice=0x2504
    vendor     = 'NVIDIA Corporation'
    device     = 'GA106 [GeForce RTX 3060 Lite Hash Rate]'
    class      = display

この情報を使ってX用の以下のファイルを作成。

# cat /usr/local/etc/X11/xorg.conf.d/driver-nvidia.conf
Section "Device"
    Identifier    "Device0"
    Driver        "nvidia"
    VendorName    "NVIDIA COrporation"
    BoardName     "NVIDIA GeForce RTX 3060"
    BusId         "PCI:4:0:0"
EndSection

でstartxすると、無事にXが起動し、eGPUに接続したモニター上に表示されました!

続く…。

Raptor LakeのIris Xeグラフィックスは13Rのdrm-kmodではまだサポートされてない

posted by jun-g at Sat, 27 May 2023 17:30 JST

先日購入したIntel NUC13 Pro のセットアップ続き。

書きたかったことはタイトルの通りで、1世代前のAlder LakeのGPUも まだサポートされてなさそう

14-CURRENTだと Alder Lakeはサポートされていそう

とりあえずDRMは一旦諦めて、以下のファイルを作成してXは起動できるようになりました。

$ cat /usr/loca/etc/X11/xorg/conf.d/driver-scfb.conf
Section "Device"
    Identifier    "Card0"
    Driver        "scfb"
EndSection

続く…。

Intel NUC13 Pro購入

posted by jun-g at Mon, 22 May 2023 09:50 JST

一昨年にCPUを入れ替えつつ 2014年に作った自作PCをずっと使っていましたが、ATXケースが大きく場所を取るのでもう少し省スペースなPCにしたいなと思っていたところ、 IntelのNUC 13 Pro が売っていたので購入しました。

購入したのはCore i7 CPUが載ったキットなので、あわせてメモリやストレージも購入しました。スペックはこんな感じです。

キット Intel NUC13ANHi7
CPU Intel Core i7 1360P
メモリ Kingston FURY Impact DDR4-3200 32GBx2
NVMe Western Digital WD_BLACK SN850X 1TB
SSD Samsung SSD 870 QVO 4TBi

13世代CoreなのでメモリはDDR5が良かったですが、そうすると今のところNUC 13 Extremeしか選択肢がなく、Extremeはちょっと大きすぎるのでそこは妥協しました。

実際手元に届いて、想像したよりももっと小さくてビックリしました。旧PCのケースはWINDy製でずっと使うつもりでしたが、こんなに小さくて済むならタワー型PCはもうイラネという感じ…。


さて、キットなのでOSも自分で選んでインストールする必要があります。

最近はもっぱらWindows11(+WSL)のラップトップで生活しているし、仕事ではDockerやK8S使う機会も多いので、デスクトップが使えつつコンテナも動くOSが良いですね。

…ということでFreeBSD 13.2をインストールしました。要件は満たしているはず。

dmesgはこんな感じです。

Copyright (c) 1992-2021 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 13.2-RELEASE releng/13.2-n254617-525ecfdad597 GENERIC amd64
FreeBSD clang version 14.0.5 (https://github.com/llvm/llvm-project.git llvmorg-14.0.5-0-gc12386ae247c)
VT(efifb): resolution 3840x2160
CPU: 13th Gen Intel(R) Core(TM) i7-1360P (2611.20-MHz K8-class CPU)
  Origin="GenuineIntel"  Id=0xb06a2  Family=0x6  Model=0xba  Stepping=2
  Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE>
  Features2=0x7ffafbff<SSE3,PCLMULQDQ,DTES64,MON,DS_CPL,VMX,SMX,EST,TM2,SSSE3,SDBG,FMA,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,TSCDLT,AESNI,XSAVE,OSXSAVE,AVX,F16C,RDRAND>
  AMD Features=0x2c100800<SYSCALL,NX,Page1GB,RDTSCP,LM>
  AMD Features2=0x121<LAHF,ABM,Prefetch>
  Structured Extended Features=0x239c27eb<FSGSBASE,TSCADJ,BMI1,AVX2,FDPEXC,SMEP,BMI2,ERMS,INVPCID,NFPUSG,RDSEED,ADX,SMAP,CLFLUSHOPT,CLWB,PROCTRACE,SHA>
  Structured Extended Features2=0x984007bc<UMIP,PKU,OSPKE,WAITPKG,GFNI,VAES,VPCLMULQDQ,RDPID,MOVDIRI,MOVDIR64B>
  Structured Extended Features3=0xfc18c410<FSRM,MD_CLEAR,IBT,IBPB,STIBP,L1DFL,ARCH_CAP,CORE_CAP,SSBD>
  XSAVE Features=0xf<XSAVEOPT,XSAVEC,XINUSE,XSAVES>
  IA32_ARCH_CAPS=0x88fd6b<RDCL_NO,IBRS_ALL,SKIP_L1DFL_VME,MDS_NO,TAA_NO>
  VT-x: PAT,HLT,MTF,PAUSE,EPT,UG,VPID,VID,PostIntr
  TSC: P-state invariant, performance statistics
real memory  = 68717379584 (65534 MB)
avail memory = 66327597056 (63254 MB)
Event timer "LAPIC" quality 600
ACPI APIC Table: <INTEL NUCxi7A5>
FreeBSD/SMP: Multiprocessor System Detected: 16 CPUs
FreeBSD/SMP: Non-uniform topology
random: registering fast source Intel Secure Key RNG
random: fast provider: "Intel Secure Key RNG"
random: unblocking device.
ioapic0 <Version 2.0> irqs 0-119
Launching APs: 1 9 2 13 7 5 3 10 8 6 15 12 14 11 4
random: entropy device external interface
kbd0 at kbdmux0
efirtc0: <EFI Realtime Clock>
efirtc0: registered as a time-of-day clock, resolution 1.000000s
smbios0: <System Management BIOS> at iomem 0x59454000-0x5945401e
smbios0: Version: 3.5, BCD Revision: 3.5
aesni0: <AES-CBC,AES-CCM,AES-GCM,AES-ICM,AES-XTS,SHA1,SHA256>
acpi0: <INTEL>
acpi0: Power Button (fixed)
hpet0: <High Precision Event Timer> iomem 0xfed00000-0xfed003ff on acpi0
Timecounter "HPET" frequency 19200000 Hz quality 950
Event timer "HPET" frequency 19200000 Hz quality 350
Event timer "HPET1" frequency 19200000 Hz quality 340
Event timer "HPET2" frequency 19200000 Hz quality 340
Event timer "HPET3" frequency 19200000 Hz quality 340
Event timer "HPET4" frequency 19200000 Hz quality 340
Event timer "HPET5" frequency 19200000 Hz quality 340
Event timer "HPET6" frequency 19200000 Hz quality 340
Event timer "HPET7" frequency 19200000 Hz quality 340
attimer0: <AT timer> port 0x40-0x43,0x50-0x53 irq 0 on acpi0
Timecounter "i8254" frequency 1193182 Hz quality 0
Event timer "i8254" frequency 1193182 Hz quality 100
Timecounter "ACPI-fast" frequency 3579545 Hz quality 900
acpi_timer0: <24-bit timer at 3.579545MHz> port 0x1808-0x180b on acpi0
acpi_ec0: <Embedded Controller: GPE 0x6e> port 0x62,0x66,0x68,0x6c,0x6a,0x6e on acpi0
pcib0: <ACPI Host-PCI bridge> port 0xcf8-0xcff on acpi0
pci0: <ACPI PCI bus> on pcib0
vgapci0: <VGA-compatible display> port 0x3000-0x303f mem 0x6123000000-0x6123ffffff,0x4000000000-0x400fffffff at device 2.0 on pci0
vgapci0: Boot video device
pcib1: <ACPI PCI-PCI bridge> at device 6.0 on pci0
pci1: <ACPI PCI bus> on pcib1
nvme0: <Generic NVMe Device> mem 0x84400000-0x84403fff at device 0.0 on pci1
pcib2: <ACPI PCI-PCI bridge> at device 7.0 on pci0
pcib3: <ACPI PCI-PCI bridge> at device 7.2 on pci0
xhci0: <XHCI (generic) USB 3.0 controller> mem 0x6124190000-0x612419ffff at device 13.0 on pci0
xhci0: 32 bytes context size, 64-bit DMA
usbus0 on xhci0
usbus0: 5.0Gbps Super Speed USB v3.0
pci0: <serial bus, USB> at device 13.2 (no driver attached) pci0: <serial bus, USB> at device 13.3 (no driver attached)
xhci1: <Intel Alder Lake USB 3.2 controller> mem 0x6124180000-0x612418ffff at device 20.0 on pci0
xhci1: 32 bytes context size, 64-bit DMA
usbus1 on xhci1
usbus1: 5.0Gbps Super Speed USB v3.0
pci0: <memory, RAM> at device 20.2 (no driver attached)
pci0: <network> at device 20.3 (no driver attached)
pci0: <serial bus> at device 21.0 (no driver attached)
pci0: <serial bus> at device 21.1 (no driver attached)
pci0: <simple comms> at device 22.0 (no driver attached)
ahci0: <AHCI SATA controller> port 0x3090-0x3097,0x3080-0x3083,0x3060-0x307f mem 0x84500000-0x84501fff,0x84503000-0x845030ff,0x84502000-0x845027ff at device 23.0 on pci0
ahci0: AHCI v1.31 with 1 6Gbps ports, Port Multiplier not supported
ahcich1: <AHCI channel> at channel 1 on ahci0
pcib4: <ACPI PCI-PCI bridge> at device 29.0 on pci0
pci2: <ACPI PCI bus> on pcib4
igc0: <Intel(R) Ethernet Controller I226-V> mem 0x84200000-0x842fffff,0x84300000-0x84303fff at device 0. 0 on pci2
igc0: Using 1024 TX descriptors and 1024 RX descriptors
igc0: Using 4 RX queues 4 TX queues
igc0: Using MSI-X interrupts with 5 vectors
igc0: Ethernet address: 48:21:0b:56:9b:93
igc0: netmap queues/slots: TX 4/1024, RX 4/1024
isab0: <PCI-ISA bridge> at device 31.0 on pci0
isa0: <ISA bus> on isab0
hdac0: <Intel Raptor Lake-P HDA Controller> mem 0x61241b0000-0x61241b3fff,0x6124000000-0x61240fffff at device 31.3 on pci0
pci0: <serial bus> at device 31.5 (no driver attached)
acpi_button0: <Sleep Button> on acpi0
cpu0: <ACPI CPU> on acpi0
acpi_button1: <Power Button> on acpi0
acpi_tz0: <Thermal Zone> on acpi0
acpi_syscontainer0: <System Container> on acpi0
acpi_syscontainer1: <System Container> on acpi0
atrtc0: <AT realtime clock> at port 0x70 irq 8 on isa0
atrtc0: Warning: Couldn't map I/O.
atrtc0: registered as a time-of-day clock, resolution 1.000000s
Event timer "RTC" frequency 32768 Hz quality 0
atrtc0: non-PNP ISA device will be removed from GENERIC in FreeBSD 14.
hwpstate_intel0: <Intel Speed Shift> on cpu0
hwpstate_intel1: <Intel Speed Shift> on cpu1
hwpstate_intel2: <Intel Speed Shift> on cpu2
hwpstate_intel3: <Intel Speed Shift> on cpu3
hwpstate_intel4: <Intel Speed Shift> on cpu4
hwpstate_intel5: <Intel Speed Shift> on cpu5
hwpstate_intel6: <Intel Speed Shift> on cpu6
hwpstate_intel7: <Intel Speed Shift> on cpu7
hwpstate_intel8: <Intel Speed Shift> on cpu8
hwpstate_intel9: <Intel Speed Shift> on cpu9
hwpstate_intel10: <Intel Speed Shift> on cpu10
hwpstate_intel11: <Intel Speed Shift> on cpu11
hwpstate_intel12: <Intel Speed Shift> on cpu12
hwpstate_intel13: <Intel Speed Shift> on cpu13
hwpstate_intel14: <Intel Speed Shift> on cpu14
hwpstate_intel15: <Intel Speed Shift> on cpu15
Timecounter "TSC-low" frequency 1305602658 Hz quality 1000
Timecounters tick every 1.000 msec
ZFS filesystem version: 5
ZFS storage pool version: features support (5000)
ugen1.1: <Intel XHCI root HUB> at usbus1
uhub0 on usbus1
uhub0: <Intel XHCI root HUB, class 9/0, rev 3.00/1.00, addr 1> on usbus1
ugen0.1: <Intel XHCI root HUB> at usbus0
uhub1 on usbus0
uhub1: <Intel XHCI root HUB, class 9/0, rev 3.00/1.00, addr 1> on usbus0
nvd0: <WD_BLACK SN850X 1000GB> NVMe namespace
nvd0: 953869MB (1953525168 512 byte sectors)
hdacc0: <Realtek ALC256 HDA CODEC> at cad 0 on hdac0
hdaa0: <Realtek ALC256 Audio Function Group> at nid 1 on hdacc0
pcm0: <Realtek ALC256 (Right Analog)> at nid 33 and 25 on hdaa0
Trying to mount root from zfs:root [rw]...
ada0 at ahcich1 bus 0 scbus0 target 0 lun 0
ada0: <Samsung SSD 870 QVO 4TB SVQ02B6Q> ACS-4 ATA SATA 3.x device
ada0: Serial Number S5STNF0W200963X
ada0: 600.000MB/s transfers (SATA 3.x, UDMA6, PIO 512bytes)
ada0: Command Queueing enabled
ada0: 3815447MB (7814037168 512 byte sectors)
uhub1: 4 ports with 4 removable, self powered
uhub0: 16 ports with 16 removable, self powered
ugen1.2: <vendor 0x05e3 USB2.0 Hub> at usbus1
uhub2 on uhub0
uhub2: <vendor 0x05e3 USB2.0 Hub, class 9/0, rev 2.00/32.98, addr 1> on usbus1
Root mount waiting for: usbus1
uhub2: 4 ports with 4 removable, self powered
Root mount waiting for: usbus1
ugen1.3: <Logitech USB Receiver> at usbus1
ukbd0 on uhub2
ukbd0: <Logitech USB Receiver, class 0/0, rev 2.00/24.10, addr 2> on usbus1
kbd1 at ukbd0
ugen1.4: <vendor 0x05e3 USB2.0 Hub> at usbus1
uhub3 on uhub2
uhub3: <vendor 0x05e3 USB2.0 Hub, class 9/0, rev 2.00/32.98, addr 3> on usbus1
Root mount waiting for: usbus1
uhub3: 4 ports with 4 removable, self powered
ugen1.5: <PFU Limited HHKB-Hybrid> at usbus1
ukbd1 on uhub3
ukbd1: <keyboard> on usbus1
kbd2 at ukbd1
ukbd2 on uhub3
ukbd2: <Multi-Media> on usbus1
kbd3 at ukbd2
ugen1.6: <vendor 0x8087 product 0x0033> at usbus1
Intel(R) Wireless WiFi based driver for FreeBSD
acpi_wmi0: <ACPI-WMI mapping> on acpi0
acpi_wmi0: Embedded MOF found
ACPI: \134AMW0.WQBA: 1 arguments were passed to a non-method ACPI object (Buffer) (20201113/nsarguments-361)
acpi_wmi1: <ACPI-WMI mapping> on acpi0
acpi_wmi1: Embedded MOF found
ACPI: \134_SB.WFDE.WQCC: 1 arguments were passed to a non-method ACPI object (Buffer) (20201113/nsarguments-361)
acpi_wmi2: <ACPI-WMI mapping> on acpi0
acpi_wmi2: Embedded MOF found
ACPI: \134_SB.WFTE.WQCC: 1 arguments were passed to a non-method ACPI object (Buffer) (20201113/nsarguments-361)
iwlwifi0: <iwlwifi> mem 0x61241b4000-0x61241b7fff at device 20.3 on pci0
iwlwifi0: successfully loaded firmware image 'iwlwifi-so-a0-gf-a0-73.ucode'
iwlwifi0: api flags index 2 larger than supported by driver
iwlwifi0: TLV_FW_FSEQ_VERSION: FSEQ Version: 0.0.2.36
iwlwifi0: loaded firmware version 73.35c0a2c6.0 so-a0-gf-a0-73.ucode op_mode iwlmvm
iwlwifi0: Detected Intel(R) Wi-Fi 6E AX211 160MHz, REV=0x370
iwlwifi0: successfully loaded firmware image 'iwlwifi-so-a0-gf-a0.pnvm'
iwlwifi0: loaded PNVM version 881c99e1
iwlwifi0: Detected RF GF, rfid=0x2010d000
iwlwifi0: base HW address: d4:d8:53:84:1c:7d
ig4iic0: <Intel Alder Lake-P I2C Controller-0> at device 21.0 on pci0
ig4iic0: Using MSI
iicbus0: <Philips I2C bus (ACPI-hinted)> on ig4iic0
ig4iic1: <Intel Alder Lake-P I2C Controller-1> at device 21.1 on pci0
ig4iic1: Using MSI
iicbus1: <Philips I2C bus (ACPI-hinted)> on ig4iic1
iicbus1: <unknown card> at addr 0x36
iicbus1: <unknown card> at addr 0x63
ichsmb0: <Intel Alder Lake SMBus controller> port 0xefa0-0xefbf mem 0x61241bc000-0x61241bc0ff at device31.4 on pci0
smbus0: <System Management Bus> on ichsmb0
wlan0: Ethernet address: d4:d8:53:84:1c:7d
lo0: link state changed to UP
wlan0: ieee80211_new_state_locked: pending ASSOC -> RUN transition lost
wlan0: link state changed to UP
iwlwifi0: No beacon heard and the session protection is over already...
wlan0: link state changed to DOWN
ums0 on uhub2
ums0: <Logitech USB Receiver, class 0/0, rev 2.00/24.10, addr 2> on usbus1
ums0: 16 buttons and [XYZT] coordinates ID=2
uhid0 on uhub2
uhid0: <Logitech USB Receiver, class 0/0, rev 2.00/24.10, addr 2> on usbus1
uhid1 on uhub3
uhid1: <PFU Limited HHKB-Hybrid, class 0/0, rev 1.10/0.01, addr 4> on usbus1

とりあえずHWは一通り認識してくれました。最新デバイスも普通に認識してくれるのでメンテナの皆様には感謝ですね。

Xの設定やデータ移行はこれからなのでボチボチやります。

過去エントリー