Closed bluepra closed 10 months ago
Hi,
For the tutorial projects you can find the generated RTL under, for example model_1/hls4ml_prj/myproject_prj/solution1/impl/{verilog, vhdl}
. This is the RTL of the NN IP. To generate a bitstream that you can load onto an FPGA, you need to integrated that IP into a larger project - to connect it to the outside world somehow. You can check out the new VivadoAccelerator
backend (currently on master
branch, not yet in a release) to make bitstreams for Pynq-Z2 or ZCU102 boards. If you have a similar type of board like another Zynq SoC kit it should not be too hard to adapt.
hi @thesps ,
i try to use VivadoAccelerator backend for pynq z2 but i faced this message : Backend VivadoAccelerator does not support building projects.
the config in yaml file
as shown below :
KerasJson: LeNet5_MNIST_model.json
KerasH5: LeNet5_MNIST_weights.h5
#InputData: keras/KERAS_3layer_input_features.dat
#OutputPredictions: keras/KERAS_3layer_predictions.dat
OutputDir: lenet5-hls-test1
ProjectName: lenet5
board: pynq-z2
Part: xc7z020clg400-1
ClockPeriod: 5
Backend: VivadoAccelerator
Interface: axi_stream
IOType: io_stream
HLSConfig:
Model:
Precision: ap_fixed<16,6>
ReuseFactor: 1
Strategy: Resource
# LayerType:
# Dense:
# ReuseFactor: 2
# Strategy: Resource
# Compression: True
and this is the out put of terminal :
(base) abdo@abdo:~/PycharmProjects/lenet5/qkeras$ hls4ml convert -c co_nf.yml
2023-11-19 18:44:55.190326: I tensorflow/tsl/cuda/cudart_stub.cc:28] Could not find cuda drivers on your machine, GPU will not be used.
2023-11-19 18:44:55.285062: E tensorflow/compiler/xla/stream_executor/cuda/cuda_dnn.cc:9342] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
2023-11-19 18:44:55.285098: E tensorflow/compiler/xla/stream_executor/cuda/cuda_fft.cc:609] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
2023-11-19 18:44:55.285189: E tensorflow/compiler/xla/stream_executor/cuda/cuda_blas.cc:1518] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2023-11-19 18:44:55.308195: I tensorflow/tsl/cuda/cudart_stub.cc:28] Could not find cuda drivers on your machine, GPU will not be used.
2023-11-19 18:44:55.308453: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2023-11-19 18:44:56.599776: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
Loading configuration from co_nf.yml
Interpreting Model
Topology:
Layer name: input_1, layer type: InputLayer, input shapes: [[None, 28, 28, 1]], output shape: [None, 28, 28, 1]
Layer name: conv_0, layer type: Conv2D, input shapes: [[None, 28, 28, 1]], output shape: [None, 26, 26, 16]
Layer name: bn_conv_0, layer type: BatchNormalization, input shapes: [[None, 26, 26, 16]], output shape: [None, 26, 26, 16]
Layer name: conv_act_0, layer type: Activation, input shapes: [[None, 26, 26, 16]], output shape: [None, 26, 26, 16]
Layer name: pool_0, layer type: MaxPooling2D, input shapes: [[None, 26, 26, 16]], output shape: [None, 13, 13, 16]
Layer name: conv_1, layer type: Conv2D, input shapes: [[None, 13, 13, 16]], output shape: [None, 11, 11, 16]
Layer name: bn_conv_1, layer type: BatchNormalization, input shapes: [[None, 11, 11, 16]], output shape: [None, 11, 11, 16]
Layer name: conv_act_1, layer type: Activation, input shapes: [[None, 11, 11, 16]], output shape: [None, 11, 11, 16]
Layer name: pool_1, layer type: MaxPooling2D, input shapes: [[None, 11, 11, 16]], output shape: [None, 5, 5, 16]
Layer name: conv_2, layer type: Conv2D, input shapes: [[None, 5, 5, 16]], output shape: [None, 3, 3, 24]
Layer name: bn_conv_2, layer type: BatchNormalization, input shapes: [[None, 3, 3, 24]], output shape: [None, 3, 3, 24]
Layer name: conv_act_2, layer type: Activation, input shapes: [[None, 3, 3, 24]], output shape: [None, 3, 3, 24]
Layer name: pool_2, layer type: MaxPooling2D, input shapes: [[None, 3, 3, 24]], output shape: [None, 1, 1, 24]
Layer name: flatten, layer type: Reshape, input shapes: [[None, 1, 1, 24]], output shape: [None, 24]
Layer name: dense_0, layer type: Dense, input shapes: [[None, 24]], output shape: [None, 42]
Layer name: bn_dense_0, layer type: BatchNormalization, input shapes: [[None, 42]], output shape: [None, 42]
Layer name: dense_act_0, layer type: Activation, input shapes: [[None, 42]], output shape: [None, 42]
Layer name: dense_1, layer type: Dense, input shapes: [[None, 42]], output shape: [None, 64]
Layer name: bn_dense_1, layer type: BatchNormalization, input shapes: [[None, 64]], output shape: [None, 64]
Layer name: dense_act_1, layer type: Activation, input shapes: [[None, 64]], output shape: [None, 64]
Layer name: output_dense, layer type: Dense, input shapes: [[None, 64]], output shape: [None, 10]
Layer name: output_softmax, layer type: Softmax, input shapes: [[None, 10]], output shape: [None, 10]
Creating HLS model
WARNING: Changing pipeline style to "dataflow".
Writing HLS project
Done
(base) abdo@abdo:~/PycharmProjects/lenet5/qkeras$ hls4ml build -p lenet5-hls-test1 -a
2023-11-19 18:45:15.265514: I tensorflow/tsl/cuda/cudart_stub.cc:28] Could not find cuda drivers on your machine, GPU will not be used.
2023-11-19 18:45:15.318470: E tensorflow/compiler/xla/stream_executor/cuda/cuda_dnn.cc:9342] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
2023-11-19 18:45:15.318543: E tensorflow/compiler/xla/stream_executor/cuda/cuda_fft.cc:609] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
2023-11-19 18:45:15.318607: E tensorflow/compiler/xla/stream_executor/cuda/cuda_blas.cc:1518] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2023-11-19 18:45:15.325347: I tensorflow/tsl/cuda/cudart_stub.cc:28] Could not find cuda drivers on your machine, GPU will not be used.
2023-11-19 18:45:15.325603: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2023-11-19 18:45:16.510641: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
Loading configuration from lenet5-hls-test1/hls4ml_config.yml
Backend VivadoAccelerator does not support building projects.
(base) abdo@abdo:~/PycharmProjects/lenet5/qkeras$
thank you in advance for your support :)
hls4ml
from the command line, it is deprecated and doesn't support the full feature set. Use the python API. Theck the tutorial to see how.
Hello, I used the hls_model.build() command to turn a 3 linear layer Keras model to its RTL version (I followed the tutorial). From my understanding, I now have the HDL version of the model. I think I need to use vivado to convert this HDL version to a bitstream that can be flashed onto an FPGA. Am I correct in saying this?
Two things:
Please feel free to correct my understanding at any stage of the process.
Thank you!