Transforming python code to HDL using hls4ml - python

I am following this tutorial: https://fastmachinelearning.org/hls4ml/setup/QUICKSTART.html
when I give the command:
root#ubuntu:~/Desktop/vivado/hls4ml/example-models$ hls4ml convert -c keras-config.yml
hls4ml: command not found
What should I do? I tried
pip install hls4ml
I get this:
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: hls4ml in /home/mojito/.local/lib/python2.7/site-packages (0.2.0)
Requirement already satisfied: numpy in /home/mojito/.local/lib/python2.7/site-packages (from hls4ml) (1.16.6)
Requirement already satisfied: six in /home/mojito/.local/lib/python2.7/site-packages (from hls4ml) (1.14.0)
Requirement already satisfied: pyyaml in /home/mojito/.local/lib/python2.7/site-packages (from hls4ml) (5.3.1)
Requirement already satisfied: h5py in /home/mojito/.local/lib/python2.7/site-packages (from hls4ml) (2.10.0)
Requirement already satisfied: onnx>=1.4.0 in /home/mojito/.local/lib/python2.7/site-packages (from hls4ml) (1.6.0)
Requirement already satisfied: typing>=3.6.4; python_version < "3.5" in /home/mojito/.local/lib/python2.7/site-packages (from onnx>=1.4.0->hls4ml) (3.7.4.1)
Requirement already satisfied: protobuf in /home/mojito/.local/lib/python2.7/site-packages (from onnx>=1.4.0->hls4ml) (3.11.3)
Requirement already satisfied: typing-extensions>=3.6.2.1 in /home/mojito/.local/lib/python2.7/site-packages (from onnx>=1.4.0->hls4ml) (3.7.4.1)
Requirement already satisfied: setuptools in /home/mojito/.local/lib/python2.7/site-packages (from protobuf->onnx>=1.4.0->hls4ml) (44.1.0)

Try this:
$ git clone https://github.com/hls-fpga-machine-learning/hls4ml.git
$ cd hls4ml/
$ pip install .
Git repo: https://github.com/hls-fpga-machine-learning/models .
Also you can use pip as a module: $ python -m pip <command> [options]

Related

Creating a new virtual machine is not working

My goal is to work with Twitter API and do a sentiment analysize on tweets.
I am Working on a MAC, with VS Code on Anaconda.
I followed the tutorial and installed: python3 -m pip install --user virtualenv in my Terminal:
(base) Ludwigs-MBP:~ ludwigmehmke$ python3 -m pip install --user virtualenv
Requirement already satisfied: virtualenv in ./.local/lib/python3.7/site-packages (20.4.3)
Requirement already satisfied: six<2,>=1.9.0 in /opt/anaconda3/lib/python3.7/site-packages (from virtualenv) (1.12.0)
Requirement already satisfied: filelock<4,>=3.0.0 in /opt/anaconda3/lib/python3.7/site-packages (from virtualenv) (3.0.12)
Requirement already satisfied: distlib<1,>=0.3.1 in ./.local/lib/python3.7/site-packages (from virtualenv) (0.3.1)
Requirement already satisfied: appdirs<2,>=1.4.3 in ./.local/lib/python3.7/site-packages (from virtualenv) (1.4.4)
Requirement already satisfied: importlib-metadata>=0.12; python_version < "3.8" in /opt/anaconda3/lib/python3.7/site-packages (from virtualenv) (0.23)
Requirement already satisfied: zipp>=0.5 in /opt/anaconda3/lib/python3.7/site-packages (from importlib-metadata>=0.12; python_version < "3.8"->virtualenv) (0.6.0)
Requirement already satisfied: more-itertools in /opt/anaconda3/lib/python3.7/site-packages (from zipp>=0.5->importlib-metadata>=0.12; python_version < "3.8"->virtualenv) (7.2.0)
(base) Ludwigs-MBP:~ ludwigmehmke$
(base) Ludwigs-MBP:~ ludwigmehmke$
This is what I get. Next step was to create a Virtual Machine in VS Code. I entered the terminal there and created following code:
Ludwigs-MBP:Python ludwigmehmke$ python3 -m venv venv
Error: [Errno 1] Operation not permitted

Package updates from remote git repository are not reflected in site-packages

I have been trying to upgrade a package based off of the most recent changes on git but the changes aren't taking effect. I ran several variations of this command, such as also using python -m pip and the actual path to the pip version in anaconda, as well as adding --upgrade: pip install git+git://github.com/lmcinnes/umap#master
Here is the output each time:
Collecting git+git://github.com/lmcinnes/umap#master
Cloning git://github.com/lmcinnes/umap (to revision master) to /tmp/pip-req-build-bck1u0of
Running command git clone -q git://github.com/lmcinnes/umap /tmp/pip-req-build-bck1u0of
Requirement already satisfied: numpy>=1.17 in /home/himani/anaconda3/lib/python3.7/site-packages (from umap-learn==0.5.1) (1.19.2)
Requirement already satisfied: scikit-learn>=0.22 in /home/himani/anaconda3/lib/python3.7/site-packages (from umap-learn==0.5.1) (0.23.2)
Requirement already satisfied: scipy>=1.0 in /home/himani/anaconda3/lib/python3.7/site-packages (from umap-learn==0.5.1) (1.6.0)
Requirement already satisfied: numba>=0.49 in /home/himani/anaconda3/lib/python3.7/site-packages (from umap-learn==0.5.1) (0.51.2)
Requirement already satisfied: pynndescent>=0.5 in /home/himani/anaconda3/lib/python3.7/site-packages (from umap-learn==0.5.1) (0.5.2)
Requirement already satisfied: llvmlite<0.35,>=0.34.0.dev0 in /home/himani/anaconda3/lib/python3.7/site-packages (from numba>=0.49->umap-learn==0.5.1) (0.34.0)
Requirement already satisfied: setuptools in /home/himani/anaconda3/lib/python3.7/site-packages (from numba>=0.49->umap-learn==0.5.1) (52.0.0.post20210125)
Requirement already satisfied: joblib>=0.11 in /home/himani/anaconda3/lib/python3.7/site-packages (from pynndescent>=0.5->umap-learn==0.5.1) (1.0.0)
Requirement already satisfied: threadpoolctl>=2.0.0 in /home/himani/anaconda3/lib/python3.7/site-packages (from scikit-learn>=0.22->umap-learn==0.5.1) (2.1.0)
And looking in the actual directory of where umap is in site-packages, I can see that none of the files are being changed to reflect the updates, so it seems that nothing is happening. I am tempted to just manually change the files myself but I know that wouldn't be smart for the long run.
try using the --update and --force-reinstall options of pip, or:
pip install --update --force-reinstall git+git://github.com/lcminnes/umap#master

Having problems installing modules on python (Mac)

I'm a bit new to using pip to install modules on Python. I believe I have pip installed, however when I try to use the module I've tried to install using pip it says there is no such module. I'll post terminal response to see what happened. I'd really appreciate if somebody can let me know if I'm making a mistake installing modules, thanks for your time.
faizrahman#138-38-186-80 ~ % sudo pip install matplotlib
Password:
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
WARNING: The directory '/Users/faizrahman/Library/Caches/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied: matplotlib in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (1.3.1)
Requirement already satisfied: numpy>=1.5 in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from matplotlib) (1.8.0rc1)
Requirement already satisfied: python-dateutil in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from matplotlib) (1.5)
Requirement already satisfied: tornado in /Library/Python/2.7/site-packages (from matplotlib) (5.1.1)
Requirement already satisfied: pyparsing>=1.5.6 in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from matplotlib) (2.0.1)
Requirement already satisfied: nose in /Library/Python/2.7/site-packages (from matplotlib) (1.3.7)
Requirement already satisfied: singledispatch in /Library/Python/2.7/site-packages (from tornado->matplotlib) (3.4.0.3)
Requirement already satisfied: futures in /Library/Python/2.7/site-packages (from tornado->matplotlib) (3.3.0)
Requirement already satisfied: backports-abc>=0.4 in /Library/Python/2.7/site-packages (from tornado->matplotlib) (0.5)
Requirement already satisfied: six in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python (from singledispatch->tornado->matplotlib) (1.12.0)
faizrahman#138-38-186-80 ~ %
You will need to call pip from python3:
sudo python3 -m pip install matplotlib

Failed to import 'keystoneauth1' ... albeit installed?

I am using python3 via brew on MacOs.
When I do
> python3 -c "import keystoneauth1"
I get:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'keystoneauth1'
But then:
> pip3 install keystoneauth1
Requirement already satisfied: keystoneauth1 in /usr/local/lib/python3.7/site-packages (3.9.0)
Requirement already satisfied: iso8601>=0.1.11 in /usr/local/lib/python3.7/site-packages (from keystoneauth1) (0.1.12)
Requirement already satisfied: os-service-types>=1.2.0 in /usr/local/lib/python3.7/site-packages (from keystoneauth1) (1.2.0)
Requirement already satisfied: stevedore>=1.20.0 in /usr/local/lib/python3.7/site-packages (from keystoneauth1) (1.28.0)
Requirement already satisfied: pbr!=2.1.0,>=2.0.0 in /usr/local/lib/python3.7/site-packages (from keystoneauth1) (4.1.0)
Requirement already satisfied: six>=1.10.0 in /usr/local/lib/python3.7/site-packages (from keystoneauth1) (1.11.0)
Requirement already satisfied: requests>=2.14.2 in /usr/local/lib/python3.7/site-packages (from keystoneauth1) (2.19.1)
Requirement already satisfied: idna<2.8,>=2.5 in /usr/local/lib/python3.7/site-packages (from requests>=2.14.2->keystoneauth1) (2.7)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.7/site-packages (from requests>=2.14.2->keystoneauth1) (2018.4.16)
Requirement already satisfied: urllib3<1.24,>=1.21.1 in /usr/local/lib/python3.7/site-packages (from requests>=2.14.2->keystoneauth1) (1.23)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python3.7/site-packages (from requests>=2.14.2->keystoneauth1) (3.0.4)
Nothing else shows up there. When I then verify the installation, things look good:
> pip3 show keystoneauth1
Name: keystoneauth1
Version: 3.9.0
Summary: Authentication Library for OpenStack Identity
Home-page: https://docs.openstack.org/keystoneauth/latest/
Author: OpenStack
Author-email: openstack-dev#lists.openstack.org
License: UNKNOWN
Location: /usr/local/lib/python3.7/site-packages
Requires: stevedore, requests, pbr, os-service-types, six, iso8601
Required-by: openstacksdk, keystoneauth
But as shown, already importing that module doesn't work.
For me, the problem manifested itself after upgrading brew python to the lastest version 3.7.6.
I explicitly upgraded brew, and pip3 as well, but no luck.
And sorry for the repeated typos. The module name is really keystoneauth1.
I really don't understand what exactly is going on here.
So this isn't really an answer that explains and solves the issue, but the workaround that worked for me:
First, I force removed python brew uninstall --ignore-dependencies python
Then, I only installed it again brew install python
And afterwards, my scripts (that in the end used that import) work again without any problems?!

Python cannot see module after installing via pip

I'm still trying to master the science of installing packages via pip. When I run pip to install geocoder, I get the following:
(base) C:\Users\MBSanders>python -m pip install geocoder
Requirement already satisfied: geocoder in c:\programdata\anaconda3\lib\site-packages (1.38.1)
Requirement already satisfied: requests in c:\programdata\anaconda3\lib\site-packages (from geocoder) (2.21.0)
Requirement already satisfied: future in c:\programdata\anaconda3\lib\site-packages (from geocoder) (0.17.1)
Requirement already satisfied: click in c:\programdata\anaconda3\lib\site-packages (from geocoder) (7.0)
Requirement already satisfied: six in c:\programdata\anaconda3\lib\site-packages (from geocoder) (1.12.0)
Requirement already satisfied: ratelim in c:\programdata\anaconda3\lib\site-packages (from geocoder) (0.1.6)
Requirement already satisfied: certifi>=2017.4.17 in c:\programdata\anaconda3\lib\site-packages (from requests->geocoder) (2019.3.9)
Requirement already satisfied: idna<2.9,>=2.5 in c:\programdata\anaconda3\lib\site-packages (from requests->geocoder) (2.8)
Requirement already satisfied: urllib3<1.25,>=1.21.1 in c:\programdata\anaconda3\lib\site-packages (from requests->geocoder) (1.24.1)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\programdata\anaconda3\lib\site-packages (from requests->geocoder) (3.0.4)
Requirement already satisfied: decorator in c:\programdata\anaconda3\lib\site-packages (from ratelim->geocoder) (4.4.0)
When I run
os.getcwd()
in spyder/python, I get
'C:\\Users\\MBSanders'
My question is, why do I get
ModuleNotFoundError: No module named 'geocoder'
When I run
import geocoder
I'm somewhat new to python. Please let me know if additional info is needed to trouble shoot. I'm within a federal agency so I do not have admin rights.
When I run sys.path in the console, I get
sys.path
Out[12]:
['F:\\Users\\MBSanders',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\python37.zip',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\DLLs',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\lib',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3',
'',
'C:\\Users\\MBSanders\\AppData\\Roaming\\Python\\Python37\\site-packages',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\win32',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\win32\\lib',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\Pythonwin',
'C:\\Users\\MBSanders\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\IPython\\extensions',
'F:\\Users\\MBSanders\\.ipython']
Assuming you're running python on the terminal, and python is the command you're using to run it, try doing python -m pip install geocoder. That'll install it for the python build you want to use. Or if you know the full path to the python build you're using, you can do something similar like /path/to/python -m pip install geocoder.
if you are using python 3.7 or 3.8 you may need to pip3.7 or pip3.8 install if you OS is recognizing a 2.x version as default

Categories

Resources