You can compile the model using one of the following options:
Install DFC 3.28 – Downgrade your DFC version by downloading the previous version(3.28) from the Developer Zone and installing it in a clean virtual environment.
Downgrade your Python version to 3.8 – Alternatively, install Python 3.8 and python3.8-dev, export the model as described above, create a clean virtual environment, and install DFC 3.29.
i tried to compile the visual part with DFC 3.28.0.
I got this error:
hailo_sdk_client.model_translator.exceptions.ParsingWithRecommendationException: Parsing failed. The errors found in the graph are:
UnsupportedShuffleLayerError in op /attnpool/Transpose_5: Failed to determine type of layer to create in node /attnpool/Transpose_5
Please try to parse the model again, using these end node names: /attnpool/MatMul_4
Also, please double-check that you’re using this code for exporting and that everything is being done in a clean environment.
import torch
import clip
from torch.autograd import Variable
vision_arch = "RN50x4"
device = "cpu"
model, preprocess = clip.load("RN50x4", device=device)
vit = model.visual
dummy_input = Variable(torch.randn(1, 3, 288, 288, device="cpu"))
# ==================== #
# Export Model as ONNX #
# ==================== #
vit.eval()
torch.onnx.export(vit, # model being run
dummy_input, # model input (or a tuple for multiple inputs)
"clip.onnx", # where to save the model
opset_version=14, # the ONNX version to export the model to
do_constant_folding=True, # whether to execute constant folding for optimization
)
First i tried to compile the onnx you have send me. It failed at the same point as my onnx file.
Parsing failed. The errors found in the graph are:
UnsupportedShuffleLayerError in op /attnpool/Transpose_5: Failed to determine type of layer to create in node /attnpool/Transpose_5
Please try to parse the model again, using these end node names: /attnpool/MatMul_4
Then i checkd the installed packages.
My list is way longer than yours:
I am using a fresh new enviroment and deleted all global packages with pip freeze | xargs pip uninstall -y.
I am using hailo_dataflow_compiler-3.28.0-py3-none-linux_x86_64.whl with python 3.10.12 to install the DFC.
Of the packages on my list and your list, the following are different:
My version | Your version
numpy==1.23.3 | 2.1.3
onnx==1.14.0 | 1.17.0
protobuf==3.20.3 | 5.28.3
regex not installed | 2024.11.6
I also checked again with the DFC 3.29.0 and tried to compile your onnx but there i get the old error:
raise UnexpectedNodeError(f"Failed to find reshape node in format conversion layer near {self.name}.")
output_shape = consumed_vertices[-1].get_output_shapes()[0]
spatial_reshape_sizes = [output_shape[1], output_shape[2]]
return consumed_vertices, [output_shape], spatial_reshape_sizes
The list I sent you is for the clip_venv.
I checked my DFC virtual environment, and it contains the same packages as yours, so I’m not sure why the parsing isn’t working.
Please download the onnx from the link I sent you. I’ve uploaded a new version that I checked today.
Hey @lihis
The new model you sent me compiles fine.
My question now is how did you get the onnx file?
Because for the clip I need torch 2.5, but in the file you sent me I can see you used torch 1.7.