openvinotoolkit / openvino

OpenVINO™ is an open-source toolkit for optimizing and deploying AI inference
https://docs.openvino.ai
Apache License 2.0
7.21k stars 2.25k forks source link

[Bug] NCS 2 does not work inside KVM #6609

Closed DenisVASI9 closed 3 years ago

DenisVASI9 commented 3 years ago
System information (version)
Detailed description

I don't understand how to run movidius inside KVM.

Steps to reproduce

1) Crate KVM virtual machine 2) Install ubuntu and openvino 3) Login ubuntu 4) /opt/intel/openvino_2021/deployment_tools/demo 5) ./demo_squeezenet_download_convertrun.sh -d MYRIAD 6) E: [ncAPI] [ 52156] [classification] ncDeviceOpen:1013 Failed to find booted device after boot [ ERROR ] Can not init Myriad device: NC_ERROR

Iffa-Intel commented 3 years ago

Hi,

Have you tried to plug out then plug back in the NCS2 stick? this trick works in some cases. what type of virtual machine are you using? (eg: windows host using VMware or Oracle Virtualbox to run ubuntu 18)

Just to clarify, did you mean Oracle Virtualbox when you mentioned Oracle linux 8? Usually, you will need to apply a USB filter for the NCS2 in the virtual machine setting for it to work properly.

brmarkus commented 3 years ago

Have you installed the UDEV-rule file as described in the installation guide "https://docs.openvinotoolkit.org/latest/openvino_docs_install_guides_installing_openvino_linux.html#additional-NCS-steps"?

Have you installed it inside or outside the guest operating-system?

Have you explicitly shared ("USB-forwarding") the two USB-devices from your "host" into your "guest"?

The Myriad-X (NCS2) first is visible as a high-speed-device (vendor-id 03e7, product-id 2485).

Once the MyriadX plugin from OpenVINO has started the initialization process the USB-device will disappear from the USB-bus - and will appear again, but now as a super-speed device (vendor-id 03e7, product-id f63b).

That requires to either share (USB-forwarding) the whole USB-bus or these two device configurations; that's why in the UDEV-rule file you can see two devices listed.

Can you check with "lsusb" before starting and after starting your OpenVINO application? Can you confirm you can see first the one configuration and then the second configuration?

In two parallel console terminals (one outside your KVM-guest, and another inside your KVM-guest) you could keep running "dmesg -w" to keep watching the system logs - you will notice that the MyriadX gets detected after inserting; then, when you start your application, it will disappear - and then appear again as another device. Depending on your USB-forwarding the system-logs might look different - to indicate whether the second device was shared (forwarded) properly or not.

DenisVASI9 commented 3 years ago

@zulkifli-halim @Iffa-Meah Thank you for your questions, I will write answers soon

DenisVASI9 commented 3 years ago

I will elaborate on the creation of the server: 1) I inserted the orico PVU3-7U-R2.3 (usb pci) expansion board into the pci 2) Installed oracle linux, with kernel version 4 (not UEK kernel) 3) Installed libvirt, qumu and other standard kvm dependencies 4) Created a virtual machine with ubuntu 20.04 5) Opened the virtual machine menu and clicked "add hardware" 6) Add my PCI card to the virtual machine and boot it up. 7) Load it and use it.

I did not do anything different with the host, I did not add hardware to blacklists or anything like that. The virtual machine sees MyriadX and how I remove/add it

After experimenting - I will attach the dmesg output, thanks

DenisVASI9 commented 3 years ago

Hi, I found a way to make it work. To do this, I used vfio to take the pci bus away from the host and give it to the guest.

The question remains why it only works as root user, sudo and normal user gives an error NC_ERROR

For example: [E:] [BSL] found 0 ioexpander device ['CPU', 'GNA', 'MYRIAD'] load model to mem E: [ncAPI] [ 32388] [python] ncDeviceOpen:1013 Failed to find booted device after boot Traceback (most recent call last): File "dotter_to_ncs.py", line 8, in exec_net = ie.load_network(network, device_name="MYRIAD") File "ie_api.pyx", line 367, in openvino.inference_engine.ie_api.IECore.load_network File "ie_api.pyx", line 379, in openvino.inference_engine.ie_api.IECore.load_network RuntimeError: Can not init Myriad device: NC_ERROR`

Although different networks give different errors, some can not initialize mutex.

DenisVASI9 commented 3 years ago

@zulkifli-halim @Iffa-Meah Do you have any thoughts on this?

Iffa-Intel commented 3 years ago

Hi,

Like what @brmarkus mentioned, did you installed the UDEV-rule file as described in the installation guide ?

Plus with the additional steps required for VPU?

Since you are using VM, it is necessary to make the pci bus away from the host and give it to the guest (basic setup), if not, how the VM(guest) would do the operation. Similar concept of accessing the USB from VM. You won't be able to see the contents without changing the USB access from host to VM.

check this out for the differences between sudo and su

The nature of booting and re-booting is expected from the NCS2 when an execution occurs, however, if it had been set up properly, it should automatically re-booted and the VM system should automatically detect it.

Iffa-Intel commented 3 years ago

Closing issue, feel free to re-open or start a new issue if additional assistance is needed