Coder Social home page Coder Social logo

multi-thread friendly? about onnxruntime.jl HOT 6 CLOSED

jw3126 avatar jw3126 commented on July 28, 2024
multi-thread friendly?

from onnxruntime.jl.

Comments (6)

Moelf avatar Moelf commented on July 28, 2024

if we remove all the @timed stuff it seems to work, I suggest remove all the timed stuff for production

from onnxruntime.jl.

jw3126 avatar jw3126 commented on July 28, 2024

Thanks for bringing this up. I agree we should just get rid of TimerOutputs. Would be awesome if you could make a PR!

from onnxruntime.jl.

Moelf avatar Moelf commented on July 28, 2024

done

from onnxruntime.jl.

Moelf avatar Moelf commented on July 28, 2024
julia> const model_cpu = load_inference("onnx_model_test.onnx");

julia> @time let input = Dict("dense_input" => randn(Float32, 1, 78))
           for _ = 1:10^5
               model_cpu(input)
           end
       end
  1.294845 seconds (5.10 M allocations: 1.068 GiB, 10.40% gc time)

julia> @time let input = Dict("dense_input" => randn(Float32, 1, 78))
           Threads.@threads for _ = 1:10^5
               model_cpu(input)
           end
       end
  1.035058 seconds (5.12 M allocations: 1.069 GiB, 14.82% gc time, 1.43% compilation time)

julia> Threads.nthreads()
10

actually, it doesn't scale anyway

from onnxruntime.jl.

Moelf avatar Moelf commented on July 28, 2024

but at least this trick works:

julia> const models = [load_inference("./onnx_model_test.onnx") for _=1:Threads.nthreads()]

julia> @time let input = Dict("dense_input" => randn(Float32, 1, 78))
           Threads.@threads for _ = 1:10^5
               models[Threads.threadid()](input)
           end
       end
  0.367188 seconds (5.12 M allocations: 1.069 GiB, 38.03% compilation time)

somewhat

from onnxruntime.jl.

jw3126 avatar jw3126 commented on July 28, 2024

My guess is that onnxruntime does multithreading internally on CPU?

from onnxruntime.jl.

Related Issues (14)

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.