fastmachinelearning / hls4ml-tutorial

Tutorial notebooks for hls4ml
http://fastmachinelearning.org/hls4ml-tutorial/
303 stars 133 forks source link

Unable to generate bitfile #53

Closed CestMerNeil closed 1 year ago

CestMerNeil commented 1 year ago

I am now trying to reproduce this tutorial, however I am unable to generate a bitfile and there is an error when I run the following code in part 7a

hls_model.build(csim=False, export=True, bitfile=True)

ERROR:

INFO: [BD 41-1029] Generation completed for the IP Integrator block hier_0/myproject_axi_0 .
Exporting to file /home/jovyan/hls4ml-tutorial/model_3/hls4ml_prj_pynq/myproject_vivado_accelerator/project_1.srcs/sources_1/bd/design_1/hw_handoff/design_1.hwh
Generated Block Design Tcl file /home/jovyan/hls4ml-tutorial/model_3/hls4ml_prj_pynq/myproject_vivado_accelerator/project_1.srcs/sources_1/bd/design_1/hw_handoff/design_1_bd.tcl
Generated Hardware Definition File /home/jovyan/hls4ml-tutorial/model_3/hls4ml_prj_pynq/myproject_vivado_accelerator/project_1.srcs/sources_1/bd/design_1/synth/design_1.hwdef
INFO: [IP_Flow 19-5642] Done with IP cache export for multiple IPs
realloc(): invalid old size
Abnormal program termination (6)
Please check '/home/jovyan/hls4ml-tutorial/model_3/hls4ml_prj_pynq/hs_err_pid21926.log' for details

I am using Ubuntu and using the provided Docker image with Vivado.

Here is the log file:

#
# An unexpected error has occurred (6)
#
Stack:
/lib/x86_64-linux-gnu/libc.so.6(+0x42520) [0x7f8d3cc1a520]
/lib/x86_64-linux-gnu/libc.so.6(pthread_kill+0x12c) [0x7f8d3cc6ea7c]
/lib/x86_64-linux-gnu/libc.so.6(raise+0x16) [0x7f8d3cc1a476]
/lib/x86_64-linux-gnu/libc.so.6(abort+0xd3) [0x7f8d3cc007f3]
/lib/x86_64-linux-gnu/libc.so.6(+0x896f6) [0x7f8d3cc616f6]
/lib/x86_64-linux-gnu/libc.so.6(+0xa0d7c) [0x7f8d3cc78d7c]
/lib/x86_64-linux-gnu/libc.so.6(realloc+0x36c) [0x7f8d3cc7db2c]
/lib/x86_64-linux-gnu/libudev.so.1(+0x15707) [0x7f8d3eeab707]
/lib/x86_64-linux-gnu/libudev.so.1(+0x1bb1b) [0x7f8d3eeb1b1b]
/lib/x86_64-linux-gnu/libudev.so.1(+0x75ff) [0x7f8d3ee9d5ff]
/lib/x86_64-linux-gnu/libudev.so.1(+0x7b6b) [0x7f8d3ee9db6b]
/lib/x86_64-linux-gnu/libudev.so.1(+0x10192) [0x7f8d3eea6192]
/lib/x86_64-linux-gnu/libudev.so.1(+0x105d3) [0x7f8d3eea65d3]
/lib/x86_64-linux-gnu/libudev.so.1(udev_enumerate_scan_devices+0x2a1) [0x7f8d3eea7341]
/opt/Xilinx/Vivado/2019.2/lib/lnx64.o/libXil_lmgr11.so(+0x10f927) [0x7f8d33d0f927]
/opt/Xilinx/Vivado/2019.2/lib/lnx64.o/libXil_lmgr11.so(xilinxd_52bd858d5acf2fc4+0x9) [0x7f8d33d0fd89]
/opt/Xilinx/Vivado/2019.2/lib/lnx64.o/libXil_lmgr11.so(+0xc6566) [0x7f8d33cc6566]
/opt/Xilinx/Vivado/2019.2/lib/lnx64.o/libXil_lmgr11.so(xilinxd_52bd853912de43c2+0xc8) [0x7f8d33cc6098]
/opt/Xilinx/Vivado/2019.2/lib/lnx64.o/libXil_lmgr11.so(+0xb33a2) [0x7f8d33cb33a2]
/opt/Xilinx/Vivado/2019.2/lib/lnx64.o/libXil_lmgr11.so(xilinxd_52bd995765656b48+0x2a) [0x7f8d33cbd5da]
/opt/Xilinx/Vivado/2019.2/lib/lnx64.o/libXil_lmgr11.so(xilinxd_52bd700d1bd3c616+0x73) [0x7f8d33cbd6c3]
/opt/Xilinx/Vivado/2019.2/lib/lnx64.o/librdi_commonxillic.so(XilReg::Utils::GetHostInfo[abi:cxx11](XilReg::Utils::HostInfoType, bool) const+0x208) [0x7f8d376674f8]
/opt/Xilinx/Vivado/2019.2/lib/lnx64.o/librdi_commonxillic.so(XilReg::Utils::GetHostInfoFormatted[abi:cxx11](XilReg::Utils::HostInfoType, bool) const+0x52) [0x7f8d3766b2c2]
/opt/Xilinx/Vivado/2019.2/lib/lnx64.o/librdi_commonxillic.so(XilReg::Utils::GetHostInfo[abi:cxx11]() const+0x183) [0x7f8d3766b583]
/opt/Xilinx/Vivado/2019.2/lib/lnx64.o/librdi_commonxillic.so(XilReg::Utils::GetRegInfo(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, bool)+0xc6) [0x7f8d37675e06]
/opt/Xilinx/Vivado/2019.2/lib/lnx64.o/librdi_commonxillic.so(XilReg::Utils::GetRegInfoWebTalk(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)+0x60) [0x7f8d37676090]
/opt/Xilinx/Vivado/2019.2/lib/lnx64.o/librdi_project.so(HAPRWebtalkHelper::getRegistrationId[abi:cxx11]() const+0x3a) [0x7f8d02e37a2a]
/opt/Xilinx/Vivado/2019.2/lib/lnx64.o/librdi_project.so(HAPRWebtalkHelper::HAPRWebtalkHelper(HAPRProject*, HAPRDesign*, HWEWebtalkMgr*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)+0xb0) [0x7f8d02e37ea0]
/opt/Xilinx/Vivado/2019.2/lib/lnx64.o/librdi_tcltasks.so(+0x180cbc6) [0x7f8d2e20cbc6]
/opt/Xilinx/Vivado/2019.2/lib/lnx64.o/librdi_tcltasks.so(+0x1817914) [0x7f8d2e217914]
/opt/Xilinx/Vivado/2019.2/lib/lnx64.o/librdi_common.so(+0x86eca2) [0x7f8d3e26eca2]
/opt/Xilinx/Vivado/2019.2/lib/lnx64.o/libtcl8.5.so(+0x334af) [0x7f8d36a334af]
/opt/Xilinx/Vivado/2019.2/lib/lnx64.o/libtcl8.5.so(+0x34b38) [0x7f8d36a34b38]
/opt/Xilinx/Vivado/2019.2/lib/lnx64.o/libtcl8.5.so(Tcl_EvalEx+0x13) [0x7f8d36a350a3]
/opt/Xilinx/Vivado/2019.2/lib/lnx64.o/libtcl8.5.so(Tcl_FSEvalFileEx+0x1da) [0x7f8d36a99c5a]
/opt/Xilinx/Vivado/2019.2/lib/lnx64.o/librdi_commontasks.so(+0x2b1d8d) [0x7f8d30ab1d8d]
/opt/Xilinx/Vivado/2019.2/lib/lnx64.o/librdi_common.so(+0x86eca2) [0x7f8d3e26eca2]
/opt/Xilinx/Vivado/2019.2/lib/lnx64.o/libtcl8.5.so(+0x334af) [0x7f8d36a334af]
/opt/Xilinx/Vivado/2019.2/lib/lnx64.o/libtcl8.5.so(Tcl_EvalObjv+0x32) [0x7f8d36a335e2]
/opt/Xilinx/Vivado/2019.2/lib/lnx64.o/libtcl8.5.so(TclEvalObjEx+0x322) [0x7f8d36a35402]
/opt/Xilinx/Vivado/2019.2/lib/lnx64.o/librdi_commontasks.so(+0x2de870) [0x7f8d30ade870]
/opt/Xilinx/Vivado/2019.2/lib/lnx64.o/librdi_commontasks.so(+0x2e011e) [0x7f8d30ae011e]
/opt/Xilinx/Vivado/2019.2/lib/lnx64.o/librdi_common.so(+0x86eca2) [0x7f8d3e26eca2]
/opt/Xilinx/Vivado/2019.2/lib/lnx64.o/libtcl8.5.so(+0x334af) [0x7f8d36a334af]
/opt/Xilinx/Vivado/2019.2/lib/lnx64.o/libtcl8.5.so(Tcl_EvalObjv+0x32) [0x7f8d36a335e2]
/opt/Xilinx/Vivado/2019.2/lib/lnx64.o/libtcl8.5.so(TclEvalObjEx+0x322) [0x7f8d36a35402]
/opt/Xilinx/Vivado/2019.2/lib/lnx64.o/librdi_commonmain.so(+0x7af3) [0x7f8d3d607af3]
/opt/Xilinx/Vivado/2019.2/lib/lnx64.o/libtcl8.5.so(Tcl_Main+0x1d0) [0x7f8d36aa0210]
/opt/Xilinx/Vivado/2019.2/lib/lnx64.o/librdi_common.so(+0x8b30cb) [0x7f8d3e2b30cb]
/lib/x86_64-linux-gnu/libc.so.6(+0x94b43) [0x7f8d3cc6cb43]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x44) [0x7f8d3ccfdbb4]
CestMerNeil commented 1 year ago

I am sorry to say that this is a Vivado generated problem.

To solve this problem, I refer to the following URL of AMD.

In this project, I solved the problem by modifying the first block of code in notebook 7a as follows:

from tensorflow.keras.models import load_model
from qkeras.utils import _add_supported_quantized_objects

co = {}
_add_supported_quantized_objects(co)
import os

os.environ['PATH'] = os.environ['XILINX_VIVADO'] + '/bin:' + os.environ['PATH']
os.environ['LD_PRELOAD'] = '/lib/x86_64-linux-gnu/libudev.so.1'