Giter Club home page Giter Club logo

Comments (4)

tianleiwu avatar tianleiwu commented on June 25, 2024

A possible cause: microsoft/onnxconverter-common#271

If you find two Cast nodes linked like:
image

A walkaround is to remove extra Cast nodes like

import onnx
from onnxruntime.transformers.onnx_model import OnnxModel
onnx_model=OnnxModel(onnx.load("path/to/model_fp16.onnx"))
onnx_model.remove_cascaded_cast_nodes()
onnx_model.save_model_to_file("path/to/model_fp16_v2.onnx", use_external_data_format=False, all_tensors_to_one_file=True)

from onnxruntime.

Macsim2 avatar Macsim2 commented on June 25, 2024

@tianleiwu Thank you that comments me
I checked the cast nodes through netron app

This is "model_fp16.onnx"
Screenshot from 2024-04-17 16-14-51

and then I just executed what you said
However, It doesn't works for me sadly
this is "model_fp16_v2.onnx"
Screenshot from 2024-04-17 16-15-22

For reference, I think that onnxruntime or onnxconverter_common are not invalid.
Because other models are works well. except for the probelm models (the problem model is bigger than other models)
Do you have any hint can I do by anychance?

from onnxruntime.

tianleiwu avatar tianleiwu commented on June 25, 2024

Not every model can run in fp16. Sometime, some nodes need to upcast to fp32 to avoid overflow.

You can add --cmake_extra_defines onnxruntime_DEBUG_NODE_INPUTS_OUTPUTS=1 in build command line to build a package from source code. Set environment variable ORT_DEBUG_NODE_IO_DUMP_OUTPUT_DATA to be 1 before running your application. In this way, you can see of output of each node. Compare the stdout of two runs (fp32 model vs fp16 model) can find out the root cause. See https://onnxruntime.ai/docs/build/eps.html#cuda for more information.

from onnxruntime.

Macsim2 avatar Macsim2 commented on June 25, 2024

okay Thank you reply @tianleiwu
I'll keep in track this problem and I will share with you if I found the reason why the model had didn't work

from onnxruntime.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.