How to install OpenVINO Notebooks on Apple M1/M2 (Silicons)
It’s possible now! with lots of hacking still.
Now it’s possible to run OpenVINO Notebooks on Apple M1/M2! However, you need to compile it from the source and create your own wheels with my custom requirements.txt.
Let’s go! First, Let’s create the wheels!
The tricky part is really to follow all the steps very carefully. Make sure the Python is from brew, and all dependencies are preinstalled. At the build step, also make sure you don’t have any errors. Once you completed all the steps. You should expect the wheels in the ‘wheels’ directory.
Also, I would recommend using Python virtual environment to isolate any dependencies issues.
python3.10 -m venv openvino_build
source openvino_build/bin/activate
After all went well, you should expect to see these in the build folder.
(openvino_build) rlo@Raymonds-MacBook-Pro-3 wheels % ls -lastrh
total 41048
0 drwxr-xr-x 57 rlo staff 1.8K Nov 27 11:43 ..
29656 -rw-r--r-- 1 rlo staff 14M Nov 27 11:43 openvino-2022.3.0-8846-cp310-cp310-macosx_13_0_arm64.whl
0 drwxr-xr-x 4 rlo staff 128B Nov 27 11:43 .
11392 -rw-r--r-- 1 rlo staff 5.6M Nov 27 11:43 openvino_dev-2022.3.0-8846-py3-none-any.whl
At this step, you’re ready to install. First we have to install the openvino package, then we will install the openvino-dev. Note: the installation order matters here.
pip install openvino-2022.3.*
pip install openvino_dev*
Next, new dependencies and changes.
I modified the requirements.txt pretty extensively to workround some dependencies issues. For example, I removed the openvino-dev line and also removed the torch==1.8.1’s version pinning and also tensorflow is now tensorflow-macos. The NNCF also had some hard dependencies crashing, and thus will be disabled at the moment.
#rlo@Raymonds-MacBook-Pro-3 openvino_notebooks % cat requirements.txt
#openvino-dev[onnx,tensorflow2]==2022.2.0
gdown
pytube>=12.1.0
yaspin
librosa==0.8.1
# PyTorch/ONNX notebook requirements
fastseg
ipywidgets
# Upgrade onnx version to avoid 220 YOLOV5 pytorch to onnx model export issue on Windows
onnx>=1.11.0,<1.12.0
torch; sys_platform == 'darwin'
torchvision; sys_platform == 'darwin'
--find-links https://download.pytorch.org/whl/torch_stable.html
torch==1.8.1+cpu; sys_platform =='linux' or platform_system == 'Windows'
torchvision==0.9.1+cpu; sys_platform =='linux' or platform_system == 'Windows'
torchmetrics==0.6.2
# PaddlePaddle notebook requirements
# For 103 PaddlePaddle MO conversion tutorial and 206 PaddleGAN/AnimeGAN demo
paddlepaddle==2.3.*
paddlehub<=2.2.0
# paddle2onnx 0.9.7 fails export in 206 and 207
paddle2onnx>=0.6,<=0.9.6
ppgan
# BERT quantization notebook requirements
transformers
# NNCF notebook requirements
#git+https://github.com/openvinotoolkit/nncf.git@f62b6629c71822b5241e175e0a03c3acb42ae01e#egg=nncf[tf,torch]
#tensorflow>=2.5,<=2.9.1
#tensorflow_datasets==4.2.0
# CT scan training/inference requirements
monai==0.9.1
pytorch_lightning
# Jupyter requirements
jupyterlab
# The packages below are not directly required. They are dependencies of
# other dependencies that are pinned to a specific version to avoid
# compatibility issues or vulnerabilities
seaborn>=0.11.0
geffnet==0.9.8
matplotlib<3.4
jedi==0.17.2
setuptools>=56.0.0
Pillow>=8.3.2
ipykernel==5.*
ipython==7.16.3 # not directly required, pinned to avoid a vulnerability
pygments>=2.7.4 # not directly required, pinned by Snyk to avoid a vulnerability
nltk>=3.6.4 # not directly required, pinned by Snyk to avoid a vulnerability
rsa>=4.7 # not directly required, pinned by Snyk to avoid a vulnerability
scikit-learn>=0.24.2 # not directly required, pinned by Snyk to avoid a vulnerability
paddlenlp==2.0.8 # workaround for "cannot import name '_C_ops'" error with paddlehub
parasail<=1.2.4 # higher version causes paddle issues
nest-asyncio<=1.5.4
jupyter-client<=7.2.0
Then, we have to install this or ONNX will give errors otherwise.
brew install protobuf
brew link --overwrite protobuf
Then, we need automake and libtool when we build some wheels during the installation too (took me a while to figure out).
brew install automake
brew install libtool
Now, run the requirements.txt. This will take a while (get a coffee now).
pip install -r requirements.txt
Finally!
Successfully installed Flask-Babel-2.0.0 aiohttp-3.8.3 aiosignal-1.3.1 anyio-3.6.2 argon2-cffi-21.3.0 argon2-cffi-bindings-21.2.0 astor-0.8.1 async-timeout-4.0.2 attrs-22.1.0 audioread-3.0.0 babel-2.11.0 bce-python-sdk-0.8.74 beautifulsoup4-4.11.1 bleach-5.0.1 cffi-1.15.1 click-8.1.3 colorama-0.4.6 colorlog-6.7.0 cycler-0.11.0 decorator-5.1.1 dill-0.3.6 entrypoints-0.4 fastseg-0.1.2 flask-2.2.2 frozenlist-1.3.3 fsspec-2022.11.0 future-0.18.2 gdown-4.5.4 geffnet-0.9.8 gunicorn-20.1.0 imageio-2.22.4 imageio-ffmpeg-0.4.7 ipykernel-5.5.6 ipython-7.16.3 ipywidgets-8.0.2 itsdangerous-2.1.2 jedi-0.17.2 jinja2-3.1.2 joblib-1.2.0 jsonschema-4.17.1 jupyter-client-7.2.0 jupyter-core-5.0.0 jupyter-server-1.23.3 jupyterlab-3.5.0 jupyterlab-pygments-0.2.2 jupyterlab-server-2.16.3 jupyterlab-widgets-3.0.3 kiwisolver-1.4.4 librosa-0.8.1 llvmlite-0.39.1 matplotlib-3.3.4 monai-0.9.1 multidict-6.0.2 multiprocess-0.70.14 nbclassic-0.4.8 nbclient-0.7.0 nbconvert-7.2.5 nbformat-5.7.0 nest-asyncio-1.5.4 nltk-3.7 notebook-6.5.2 notebook-shim-0.2.2 numba-0.56.4 onnx-1.11.0 paddle2onnx-0.8.1 paddlehub-2.2.0 paddlenlp-2.0.8 paddlepaddle-2.3.2 pandocfilters-1.5.0 parasail-1.2.4 pooch-1.6.0 ppgan-0.1.2 pytorch_lightning-1.6.5 resampy-0.4.2 scikit-image-0.19.3 scikit-learn-1.1.3 seaborn-0.12.1 seqeval-1.2.2 soundfile-0.11.0 terminado-0.17.0 torchmetrics-0.6.2 torchvision-0.14.0 visualdl-2.4.1 yarl-1.8.1 yaspin-2.2.0
Results and limitations
I will update this again with more limitations I found. But so far. It’s working (kinda)…
If you find any bugs or issues, you may file an issue here and see what the community can do to help.