wbsgrepit

wbsgrepit

Convert a pytorch model to native elixir

Hello,

I have seen some references that there is work being done to help migrate pytorch models to elixir. I am wondering if there is any pointers folks could give me to some resources related to this? Recently Whisper was released and I am very keen to try to pull that into some of my projects and see how it performs, but I would really like to run in elixir land and not need to shell out to pytorch.

Was I misremembering that there was a project being worked to change pytorch models to be able to run in elixir?

First Post!

kip

kip

ex_cldr Core Team

I think the Axon library may be what you are after (on my phone so sorry for the brief answer)

Most Liked

meanderingstream

meanderingstream

Find an ONNX export of the PyTorch model or you can use PyTorch to load a model and then export the model to ONNX. Once you have an ONNX model, then you can use axon_onnx to load into Elixir.

I suggest starting with the following notebook that I contributed to Axon, axon/guides/serialization/onnx_to_axon.livemd at main · elixir-nx/axon · GitHub. If you can get the ONNX to Axon side of the process working for you, then try the same thing on another ONNX model.

If you want to see an example of converting a PyTorch model to ONNX, review the Fast.ai code linked in the above livebook.

** BIG WARNING ** Saving ONNX imported models to an Axon file will probably fail. You can check Sean’s ElixirConf presentation for why.

Another warning: If you want to run a model on your CPU, use Torchx or XLA, you should be fine. Models have GPU memory size requirements. When trying to run a model on a GPU, it needs to fit in the available GPU memory.

Expect a blog post on Axon and ONNX at https://alongtheaxon.com/ about the above onnx_to_axon notebook. It is on my short term TODO.
Good Luck.

Where Next?

Popular in Questions Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 131117 1222
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

We're in Beta

About us Mission Statement