project-akri / akri-docs

Documentation for Akri
https://docs.akri.sh/
Apache License 2.0
8 stars 21 forks source link

Deployment steps for usb-camera-demo need slight edit in order to work on an Azure VM due to missing kernel modules #26

Closed roalexan closed 2 years ago

roalexan commented 2 years ago

Installing the usb-camera-demo sample on an Azure VM (I used Ubuntu 18.04 LTS) doesn't work with the instructions as they are now. An error occurs when trying to install the v4l2loopback kernel module due to the VM missing certain required kernel modules (e.g. usb device drivers). Here are the steps I did:

az vm create \ --resource-group ${RESOURCE_GROUP} \ --name ${VM_NAME} \ --image UbuntuLTS \ --admin-username ${VM_USER_NAME} \ --admin-password ${VM_PASSWORD} \ --public-ip-sku Standard

and in step 2 under “Setting up mock udev video devices” got this error:

... sudo dpkg -i v4l2loopback-dkms_0.12.5-1_all.deb Selecting previously unselected package v4l2loopback-dkms. (Reading database ... 82547 files and directories currently installed.) Preparing to unpack v4l2loopback-dkms_0.12.5-1_all.deb ... Unpacking v4l2loopback-dkms (0.12.5-1) ... Setting up v4l2loopback-dkms (0.12.5-1) ... Loading new v4l2loopback-0.12.5 DKMS files... Building for 5.4.0-1072-azure Building initial module for 5.4.0-1072-azure Error! Bad return status for module build on kernel: 5.4.0-1072-azure (x86_64) Consult /var/lib/dkms/v4l2loopback/0.12.5/build/make.log for more information.

The log shows:

DKMS make.log for v4l2loopback-0.12.5 for kernel 5.4.0-1072-azure (x86_64) Thu Mar 17 18:19:28 UTC 2022 Building v4l2-loopback driver... make -C /lib/modules/5.4.0-1072-azure/build M=/var/lib/dkms/v4l2loopback/0.12.5/build modules make[1]: Entering directory '/usr/src/linux-headers-5.4.0-1072-azure' CC [M] /var/lib/dkms/v4l2loopback/0.12.5/build/v4l2loopback.o Building modules, stage 2. MODPOST 1 modules ERROR: "video_ioctl2" [/var/lib/dkms/v4l2loopback/0.12.5/build/v4l2loopback.ko] undefined! ERROR: "__video_register_device" [/var/lib/dkms/v4l2loopback/0.12.5/build/v4l2loopback.ko] undefined! ERROR: "v4l2_ctrl_new_custom" [/var/lib/dkms/v4l2loopback/0.12.5/build/v4l2loopback.ko] undefined! ERROR: "v4l2_ctrl_handler_init_class" [/var/lib/dkms/v4l2loopback/0.12.5/build/v4l2loopback.ko] undefined! ERROR: "video_device_release" [/var/lib/dkms/v4l2loopback/0.12.5/build/v4l2loopback.ko] undefined! ERROR: "video_device_alloc" [/var/lib/dkms/v4l2loopback/0.12.5/build/v4l2loopback.ko] undefined! ERROR: "v4l2_device_register" [/var/lib/dkms/v4l2loopback/0.12.5/build/v4l2loopback.ko] undefined! ERROR: "v4l2_ctrl_handler_free" [/var/lib/dkms/v4l2loopback/0.12.5/build/v4l2loopback.ko] undefined! ERROR: "v4l2_device_unregister" [/var/lib/dkms/v4l2loopback/0.12.5/build/v4l2loopback.ko] undefined! ERROR: "video_unregister_device" [/var/lib/dkms/v4l2loopback/0.12.5/build/v4l2loopback.ko] undefined! ERROR: "video_devdata" [/var/lib/dkms/v4l2loopback/0.12.5/build/v4l2loopback.ko] undefined! scripts/Makefile.modpost:93: recipe for target 'modpost' failed make[2]: *** [modpost] Error 1 Makefile:1675: recipe for target 'modules' failed make[1]: [modules] Error 2 make[1]: Leaving directory '/usr/src/linux-headers-5.4.0-1072-azure' Makefile:42: recipe for target 'v4l2loopback.ko' failed make: [v4l2loopback.ko] Error 2

I got it to work (thanks kate-goldenring for the help) by adjusting the deployment steps slightly as follows:

sudo apt update sudo apt -y install linux-modules-extra-azure sudo apt -y install linux-headers-$(uname -r) sudo apt -y install linux-modules-extra-$(uname -r) sudo reboot now sudo apt -y install dkms curl http://deb.debian.org/debian/pool/main/v/v4l2loopback/v4l2loopback-dkms_0.12.5-1_all.deb -o v4l2loopback-dkms_0.12.5-1_all.deb sudo dpkg -i v4l2loopback-dkms_0.12.5-1_all.deb

It might be best to add to the demo that it assumes the VM being used supports the proper kernel modules, and perhaps incorporate the above working steps in some section specific to an Azure VM.

kate-goldenring commented 2 years ago

@roalexan thank you for working through this! I agree that we should at least add a note in the instructions that links to this issue. I'll look into updating that docs

roalexan commented 2 years ago

@kate-goldenring uh oh. I tried to create a fresh vm multiple time following the above steps, and this time it doesn't seem to be working - I'm seeing:

sudo dpkg -i v4l2loopback-dkms_0.12.5-1_all.deb Selecting previously unselected package v4l2loopback-dkms. (Reading database ... 85475 files and directories currently installed.) Preparing to unpack v4l2loopback-dkms_0.12.5-1_all.deb ... Unpacking v4l2loopback-dkms (0.12.5-1) ... Setting up v4l2loopback-dkms (0.12.5-1) ... Loading new v4l2loopback-0.12.5 DKMS files... Building for 5.4.0-1073-azure Module build for kernel 5.4.0-1073-azure was skipped since the kernel headers for this kernel does not seem to be installed.

well, the only difference this time around as far as I remember is that this time around I'm using the az cli to create the vm, as opposed to the Azure portal. I'll try a few different things and report back if I figure something out.

roalexan commented 2 years ago

@kate-goldenring well, from the Azure portal I get the same problem using Linux (ubuntu 18.04); however, trying again from the portal with Linux (ubuntu 20.04) it DOES work. So, probably I actually used ubuntu 20.04 the first time around and forgot about it (the original deployment has since been cleaned up). So, tomorrow I'll try this again from the az cli using ubuntu 20.04 and report back- hopefully with good news.

kate-goldenring commented 2 years ago

@roalexan, I wonder if we need to install a specific kernel module package for 18.04. Did the generic packages linux-modules-extra-azure etc exist in apt for 18.04?

roalexan commented 2 years ago

@kate-goldenring tomorrow I'll kick of another deployment using 18.04 again and see. In the meantime, I can at least confirm that it does indeed work for 20.04 via both portal and az cli deployment.

roalexan commented 2 years ago

for 18.04 generic packages linux-modules-extra-azure does exist. Below is what I see:

sudo apt -y install linux-modules-extra-azure Reading package lists... Done Building dependency tree Reading state information... Done The following package was automatically installed and is no longer required: linux-headers-4.15.0-171 Use 'sudo apt autoremove' to remove it. The following additional packages will be installed: linux-image-5.4.0-1073-azure linux-modules-5.4.0-1073-azure linux-modules-extra-5.4.0-1073-azure Suggested packages: fdutils linux-azure-5.4-doc-5.4.0 | linux-azure-5.4-source-5.4.0 linux-azure-5.4-tools linux-headers-5.4.0-1073-azure The following NEW packages will be installed: linux-image-5.4.0-1073-azure linux-modules-5.4.0-1073-azure linux-modules-extra-5.4.0-1073-azure linux-modules-extra-azure 0 upgraded, 4 newly installed, 0 to remove and 29 not upgraded. Need to get 39.0 MB of archives. After this operation, 143 MB of additional disk space will be used. Get:1 http://azure.archive.ubuntu.com/ubuntu bionic-updates/main amd64 linux-modules-5.4.0-1073-azure amd64 5.4.0-1073.76~18.04.1 [13.3 MB] Get:2 http://azure.archive.ubuntu.com/ubuntu bionic-updates/main amd64 linux-image-5.4.0-1073-azure amd64 5.4.0-1073.76~18.04.1 [9935 kB] Get:3 http://azure.archive.ubuntu.com/ubuntu bionic-updates/main amd64 linux-modules-extra-5.4.0-1073-azure amd64 5.4.0-1073.76~18.04.1 [15.7 MB] Get:4 http://azure.archive.ubuntu.com/ubuntu bionic-updates/main amd64 linux-modules-extra-azure amd64 5.4.0.1073.52 [2572 B] Fetched 39.0 MB in 4min 43s (138 kB/s) Selecting previously unselected package linux-modules-5.4.0-1073-azure. (Reading database ... 77008 files and directories currently installed.) Preparing to unpack .../linux-modules-5.4.0-1073-azure_5.4.0-1073.76~18.04.1_amd64.deb ... Unpacking linux-modules-5.4.0-1073-azure (5.4.0-1073.76~18.04.1) ... Selecting previously unselected package linux-image-5.4.0-1073-azure. Preparing to unpack .../linux-image-5.4.0-1073-azure_5.4.0-1073.76~18.04.1_amd64.deb ... Unpacking linux-image-5.4.0-1073-azure (5.4.0-1073.76~18.04.1) ... Selecting previously unselected package linux-modules-extra-5.4.0-1073-azure. Preparing to unpack .../linux-modules-extra-5.4.0-1073-azure_5.4.0-1073.76~18.04.1_amd64.deb ... Unpacking linux-modules-extra-5.4.0-1073-azure (5.4.0-1073.76~18.04.1) ... Selecting previously unselected package linux-modules-extra-azure. Preparing to unpack .../linux-modules-extra-azure_5.4.0.1073.52_amd64.deb ... Unpacking linux-modules-extra-azure (5.4.0.1073.52) ... Setting up linux-modules-5.4.0-1073-azure (5.4.0-1073.76~18.04.1) ... Setting up linux-image-5.4.0-1073-azure (5.4.0-1073.76~18.04.1) ... I: /initrd.img.old is now a symlink to boot/initrd.img-5.4.0-1072-azure I: /vmlinuz is now a symlink to boot/vmlinuz-5.4.0-1073-azure I: /initrd.img is now a symlink to boot/initrd.img-5.4.0-1073-azure Setting up linux-modules-extra-5.4.0-1073-azure (5.4.0-1073.76~18.04.1) ... Setting up linux-modules-extra-azure (5.4.0.1073.52) ... Processing triggers for linux-image-5.4.0-1073-azure (5.4.0-1073.76~18.04.1) ... /etc/kernel/postinst.d/initramfs-tools: update-initramfs: Generating /boot/initrd.img-5.4.0-1073-azure /etc/kernel/postinst.d/zz-update-grub: Sourcing file /etc/default/grub' Sourcing file/etc/default/grub.d/50-cloudimg-settings.cfg' Generating grub configuration file ... Found linux image: /boot/vmlinuz-5.4.0-1073-azure Found initrd image: /boot/initrd.img-5.4.0-1073-azure Found linux image: /boot/vmlinuz-5.4.0-1072-azure Found initrd image: /boot/initrd.img-5.4.0-1072-azure Adding boot menu entry for EFI firmware configuration done

but kernel headers still appear to not be available. Below is what I see:

sudo apt -y install linux-headers-$(uname -r) sudo apt -y install linux-modules-extra-$(uname -r) sudo reboot now ssh back in sudo apt -y install dkms curl http://deb.debian.org/debian/pool/main/v/v4l2loopback/v4l2loopback-dkms_0.12.5-1_all.deb -o v4l2loopback-dkms_0.12.5-1_all.deb sudo dpkg -i v4l2loopback-dkms_0.12.5-1_all.deb Selecting previously unselected package v4l2loopback-dkms. (Reading database ... 85152 files and directories currently installed.) Preparing to unpack v4l2loopback-dkms_0.12.5-1_all.deb ... Unpacking v4l2loopback-dkms (0.12.5-1) ... Setting up v4l2loopback-dkms (0.12.5-1) ... Loading new v4l2loopback-0.12.5 DKMS files... Building for 5.4.0-1073-azure Module build for kernel 5.4.0-1073-azure was skipped since the kernel headers for this kernel does not seem to be installed.

well, for now I'm going to stick with 20.04.

kate-goldenring commented 2 years ago

@roalexan thanks for giving ubuntu 18.04 another try. I think it is fine to leave 18.04 unresolved. If someone is committed to using an Azure 18.04 VM we can pick up here where we left off.