Open Afef00 opened 1 year ago
Hi @Afef00 Do you use PYNQ system image? If not, you can refer to https://github.com/Xilinx/Vitis-AI/blob/1.3.1/demo/VART/inception_v1_mt_py/inception_v1.py python example.
@qianglin-xlnx Yes, I used PYNQ-DPU (PYNQ image 2.7). The problem is when I tried other models, such as those provided on Jupyter notebook or other Xmodels that I tested before, it works fine. I don't get what the problem is.
From the log you provide, the model you compiled has 2 DPU subgraphs.
[UNILOG][INFO] Total device subgraph number 5, DPU subgraph number 2
While your program assert at the number of subgraph, which the DPU subgraph must be 1 in your program. Maybe you can modify this in your code.
--> 171 assert len(subgraphs) == 1
@qianglin-xlnx How can I modify this in the code?
I tried to modify the model architecture as follow:
inputs = tf.keras.Input(shape=input_shape)
x = tf.keras.layers.Conv2D(128, (3,3), activation='relu', input_shape=(input_shape))(inputs)
x = tf.keras.layers.MaxPooling2D((4,3))(x)
x = tf.keras.layers.Conv2D(32, (1,3), activation='relu')(x)
x = tf.keras.layers.MaxPooling2D((1,3))(x)
x = tf.keras.layers.Flatten()(x)
x = tf.keras.layers.Dense(512, activation='relu')(x)
x = tf.keras.layers.Dense(512, activation='relu')(x)
outputs = tf.keras.layers.Dense(2, activation='softmax')(x)
model = tf.keras.Model(inputs=inputs, outputs=outputs, name='classifier')
However, when I tried to compile the model I got this error:
[INFO] Namespace(inputs_shape=None, layout='NHWC', model_files=['quantized_depression_V2/quantize_eval_model.pb'], model_type='tensorflow', out_filename='./depression_V2_org.xmodel', proto=None)
[INFO] tensorflow model: quantized_depression_V2/quantize_eval_model.pb
[INFO] parse raw model :100%|█| 26/26 [00:00<00:00, 27134.09it/s]
[INFO] infer shape (NHWC) :100%|█| 33/33 [00:00<00:00, 5077.85it/s]
[INFO] infer shape (NHWC) :100%|█| 30/30 [00:00<00:00, 4038.81it/s]
[INFO] generate xmodel :100%|█| 30/30 [00:01<00:00, 17.32it/s]
[INFO] generate xmodel: /workspace/depression_V2_org.xmodel
[UNILOG][INFO] The compiler log will be dumped at "/tmp/vitis-ai-user/log/xcompiler-20221031-153814-245"
[UNILOG][INFO] Target architecture: DPUCZDX8G_ISA0_B4096_MAX_BG2
[UNILOG][INFO] Compile mode: dpu
[UNILOG][INFO] Debug mode: function
[UNILOG][INFO] Target architecture: DPUCZDX8G_ISA0_B4096_MAX_BG2
[UNILOG][INFO] Graph name: quantize_eval_model, with op num: 44
[UNILOG][INFO] Begin to compile...
[UNILOG][WARNING] xir::Op{name = max_pooling2d_1/MaxPool, type = pool-fix} has been allocated to CPU.
[UNILOG][Check Failed: bank_addr_end >= min_runtime_size][/home/xbuild/conda-bld/xcompiler_1606385139459/work/src/pass/passes/GenInst/AssignBankGroup.imp:1858][XCOM_ALLOCATE_BANK_FAIL][There is not enough bank space for the tensor]
Check failure stack trace:
Aborted (core dumped)
Hi @Afef00 Sorry about the late reply. Is this issue solved? My team does not have PYNQ-DPU. If you still have problem, you can ask PYNQ-DPU team for help.
No, actually this issue is not solved yet.
I ran Vitis AI CPU docker container from host using ./docker_run.sh xilinx/vitis-ai-cpu:1.3.411. After successfully training my custom model using the following code
After the quantization of the model I got this warning
INFO: Checking Float Graph... 2022-10-26 12:23:31.339312: W tensorflow/core/framework/cpu_allocator_impl.cc:81] Allocation of 434503680 exceeds 10% of system memory. 2022-10-26 12:23:31.479567: W tensorflow/core/framework/cpu_allocator_impl.cc:81] Allocation of 262656000 exceeds 10% of system memory. 2022-10-26 12:23:31.577909: W tensorflow/core/framework/cpu_allocator_impl.cc:81] Allocation of 85647360 exceeds 10% of system memory. 2022-10-26 12:23:31.608412: W tensorflow/core/framework/cpu_allocator_impl.cc:81] Allocation of 85647360 exceeds 10% of system memory. INFO: Float Graph Check Done. INFO: Calibrating for 32 iterations... N/A% (0 of 32) | | Elapsed Time: 0:00:00 ETA: --:--:--2022-10-26 12:23:42.735741: W tensorflow/core/framework/cpu_allocator_impl.cc:81] Allocation of 434503680 exceeds 10% of system memory. 100% (32 of 32) |########################| Elapsed Time: 0:02:33 Time: 0:02:33 INFO: Calibration Done. 2022-10-26 12:26:17.641835: W tensorflow/contrib/decent_q/utils/graph_quantizer.cc:1687] [DECENT_WARNING] Shift bias of node conv2d/Conv2D is 2147483638. It exceed range [-7, 16], modify quantize pos from 19 to 2147483641 2022-10-26 12:26:17.641863: W tensorflow/contrib/decent_q/utils/graph_quantizer.cc:1687] [DECENT_WARNING] Shift bias of node conv2d_1/Conv2D is 2147483637. It exceed range [-7, 16], modify quantize pos from 20 to 2147483641 2022-10-26 12:26:17.641867: W tensorflow/contrib/decent_q/utils/graph_quantizer.cc:1687] [DECENT_WARNING] Shift bias of node dense/MatMul is 2147483641. It exceed range [-2, 16], modify quantize pos from 21 to 2147483646 2022-10-26 12:26:17.641871: W tensorflow/contrib/decent_q/utils/graph_quantizer.cc:1687] [DECENT_WARNING] Shift bias of node dense_1/MatMul is 2147483638. It exceed range [-6, 16], modify quantize pos from 20 to 2147483642 2022-10-26 12:26:17.641873: W tensorflow/contrib/decent_q/utils/graph_quantizer.cc:1687] [DECENT_WARNING] Shift bias of node dense_2/MatMul is 2147483632. It exceed range [-6, 16], modify quantize pos from 26 to 2147483642 INFO: Generating Deploy Model... INFO: Deploy Model Generated. Quantization Summary
INFO: Output:
quantize_eval_model: quantized_depression/quantize_eval_model.pb
deploy_model: quantized_depression/deploy_model.pb
And the compilation went without any errors and I get the Xmodel.
[INFO] Namespace(inputs_shape=None, layout='NHWC', model_files=['quantized_depression/quantize_eval_model.pb'], model_type='tensorflow', out_filename='./depression_test_org.xmodel', proto=None) [INFO] tensorflow model: quantized_depression/quantize_eval_model.pb [INFO] parse raw model :100%|█| 26/26 [00:00<00:00, 21880.40it/s]
[INFO] infer shape (NHWC) :100%|█| 33/33 [00:00<00:00, 1010.51it/s]
[INFO] infer shape (NHWC) :100%|█| 30/30 [00:00<00:00, 742.64it/s]
[INFO] generate xmodel :100%|█| 30/30 [00:03<00:00, 7.62it/s]
[INFO] generate xmodel: /workspace/depression_test_org.xmodel [UNILOG][INFO] The compiler log will be dumped at "/tmp/vitis-ai-user/log/xcompiler-20221026-122808-1062" [UNILOG][INFO] Target architecture: DPUCZDX8G_ISA0_B4096_MAX_BG2 [UNILOG][INFO] Compile mode: dpu [UNILOG][INFO] Debug mode: function [UNILOG][INFO] Target architecture: DPUCZDX8G_ISA0_B4096_MAX_BG2 [UNILOG][INFO] Graph name: quantize_eval_model, with op num: 44 [UNILOG][INFO] Begin to compile... [UNILOG][WARNING] xir::Op{name = max_pooling2d_1/MaxPool, type = pool-fix} has been allocated to CPU. [UNILOG][INFO] Total device subgraph number 5, DPU subgraph number 2 [UNILOG][INFO] Compile done. [UNILOG][INFO] The meta json is saved to "/workspace/./meta.json" [UNILOG][INFO] The compiled xmodel is saved to "/workspace/./depression_test.xmodel" [UNILOG][INFO] The compiled xmodel's md5sum is e5f0d20e2578e60dd9efc74b76946bfe, and been saved to "/workspace/./md5sum.txt"
However wen trying to load the Xmodel on the ZCU104 board as follow
AssertionError Traceback (most recent call last)