DG2 kernel driver installation for Ubuntu20.04.5
===
## Table of Contents
[TOC]
## OV GPU installation guide
Ref:
https://dgpu-docs.intel.com/installation-guides/ubuntu/ubuntu-focal-arc.html
https://hub.docker.com/r/openvino/ubuntu20_dev
https://github.com/openvinotoolkit/docker_ci/blob/master/configure_gpu_ubuntu20.md
https://github.com/intel-sandbox/atsm-va-sample-demo/blob/main/system-setup.md
Pre-request BIOS settings for DG2/ATS-M
---
* **Intel Advanced Menu -> system Agent configuration -> ABove 4GB MMIO BIOS assignment (Enabled)**
* **Intel Advanced Menu -> system Agent configuration -> PCI Express Configuration -> PCIE Resizeable BAR Support (Enabled)**

Add package repository
---
set up proxy for host env.
```gherkin=
sudo -E apt-get install -y gpg-agent wget
wget -qO - https://repositories.intel.com/graphics/intel-graphics.key |
sudo gpg --dearmor --output /usr/share/keyrings/intel-graphics.gpg
echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/intel-graphics.gpg] https://repositories.intel.com/graphics/ubuntu focal-devel main' | \
sudo tee /etc/apt/sources.list.d/intel.gpu.focal.list
```
> If can't download by wget behine lab network, download manually and change as below
```gherkin=
sudo -E apt-get install -y gpg-agent wget
cat intel-graphics.key | sudo gpg --dearmor --output /usr/share/keyrings/intel-graphics.gpg
echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/intel-graphics.gpg] https://repositories.intel.com/graphics/ubuntu focal-devel main' | \
sudo tee /etc/apt/sources.list.d/intel.gpu.focal.list
```
Install Linux OEM kernel flows
---
```gherkin=
sudo -E apt-get install linux-image-5.14.0-1047-oem
cat /boot/grub/grub.cfg
```
>From this file, we can find the menuentry for $menuentry_id_option and the corresponding submenu. e.g.
submenu 'Advanced options for Ubuntu' ... {
menuentry 'Ubuntu, with Linux 5.14.0-1047-oem'...
>Now edit the file /etc/default/grub and change the default boot entry, e.g.
```gherkin=
sudo vim /etc/default/grub
#GRUB_DEFAULT="Advanced options for Ubuntu>Ubuntu, with Linux 5.14.0-1047-oem"
sudo update-grub
sudo reboot
uname -r
```
> The system should boot to prerelease kernel automatically. Make sure you get the right kernel name from "uname -r" command.
> Please ensure you are using 5.14.0-1047-oem or higher version. Then proceed blow instructions.
Install dkms and kernel header files
```gherkin=
sudo -E apt-get update
sudo -E apt-get install gawk
sudo -E apt-get install dkms \
linux-headers-$(uname -r) \
libc-dev
```
Install DKMS kernel modules
---
```gherkin=
sudo -E apt-get install intel-i915-dkms intel-platform-cse-dkms pmt
```
Install Install run-time packages
---
```gherkin=
sudo -E apt-get install \
intel-opencl-icd \
intel-level-zero-gpu level-zero \
intel-media-va-driver-non-free libmfx1 libmfxgen1 libvpl2 \
libegl-mesa0 libegl1-mesa libegl1-mesa-dev libgbm1 libgl1-mesa-dev libgl1-mesa-dri \
libglapi-mesa libgles2-mesa-dev libglx-mesa0 libigdgmm11 libxatracker2 mesa-va-drivers \
mesa-vdpau-drivers mesa-vulkan-drivers va-driver-all
```
OPTIONAL: Install developer packages
---
If you will be doing development, you may want to install optional development packages. oneAPI users will need to install these packages for some of the oneAPI tools to function correctly:
```gherkin=
sudo -E apt-get install \
libigc-dev \
intel-igc-cm \
libigdfcl-dev \
libigfxcmrt-dev \
level-zero-dev
```
> Reboot system to be effective
Configuring permissions
---
In order to access GPU capabilities, a user needs to have the correct permissions on system. The following will list the group assigned ownership of the render nodes, and list the groups the active user is a member of:
```gherkin=
stat -c "%G" /dev/dri/render*
groups ${USER}
```
If a group is listed for the render node which isn’t listed for the user, you will need to add the user to the group using gpasswd. In the following, the active user will be added to the ‘render’ group and a new shell spawned with that group active:
```gherkin=
sudo gpasswd -a ${USER} render
newgrp render
```
BKC
---
Graphics Compiler 1.0.11378
libdrm2 2.4.110.5
libva2 2.14.0.2-29
Media driver for VAAPI 22.4.3
Mesa 22.2.0.20220611.1
OpenCL* runtime 22.24.23453
```gherkin=
apt list | grep $packages
```
Verify the installations
---
### Verify the device is working with i915 driver
```
sudo apt-get install hwinfo
hwinfo --display
```
Similar information will be showed as below:
>28: PCI 02.0: 0300 VGA compatible controller (VGA)
[Created at pci.386]
Unique ID: _Znp.rCilE76BCCB
SysFS ID: /devices/pci0000:00/0000:00:02.0
SysFS BusID: 0000:00:02.0
Hardware Class: graphics card
Device Name: "GPU"
Model: "Intel VGA compatible controller"
Vendor: pci 0x8086 "Intel Corporation"
Device: pci 0x9bca
SubVendor: pci 0x8086 "Intel Corporation"
SubDevice: pci 0x2081
Revision: 0x04
Driver: "i915"
Driver Modules: "i915"
### Verify Media drivers installation
```
export DISPLAY=:0.0
sudo apt-get install vainfo
vainfo
```
Similar information will be showed as below:
>libva info: VA-API version 1.14.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_14
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.14 (libva 2.12.0)
### Verify Computing drivers installation
```
sudo apt-get install clinfo
clinfo
```
Similar information will be showed as below:
>Number of platforms 2
Platform Name Intel(R) OpenCL HD Graphics
Platform Vendor Intel(R) Corporation
Platform Version OpenCL 3.0
Platform Profile FULL_PROFILE
### Verify 3D drivers installation
Below verification needs a running desktop UI on top of your Linux distribution.
```
sudo apt install mesa-utils
glxinfo |grep OpenGL
```
Similar information will be showed as below:
>OpenGL vendor string: Intel
OpenGL renderer string: Mesa Intel(R) Graphics (DG2)
OpenGL core profile version string: 4.6 (Core Profile) Mesa 22.2.0-devel (git-44289c46d9)
OpenGL core profile shading language version string: 4.60
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 4.6 (Compatibility Profile) Mesa 22.2.0-devel (git-44289c46d9)
###### tags: `DG2` `BKC` `kernel` `installation`
{"metaMigratedAt":"2023-06-17T11:37:04.050Z","metaMigratedFrom":"YAML","title":"DG2 kernel driver installation for Ubuntu20.04.5","breaks":true,"disqus":"hackmd","contributors":"[{\"id\":\"498b4ac9-9b7a-44d4-ab9e-8e2b0dd045ca\",\"add\":10071,\"del\":3417}]"}