microTVM Reference Virtual Machines don't work

Environment OS: Ubuntu 20.04 LTS (Focal Fossa) I switched to Ubuntu because Windows doesn’t work at all. cmake fails during vagrant up.

Hi, I’m now trying to deploy my AI model to ST microcontrollers to understand how tvm works. According to this tutorial: http://tvm.apache.org/docs/tutorials/micro/micro_reference_vm.html#sphx-glr-tutorials-micro-micro-reference-vm-py the things seem very simple. I just need to install vagrant, virtualbox, the extension of vm, and tvm repository: GitHub - apache/tvm: Open deep learning compiler stack for cpu, gpu and specialized accelerators</ However, when I cd to apps/microtvm/reference-vm/zephyr, and vagrant up, my home directory contains only kitware-archive-latest.asc, zephyr and zephyr-sdk. I just don’t know if the mounting worked fine since I cannot see the tvm repository that I have in my local repository. And so I cannot go on to the next step, which is cd apps/microtvm/reference-vm/zephyr and poetry run python3 …/…/…/…/tests/micro/qemu/test_zephyr.py --microtvm-platforms=stm32f746xx(There are no such directories in the VM!).

I am not sure if the information is enough but could anyone give me some advice or confirm whether all the scripts are complete to build the environment to use utvm? I just want to compile the tflite model and get the c runtime and model parameters to deploy to microcontrollers. Is my step correct to do so? Or any other better ways? It’s better if I don’t use the reference VM and am able to deploy tflite models to microcontrollers.

hi @sho,

sorry to hear of the troubles. one note on the reference vm: the home directory inside the VM is always going to be /home/vagrant, but we mount the tvm dir at $(pwd) (from the perspective of the host machine), so you may need to:

$ cd /home/host_username/path/to/tvm

Could you paste any error output you see from vagrant up?

Thanks, Andrew

Hi @areusch, Thank you for sparing your valuable time to answer the question.

Do you mean the directory you are in right after you vagrant ssh should be $(pwd)?

Below is what it looks like when I vagrant up and vagrant ssh. And inside zephyr folder, I have no clue to what it is.

(microtvm-vFLHvY_8-py3.6) vagrant@microtvm:~$ ls kitware-archive-latest.asc zephyr zephyr-sdk (microtvm-vFLHvY_8-py3.6) vagrant@microtvm:~$ cd zephyr (microtvm-vFLHvY_8-py3.6) vagrant@microtvm:~/zephyr$ ls bootloader modules tools zephyr (microtvm-vFLHvY_8-py3.6) vagrant@microtvm:~/zephyr$ cd zephyr (microtvm-vFLHvY_8-py3.6) vagrant@microtvm:~/zephyr/zephyr$ ls CMakeLists.txt MAINTAINERS.yml doc modules version.h.in CODEOWNERS Makefile drivers samples west.yml CODE_OF_CONDUCT.md README.rst dts scripts zephyr-env.cmd CONTRIBUTING.rst VERSION include share zephyr-env.sh Kconfig arch kernel soc Kconfig.zephyr boards lib subsys LICENSE cmake misc tests (microtvm-vFLHvY_8-py3.6) vagrant@microtvm:~/zephyr/zephyr$

Is it what you expect?

And here is the log when I vagrant up. I’m not sure if there is any failure to build the VM, but please see if it’s successful. Because of the limitation of lines, I pasted the first and last tens of lines. I guess the last several lines are doubtfull (starting by ‘default’).

Script started on 2021-08-30 13:53:27+09:00 [TERM=“xterm-256color” TTY="/dev/pts/0" COLUMNS=“80” LINES=“24”] e]0;mamo@mamo-MS-7B86: ~/workspace/tvm/tvm/apps/microtvm/reference-vm/zephyrae[01;32mmamo@mamo-MS-7B86e[00m:e[01;34m~/workspace/tvm/tvm/apps/microtvm/reference-vm/zephyre[00m$ vagrant ** ** up e[0mBringing machine ‘default’ up with ‘virtualbox’ provider…e[0m e[1m==> default: Importing base box ‘tlcpack/microtvm-zephyr-2.5’…e[0m e[0m e[Ke[0me[0mProgress: 10%e[0me[0m e[Ke[0me[0mProgress: 20%e[0me[0m e[Ke[0me[0mProgress: 30%e[0me[0m e[Ke[0me[0mProgress: 40%e[0me[0m e[Ke[0me[0mProgress: 50%e[0me[0m e[Ke[0me[0mProgress: 70%e[0me[0m e[Ke[0me[0mProgress: 80%e[0me[0m e[Ke[0me[0mProgress: 90%e[0me[0m e[Ke[0me[1m==> default: Matching MAC address for NAT networking…e[0m e[1m==> default: Checking if box ‘tlcpack/microtvm-zephyr-2.5’ version ‘0.0.3’ is up to date…e[0m e[1m==> default: Setting the name of the VM: microtvm-1630299214e[0m e[1m==> default: Clearing any previously set network interfaces…e[0m e[1m==> default: Preparing network interfaces based on configuration…e[0m e[0m default: Adapter 1: nate[0m e[1m==> default: Forwarding ports…e[0m e[0m default: 22 (guest) => 2222 (host) (adapter 1)e[0m e[1m==> default: Running ‘pre-boot’ VM customizations…e[0m e[1m==> default: Booting VM…e[0m e[1m==> default: Waiting for machine to boot. This may take a few minutes…e[0m e[0;32m default: Created wheel for python-can: filename=python_can-3.3.4-py2.py3-none-any.whl size=154207 sha256=38e6332f8e6677600d3b2518780579594ec48fb50fa168cdb266f4631db782d4e[0m e[0;32m default: Stored in directory: /home/vagrant/.cache/pip/wheels/c9/68/5f/5043e338eaae13ba6ef0e181a05ce18fbc07c9c5f89a1e7b07e[0m e[0;32m default: Building wheel for progress (setup.py): startede[0m e[0;32m default: Building wheel for progress (setup.py): finished with status 'done’e[0m e[0;32m default: Created wheel for progress: filename=progress-1.6-py3-none-any.whl size=9630 sha256=6020203089aa7d8c46ee8f80c8151cc1277db0d5d87ca6661b9c2ad1bab7cdabe[0m e[0;32m default: Stored in directory: /home/vagrant/.cache/pip/wheels/9f/92/2c/aa26d18b6a4d7df29d2cf1e1ff0bcf124a58fc10118485b160e[0m e[0;32m default: Successfully built cbor intervaltree naturalsort docopt python-can progresse[0m e[0;32m default: Installing collected packages: pycparser, ruamel.yaml.clib, cffi, sortedcontainers, ruamel.yaml, pypemicro, milksnake, docutils, docopt, aenum, sphinx, sh, pyusb, python-can, pyocd-pemicro, pylink-square, pykwalify, pyelftools, prettytable, naturalsort, mypy-extensions, lxml, intervaltree, intelhex, cryptography, colorama, cmsis-pack-manager, click, cbor, capstone, arrow, west, tabulate, sphinxcontrib-svg2pdfconverter, sphinx-tabs, python-magic, pyocd, progress, ply, mypy, mock, lpc-checksum, junitparser, junit2html, imgtool, gitlint, gcovr, coverage, canopen, breathe, anytreee[0m e[0;32m default: Attempting uninstall: docutilse[0m e[0;32m default: Found existing installation: docutils 0.17.1e[0m e[0;32m default: Uninstalling docutils-0.17.1:e[0m e[0;32m default: Successfully uninstalled docutils-0.17.1e[0m e[0;32m default: Attempting uninstall: sphinxe[0m e[0;32m default: Found existing installation: Sphinx 3.5.3e[0m e[0;32m default: Uninstalling Sphinx-3.5.3:e[0m e[0;32m default: Successfully uninstalled Sphinx-3.5.3e[0m e[0;32m default: Attempting uninstall: clicke[0m e[0;32m default: Found existing installation: click 8.0.1e[0m e[0;32m default: Uninstalling click-8.0.1:e[0m e[0;32m default: Successfully uninstalled click-8.0.1e[0m e[0;31m default: ERROR: pip’s dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.e[0m e[0;31m default: microtvm 0.1.0 requires mxnet<2.0.0,>=1.6.0, which is not installed.e[0m e[0;32m default: Successfully installed aenum-3.1.0 anytree-2.8.0 arrow-1.0.3 breathe-4.30.0 canopen-1.2.1 capstone-4.0.2 cbor-1.0.0 cffi-1.14.6 click-7.1.2 cmsis-pack-manager-0.2.10 colorama-0.4.4 coverage-5.5 cryptography-3.4.8 docopt-0.6.2 docutils-0.16 gcovr-5.0 gitlint-0.15.1 imgtool-1.7.2 intelhex-2.3.0 intervaltree-3.1.0 junit2html-30.0.6 junitparser-1.6.3 lpc-checksum-2.2.0 lxml-4.6.3 milksnake-0.1.5 mock-4.0.3 mypy-0.910 mypy-extensions-0.4.3 naturalsort-1.5.1 ply-3.11 prettytable-2.2.0 progress-1.6 pycparser-2.20 pyelftools-0.27 pykwalify-1.8.0 pylink-square-0.10.1 pyocd-0.31.0 pyocd-pemicro-1.0.6 pypemicro-0.1.7 python-can-3.3.4 python-magic-0.4.24 pyusb-1.2.1 ruamel.yaml-0.17.16 ruamel.yaml.clib-0.2.6 sh-1.14.1 sortedcontainers-2.4.0 sphinx-3.3.1 sphinx-tabs-3.2.0 sphinxcontrib-svg2pdfconverter-1.1.1 tabulate-0.8.9 west-0.11.1e[0m e[0;31m default: WARNING: You are using pip version 21.1.2; however, version 21.2.4 is available.e[0m e[0;31m default: You should consider upgrading via the ‘/home/vagrant/.cache/pypoetry/virtualenvs/microtvm-vFLHvY_8-py3.6/bin/python -m pip install --upgrade pip’ command.e[0m e[0;31m default: + echo 'export TVM_LIBRARY_PATH="/home/mamo/workspace/tvm/tvm"/build-microtvm’e[0m e[0;31m default: + echo ‘VENV_PATH=$((cd “/home/mamo/workspace/tvm/tvm”/apps/microtvm/reference-vm/zephyr && poetry env list --full-path) | sed -E ‘’‘s/^(.*)[[:space:]](Activated)$/\1/g’’’)'e[0m e[0;31m default: + echo 'source $VENV_PATH/bin/activate’e[0m e[0;31m default: + echo 'export PATH="${PATH}:${HOME}/zephyr-sdk/sysroots/x86_64-pokysdk-linux/usr/bin"'e[0m e]0;mamo@mamo-MS-7B86: ~/workspace/tvm/tvm/apps/microtvm/reference-vm/zephyrae[01;32mmamo@mamo-MS-7B86e[00m:e[01;34m~/workspace/tvm/tvm/apps/microtvm/reference-vm/zephyre[00m$ exit exit

Script done on 2021-08-30 14:30:36+09:00 [COMMAND_EXIT_CODE=“0”]

Do you mean the directory you are in right after you vagrant ssh should be $(pwd)?

No, the directory after you ssh should be /home/vagrant iirc. The files you see there are related to Zephyr SDK. Your tvm repository should be available in the VM at the same path as it is on the host. For example:

~/ws/tvm/apps/microtvm/reference-vm/zephyr$ pwd
/home/andrew/ws/tvm/apps/microtvm/reference-vm/zephyr
~/ws/tvm/apps/microtvm/reference-vm/zephyr$ vagrant ssh
(microtvm-vFLHvY_8-py3.6) vagrant@microtvm:~$ pwd
/home/vagrant
(microtvm-vFLHvY_8-py3.6) vagrant@microtvm:~$ cd /home/andrew/ws/tvm
# should now be in tvm directory.

Hi @areusch I am also trying to run microTVM on a windows machine with a virtualbox VM. I am seeing the same issues reported here. For some reason the tvm folder is not getting mounted in the virtual box hence I cloned the tvm master repository within the VM. After building tvm using conda environment tvm-build, I have also executed rebuild-tvm.sh But when I try import tvm.micro after executing poetry lock && poetry install && poetry shell I am getting an error - ModuleNotFoundError: No module named ‘tvm.micro.project_api’. Do you have any idea what might be going wrong here? Thanks

hey @sooras,

Thanks for your post! We haven’t tested this with the conda build flow inside the RVM. I am wondering whether perhaps the ruby logic in the Vagrantfile doesn’t work on Windows. could you paste some logs up (e.g. from vagrant up and whatever following commands you expect to work) so I can get a better idea what’s going on?

Thanks, Andrew

hi @areusch thanks for the quick response. When I try vagrant up this is what I see. C:\tvm\apps\microtvm\reference-vm\zephyr>vagrant up Bringing machine ‘default’ up with ‘virtualbox’ provider… ==> default: Importing base box ‘tlcpack/microtvm-zephyr-2.5’… ==> default: Matching MAC address for NAT networking… ==> default: Checking if box ‘tlcpack/microtvm-zephyr-2.5’ version ‘0.0.3’ is up to date… ==> default: Setting the name of the VM: microtvm-1630505570 ==> default: Clearing any previously set network interfaces… ==> default: Preparing network interfaces based on configuration… default: Adapter 1: nat ==> default: Forwarding ports… default: 22 (guest) => 2222 (host) (adapter 1) ==> default: Running ‘pre-boot’ VM customizations… ==> default: Booting VM… There was an error while executing VBoxManage, a CLI used by Vagrant for controlling VirtualBox. The command and stderr is shown below.

Command: [“startvm”, “39a936f1-a556-4cd7-8c1a-c0aab163ac0b”, “–type”, “headless”]

Stderr: VBoxManage.exe: error: Failed to construct device ‘usb-ehci’ instance #0 (VERR_PDM_DEVHLP_VERSION_MISMATCH) VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component ConsoleWrap, interface IConsole

This could be fixed by manually choosing USB controller USB1.1 ehci controller on the VM and powering on. But when I try vagrant provision following this step I am getting this error :

C:\tvm\apps\microtvm\reference-vm\zephyr>vagrant provision ==> default: Running provisioner: shell… default: Running: C:/Users/LOCAL-~1/AppData/Local/Temp/vagrant-shell20210901-5932-1bs56od.sh default: + cd C:/tvm default: /tmp/vagrant-shell: line 23: cd: C:/tvm: No such file or directory The SSH command responded with a non-zero exit status. Vagrant assumes that this means the command failed. The output for this command should be in the log above. Please read the output to determine what went wrong.

I believe the tvm folder is not getting mounted to the VM and hence I cloned the tvm repo to /home/vagrant manually following vagrant ssh. I am trying to build microtvm in the cloned tvm folder but it’s failing on import tvm.micro for some reason.

Not sure if executing poetry lock && poetry install && poetry shell within tvm/apps/microtvm/ and then executing rebuild-tvm.sh will work?

Many thanks, Sooraj

@Sooras I think you need to install the VirtualBox extension pack, because vagrant isn’t getting through with configuring the machine and that’s why you don’t see TVM mounted. Do you have that installed?

Thanks @areusch but I have the extension pack - Oracle_VM_VirtualBox_Extension_Pack-6.1.0_RC1.vbox-extpack installed on virtual box 6.1 but still encountering these issues as shown in the logs above.

Hi @areusch Sorry for my late reply. As you showed in the console log, yes I was able to cd to tvm mounted successfully. Thanks alot! Regarding the problems @Sooras faces, I think I had the same problem. I failed to vagrant up on Windows so I switched to Ubuntu. The build flow on Windows has not been tested as @areusch mentioned?

@soros gotcha–I don’t think you are going to ultimately succeed in testing code against real hardware unless you have a USB 2.0 host controller working with your machine. I’d not try to push past that error and instead figure out how to get that working, if you must on Windows. TVM uses USB-serial to communicate with devices for autotuning and host-driven inference, and with USB 1.1 it will drop bytes and thereby stall/fail inference and autotuning if that occurs.