So Im trying to build a mediapipe whl file for my jetson nano by following this guide
https://github.com/jiuqiant/mediapipe_python_aarch64
I am successful on building it with my raspberry pi 4.
By the way this github repo also provides a whl file for mediapipe I can install it but the module for face detection is disabled (the one thing I need)
So after running
python3 setup.py gen_protos && python3 setup.py bdist_wheel
This is the error that I get
Here is my pip freeze result:
python 3.6.9
absl-py==0.10.0
apt-clone==0.2.1
apturl==0.5.2
asn1crypto==0.24.0
astunparse==1.6.3
attrs==20.3.0
beautifulsoup4==4.6.0
blinker==1.4
Brlapi==0.6.6
cachetools==4.2.1
certifi==2018.1.18
chardet==3.0.4
cryptography==2.1.4
cupshelpers==1.0
cycler==0.10.0
Cython==0.29.23
dataclasses==0.8
decorator==4.1.2
defer==1.0.6
distro-info===0.18ubuntu0.18.04.1
feedparser==5.2.1
future==0.18.2
futures==3.1.1
gast==0.3.3
google-auth==1.29.0
google-auth-oauthlib==0.4.4
google-pasta==0.2.0
graphsurgeon==0.4.5
grpcio==1.37.0
h5py==2.10.0
html5lib==0.999999999
httplib2==0.9.2
idna==2.6
importlib-metadata==4.0.0
Jetson.GPIO==2.0.16
Keras-Applications==1.0.8
Keras-Preprocessing==1.1.1
keyring==10.6.0
keyrings.alt==3.0
kiwisolver==1.3.1
language-selector==0.1
launchpadlib==1.10.6
lazr.restfulclient==0.13.5
lazr.uri==1.0.3
louis==3.5.0
lxml==4.2.1
macaroonbakery==1.1.3
Mako==1.0.7
Markdown==3.3.4
MarkupSafe==1.0
matplotlib==3.2.2
mock==3.0.5
numpy==1.16.1
oauth==1.0.1
oauthlib==3.1.0
onboard==1.4.1
opt-einsum==3.3.0
PAM==0.4.2
pandas==0.22.0
pbr==5.5.1
protobuf==3.16.0rc1
pyasn1==0.4.8
pyasn1-modules==0.2.8
pybind11==2.6.2
pycairo==1.16.2
pycrypto==2.6.1
pycups==1.9.73
pygobject==3.26.1
PyICU==1.9.8
PyJWT==1.5.3
pymacaroons==0.13.0
PyNaCl==1.1.2
pyparsing==2.4.7
pyRFC3339==1.0
python-apt==1.6.5+ubuntu0.3
python-dateutil==2.6.1
python-debian==0.1.32
pytz==2018.3
pyxattr==0.6.0
pyxdg==0.25
PyYAML==3.12
requests==2.25.1
requests-oauthlib==1.3.0
requests-unixsocket==0.1.5
rsa==4.7.2
scipy==0.19.1
SecretStorage==2.3.1
simplejson==3.13.2
six==1.15.0
ssh-import-id==5.7
system-service==0.3
systemd-python==234
tensorboard==2.5.0
tensorboard-data-server==0.6.0
tensorboard-plugin-wit==1.8.0
tensorflow==2.3.1+nv20.12
tensorflow-estimator==2.3.0
tensorrt==7.1.3.0
termcolor==1.1.0
testresources==2.0.1
typing-extensions==3.7.4.3
ubuntu-drivers-common==0.0.0
uff==0.6.9
unity-scope-calculator==0.1
unity-scope-chromiumbookmarks==0.1
unity-scope-colourlovers==0.1
unity-scope-devhelp==0.1
unity-scope-firefoxbookmarks==0.1
unity-scope-manpages==0.1
unity-scope-openclipart==0.1
unity-scope-texdoc==0.1
unity-scope-tomboy==0.1
unity-scope-virtualbox==0.1
unity-scope-yelp==0.1
unity-scope-zotero==0.1
urllib3==1.22
urwid==2.0.1
wadllib==1.3.2
webencodings==0.5
Werkzeug==2.0.0rc4
wrapt==1.12.1
xkit==0.0.0
youtube-dl==2018.3.14
zipp==3.4.1
zope.interface==4.3.2
This problem solved by upgrading gcc compiler.
adding gcc-8 g++-8 to the apt-get install
Building MediaPipe for Jetson Nano is not the easiest task ever, especially if you have decided to go for CUDA-enabled compilation. I have built MediaPipe 0.8.9 Python Wheel with CUDA 10.2 for Jetson Nano (Currently hand landmarks detection and selfie segmentation only!): https://github.com/anion0278/mediapipe-jetson
I hope it will be useful for someone.
Related
I get this error with a pytorch import python -c "import torch":
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/afs/cs.stanford.edu/u/brando9/ultimate-utils/ultimate-utils-proj-src/uutils/__init__.py", line 13, in <module>
import torch
File "/dfs/scratch0/brando9/miniconda/envs/metalearning_gpu/lib/python3.9/site-packages/torch/__init__.py", line 191, in <module>
_load_global_deps()
File "/dfs/scratch0/brando9/miniconda/envs/metalearning_gpu/lib/python3.9/site-packages/torch/__init__.py", line 153, in _load_global_deps
ctypes.CDLL(lib_path, mode=ctypes.RTLD_GLOBAL)
File "/dfs/scratch0/brando9/miniconda/envs/metalearning_gpu/lib/python3.9/ctypes/__init__.py", line 382, in __init__
self._handle = _dlopen(self._name, mode)
OSError: /dfs/scratch0/brando9/miniconda/envs/metalearning_gpu/lib/python3.9/site-packages/torch/lib/../../nvidia/cublas/lib/libcublas.so.11: symbol cublasLtHSHMatmulAlgoInit, version libcublasLt.so.11 not defined in file libcublasLt.so.11 with link time reference
how does one fix it?
related:
Could not load dynamic library 'libcublasLt.so.11'; dlerror: libcublasLt.so.11: cannot open shared object file: No such file or directory
https://github.com/pytorch/pytorch/issues/51080
The error is from dlopen libcublas.so from .../python3.9/site-packages/torch/lib/nvidia/cublas/lib/, which is the pip package "nvidia-cuda-runtime" install location.
libcublasLt.so.11 is dynamically linked to libcublas.so.11. The problem is that when you have a different cuda runtime installation (usually in /usr/local/cuda), dlopen probably gets the wrong one. You can run ldd .../python3.9/site-packages/torch/lib/nvidia/cublas/lib/libcublas.so to check the actual path of libcublasLt.so.11, which is supposed to be the one under .../python3.9/site-packages/torch/lib/nvidia/cublas/lib/
Workarounds:
Set env LD_LIBRARY_PATH=.../python3.9/site-packages/torch/lib/nvidia/cublas/lib/:$LD_LIBRARY_PATH when launching python. So that dlopen can firstly look for .so files in that directory.
Using older torch. It was since 1.13.0 torch pip install started using pip nvidia-* packages. Before that cuda libs are statically linked. That's why older torch pip install has no problem even if you have existing cuda install.
like eval said, it is because pytorch1.13 automatically install nvidia_cublas_cu11,nvidia_cuda_nvrtc_cu11,nvidia_cuda_runtime_cu11 and nvidia_cudnn_cu11. While I have my own CUDA toolKit already installed, I have the same problem.
In my case, I used pip uninstall nvidia_cublas_cu11 and solved the problem.
I think the pytorch team should solve this, since users often have their own CUDAtoolkit installed.
I don't know why this works but this worked for me:
source cuda11.1
# To see Cuda version in use
nvcc -V
pip3 install torch==1.9.1+cu111 torchvision==0.10.1+cu111 torchaudio==0.9.1 -f https://download.pytorch.org/whl/torch_stable.html
but if you look through the git issue these might also work:
conda install -y -c pytorch -c conda-forge cudatoolkit=11.1 pytorch torchvision torchaudio
pip3 install torch+cu111 torchvision torchaudio -f https://download.pytorch.org/whl/torch_stable.html
I think the conda one looks like the most robust because you can specify exactly the cudatoolkit you need, so I'd recommend that one.
I wanted to work on an images detection problem using yolov7, and I installed default dependencies as provided by yolov7 https://github.com/WongKinYiu/yolov7/blob/main/requirements.txt, but when I tried even to check the help manual I got this error
OSError: .../yolov7_env/lib/python3.8/site-packages/torch/lib/../../nvidia/cublas/lib/libcublas.so.11: undefined symbol: cublasLtGetStatusString, version libcublasLt.so.11
Then I tried to install some other dependencies using the following command:
pip install torch==1.11.0+cu113 torchvision==0.12.0+cu113 torchaudio==0.11.0 --extra-index-url https://download.pytorch.org/whl/cu113
this's how I solved the problem.
I tried to code simple exercise on qt5:
main.py:
import sys
from PySide2.QtWidgets import QApplication, QLabel
app = QApplication(sys.argv)
label = QLabel("Hello World!")
label.show()
app.exec_()
When I tried to start I got errors which are linked with Qt5 libs:
(base) [redf1sh#redPC ~]$ export QT_DEBUG_PLUGINS=1
(base) [redf1sh#redPC ~]$ python3 main.py
...
Got keys from plugin meta data ("xcb")
QFactoryLoader::QFactoryLoader() checking directory path "/home/redf1sh/anaconda3/bin/platforms" ...
Cannot load library /home/redf1sh/anaconda3/plugins/platforms/libqxcb.so: (/home/redf1sh/anaconda3/plugins/platforms/../../lib/libQt5XcbQpa.so.5: undefined symbol: _ZN11QFontEngine14bitmapForGlyphEj6QFixedRK10QTransform, version Qt_5_PRIVATE_API)
QLibraryPrivate::loadPlugin failed on "/home/redf1sh/anaconda3/plugins/platforms/libqxcb.so" : "Cannot load library /home/redf1sh/anaconda3/plugins/platforms/libqxcb.so: (/home/redf1sh/anaconda3/plugins/platforms/../../lib/libQt5XcbQpa.so.5: undefined symbol: _ZN11QFontEngine14bitmapForGlyphEj6QFixedRK10QTransform, version Qt_5_PRIVATE_API)"
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: eglfs, minimal, minimalegl, offscreen, vnc, xcb.
I've installed pyqt5 packages, pyside2 with pip.
Can you help me with this?
I solved it by myself.
Firstly, I found all packages in the system that are connected to qt and removed them:
$ pip list | grep qt
$ pip uninstall *smth*
$ conda list | grep qt
$ conda remove *smth*
$ pacman -Qe | grep qt
# pacman -R *smth*
and secondly is clear install only from pacman (not plugins in pip or conda)
# pacman -S qt5 pyside2 python-pyqt5
and now all is working well
I am currently trying to setup Visual Studio Code on Mac OSX 10.13.6 for coding in python3. I'd like to avoid using multiple virtual environments for my different python3 scripts and instead have them all run using:
(1) the same homebrew installation of python3
(2) accessing installed python packages in:
homebrew packages list
pip3 installed package list
pip installed packages list.
First, I first installed python3 using homebrew:
$ brew info python
python: stable 3.7.7 (bottled), HEAD
Interpreted, interactive, object-oriented programming language
https://www.python.org/
/usr/local/Cellar/python/3.7.7 (4,062 files, 62.4MB)
...
Python has been installed as
/usr/local/bin/python3
...
You can install Python packages with
pip3 install <package>
They will install into the site-package directory
/usr/local/lib/python3.7/site-packages
Second, I installed my required packages using homebrew:
$ brew list
cmake libffi p11-kit
dcraw libheif pandoc
dlib libidn2 pcre
...
jasper numpy webp
...
And other packages using pip and pip3:
$ pip list
DEPRECATION:...
Package Version
-------------------------------------- --------
altgraph 0.10.2
...
numpy 1.8.0rc1
...
zope.interface 4.1.1
$
$ pip3 list
Package Version
------------------ -------
appnope 0.1.0
...
numpy 1.18.2
pandocfilters 1.4.2
parso 0.5.2
pexpect 4.7.0
pickleshare 0.7.5
pip 20.0.2
pomegranate 0.12.2
...
scipy 1.4.1
Third, I opened Visual Studio Code and in "Preferences" -> "Settings" and set "Python:Python Path" to the homebrew python3 installation as noted above /usr/local/bin/python3.
See this screenshot:
Next, I added /usr/local/lib/python3.7/site-packages per the homebrew install of python3 to the Visual Studio Code Settings file using:
"python.autoComplete.extraPaths": [
"/usr/local/lib/python3.7/site-packages" ]
Finally, I selected my python interpreter in Visual Studio Code as /usr/local/bin/python3 and tried to run the following 2-lines of imports in a .py script as per the screenshot below. Note that the interpreter is Python 3.7.0 64-bit given by the bottom left corner of the VS Code window.
And after all of that, ended up with this output after clicking the "Play" button to run the code in the top right corner of VS Code:
[Running] python -u "/Users/...bayes_net_nodes.py"
Traceback (most recent call last):
File "/Users/...bayes_net_nodes.py", line 1, in <module>
import numpy as np
ModuleNotFoundError: No module named 'numpy'
[Done] exited with code=1 in 0.037 seconds
What would be the most simple way to configure VS Code so I can run python3 scripts that have access to the all the packages I've installed across my system without using virtual environments? Thank you!
Note: One workaround that seems to work, and I'm not sure why is if I put a shebang at the top of my script #! /usr/local/bin/python3 and my output then looks like this:
[Running] /usr/local/bin/python3 "/Users/...bayes_net_nodes.py"
[Done] exited with code=0 in 0.051 seconds
Which is odd, because that's different than the output above where I didn't use the shebang but both python interpreters according to VSCode are indeed /usr/local/bin/python3
I was able to reproduce your problem.. but only when I use Code Runner to run.
Those kind of Output logs with [Running] and [Done] is Code Runner.
The play button is also not green, indicating Code Runner because the default is green.
Now, for the fix!
You'll notice that it executed your script using python -u. That python would be whatever python means on your system, which for me is the default Python 2.7. Basically, it's not your Homebrew Python3 with numpy.
Code Runner has a default set of "executors" which tells it which executable to use for which language. Search it for in your settings as "code-runner Executor Map":
Open your settings.json, enter code-runner.executorMap, then let it auto-complete with the default. You'll then see a long list of mappings between language and executor. Look for the one for python:
"code-runner.executorMap": {
"javascript": "node",
...
"python": "python -u",
"perl": "perl",
...
}
And there it is: python -u, the same one it used to run your script.
If you want to continue using Code Runner, simply change it to the whichever python interpreter you want to use. In your case, it should be /usr/local/bin/python3:
"code-runner.executorMap": {
...
"python": "/usr/local/bin/python3",
...
}
It should now work:
The reason it works with a #! /usr/local/bin/python3 shebang is because Code Runner has a setting that it respects the file's shebang (code-runner.respectShebang) which is true by default.
If you don't want this extra step of setting-up Code Runner, you can simply disable (or uninstall it). All the steps you already did (setting python.pythonPath, selecting the interpreter, and clicking that Play button) would have already worked just fine with Microsoft's Python extension. See the official docs on running Python files, selecting environments, and debugging.
I cannot get Jupyter Notebook running -- it keeps restarting the kernel and giving the error message,
ImportError: No module named 'prompt_toolkit.formatted_text'
A few threads online say it is an issue with ipython versioning which can be fixed by a rollback, but that hasn't worked for me.
Here are my current versions of relevant packages:
conda==4.5.11
ipykernel==4.10.0
ipython==6.5.0
ipython-genutils==0.2.0
ipywidgets==7.4.2
jupyter==1.0.0
jupyter-client==5.2.3
jupyter-console==4.1.1
jupyter-core==4.4.0
jupyter-kernel-gateway==2.1.0
jupyterlab==0.34.12
jupyterlab-launcher==0.13.1
notebook==5.7.0
prompt-toolkit==1.0.15
Any help you can provide would be great. Thanks!
I did have the same issue with Jupyter Notebook. Point is that ipython requirement specific version of prompt-toolkit. In my case, I have ipython 7.2.0 which required prompt-toolkit <2.1.0,>=2.0.0
I just added prompt-toolkit<2.1.0,>=2.0.0 to my requirements.txt to solve this problem.
Try to run pip install prompt_toolkit and see which version of prompt_toolkit need in your project.
I am using Anaconda with python 3.4 and I am not able to get all the pillow packages I need I am afraid on Windows 8.1.
I installed pillow via the Anaconda console with:
pip install pillow
which lead to:
The following packages will be UPDATED:
conda: 3.10.0-py34_0 --> 3.10.1-py34_0
conda-env: 2.1.3-py34_0 --> 2.1.4-py34_0
pillow: 2.7.0-py34_0 --> 2.8.1-py34_0
pip: 6.0.8-py34_0 --> 6.1.1-py34_0
setuptools: 14.3-py34_0 --> 15.0-py34_0
Now, in the spyder IPython console I start with: import tkinter, from PIL import ImageTk I have no errors here, but when executing ImageTk.PhotoImage(file='a.jpg') I receive an error, telling me: ImportError: cannot import name '_imagingtk'
What did I miss?
I know this is not a complete answer, but I have had the same problem and spent a day trying to figure it out...
Here is a small subset of things I tried yesterday to the best of my weak memory...
-Tried upgrating to the latest Python environment using anaconda (tip: you can create one using
conda update conda
conda update anaconda
(I think that's it, but may have tried to make sure for key packages explicitly etc.)
-Tried using Python 3.3 environment using anaconda (tip: you can create one using
conda update conda
conda create -n py33 python=3.3 anaconda
activate py33
-Tried using PythonWin instead of anaconda (that one took some time, had to install packets like numpy manually...)
-Tried updating / downgrading / installing/ uninstalling all kinds of different variations of Pillow, PIL, etc....
-Tried using opencv instead of PIL, though did not try to write my own components...
-Tried manually copying Tcl/tk and a few others to the lib directory as suggested by some posts
-Tried using import tkinter instead of Tkinter, using import Image vs. form PIL import Image (and in general taking Image from PIL, or opencv, or Tkinter) and a lot of other similar changes to the point it fell I was doing silly things
-...
At the end, I googled a few pages about GUIs in python, and now I am using wx... I had to run
conda install wxpython
and that was it. I have to say that after all this, I am presently surprised by how easy it was to make it work, here is a code example...
You need tcl/tk library.
Install them using apt-get
Do sudo apt-get install tk8.6-dev tcl8.6-dev
--Reference.