Transforming python code to HDL using hls4ml

I am following this tutorial: Quick Start · GitBook 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??

This is the PYNQ forum. It is not affiliated with the HLS4ML project. You probably want to read the docs for that project.
Looks like you haven’t installed or setup that tool correctly.

Cathal

Yes it is a PYNQ forum. And the aim of this tool is to transform python code to vivado code for the PYNQ-z1, so the question is not irrelevant. I followed exactly the steps:

git clone https://github.com/hls-fpga-machine-learning/hls4ml.git
cd hls4ml/
pip install .

cd example-models/

hls4ml convert -c keras-config.yml

and the last command does not seem to work…Does anyone has any idea, what is wrong with this???
Maybe there are and other people that have tried and face this problem… Thank you!

I just tested this on my machine and this works @hobbyist.
Do you have Vivado and Vivado HLS installed on your computer?
This is the output of my console:

Loading configuration from keras-config.yml
Interpreting Model
Topology:
Layer name: input_1, layer type: InputLayer, current shape: [[None, 16]]
Layer name: fc1_relu, layer type: Dense, current shape: [[None, 16]]
Layer name: fc2_relu, layer type: Dense, current shape: [[None, 64]]
Layer name: fc3_relu, layer type: Dense, current shape: [[None, 32]]
Layer name: output_softmax, layer type: Dense, current shape: [[None, 32]]
Creating HLS model
Writing HLS project
Done

1 Like

Which exactly Ubuntu version do you use?
Have you put PATH?
Thank you…!

My Ubuntu version is 18.04.3. Do you have this line in your .bashrc?
export PATH=“/tools/Xilinx/Vivado/2019.1/bin:/tools/Xilinx/SDK/2019.1/bin:$PATH”

1 Like

I just write this command on the terminal?

export PATH="/tools/Xilinx/Vivado/2019.1/bin:/tools/Xilinx/SDK/2019.1/bin:$PATH"

You can do this or edit the file .bashrc and add this line there. But edit the path if your version is not 2019.1 or if Vivado isn’t installed at /tools/Xilinx.

1 Like

I inserted at the end of .bashrc file:

export PATH="/tools/Xilinx/Vivado/2019.2/bin:/tools/Xilinx/SDK/2019.2/bin:$PATH"

nothing works when running:

mojito@ubuntu:~/Desktop/vivado/hls4ml/example-models$ hls4ml convert -c keras-config.yml

bash: ./hls4ml: No such file or directory

I am using this verion:

mojito@ubuntu:/$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.4 LTS
Release:	18.04
Codename:	bionic

I don’t know what is wrong!! I am trying to find out for days…Thank you…

Which python version are you using? Do you have anaconda installed?
I don’t know why you are having problems. My conda version is 4.7.12 and installing this was straightforward.

1 Like

Anaconda in Ubuntu?? No, I will look it. I didn’t know I need it.

mojito@ubuntu:/$ python --version
Python 2.7.17
mojito@ubuntu:/$ python3 --version
Python 3.6.9

Your problem is with HLS for ML, not with PYNQ.
The HLS4ML project have an e-mail address on their page for asking questions.

I strongly suggest you try contact them there. We want to keep this forum for issues specific to PYNQ. We don’t want to close posts, but your issue really isn’t anything to do with PYNQ at this point.

Cathal

They don’t answer! I have tried…Thank you…

This is not the problem of hls4ml nor pynq. It is python & pip configuration problem.
One of the easiest and reliable solution to the python problems is installing anaconda ecosystem, Anaconda | Anaconda Distribution

Install it, load basic envvars (source PATH_TO_YOUR_CONDA_PATH/etc/profile.d/conda.sh) then activate environment (conda activate default)
or you can setup your individual setups.
Probably you have to install pip in the conda (conda install pip)

Then proceed to the steps to install hls4ml (git clone, pip install .)

Well, I guess this is already solved issue, simply not updated :slight_smile:
and expect to hear some news that you were able to build a transformer python <-> hdl :crossed_fingers:t2: