pejrich
I had Exla working at one point, but now it keeps crashing, and I can't figure out why
So I was trying to migrate some python code that I was running into my elixir code. My set up is that I have Elixir running most of the code, and rustler/rust bindings that run rust-bert for one model, and some python code that runs for another one. My goal was to bring as much as possible into Elixir. I found a model that I could run in Elixir, that was performing better than the one in Python, but there seemed to be a crossing of wires since both the Rust code, and the Elixir Nx code were using PyTorch. It seemed like whichever one ran first would get the lock on PyTorch, and the second one wouldn’t work(on the Rust side i’d see it was a error like this: Nif not loaded ... symbol not found in flat namespace '__ZN3c1019UndefinedTensorImpl10_singletonE'.
When I tried to instead run the Elixir side on Exla, I could get it to work breifly in a completely clean project, but not all together with everything else. When I load the model I get this output:
[info] TfrtCpuClient created.
[debug] the following PyTorch parameters were unused:
* bert.embeddings.position_ids
* bert.pooler.dense.bias
* bert.pooler.dense.weight
Which seems strange because I’m trying to target EXLA, not PyTorch. To confirm right before I ran this operation, I ran the following:
iex(3)> Nx.default_backend
{EXLA.Backend, [client: :host]}
Though the tensors do state EXLA:
f32[768]
EXLA.Backend<host:0,...
The model is started as follows:
{:ok, model} = Bumblebee.load_model({:hf, "vblagoje/bert-english-uncased-finetuned-pos"})
# This is only coming from local because there's no fast tokenizer "tokenizer.json" file on HF, but loading it in Python, then dumping to a file created one.
{:ok, tokenizer} = Bumblebee.load_tokenizer({:local, "priv/tokenizer"})
model = Bumblebee.Text.token_classification(model, tokenizer, aggregation: :same)
And called like:
Nx.Serving.run(model, "This is a test")
Which gives me the following:
libc++abi: terminating with uncaught exception of type std::out_of_range: Span::at failed bounds check
[1] 67025 abort iex --erl "-kernel shell_history enabled" -S mix phx.server
I have tried:
- Trying a different model, where both model and tokenizer are directly from HF, same result
- Scorched earth removal of pytorch, tensorflow, all deps, _build, the works, and then rebuilding, same result
- Completely removing rustler or anything else. Even trying in a completely clean project with just nx/bumblebee/axon/exla/jason, to try it there, same result.
- restarting the computer, same result.
I’m not even sure how to debug where it’s crashing from.
Here are my mix.exs deps:
{:axon, "~> 0.5.1"},
{:bumblebee, "~> 0.2.0"},
{:nx, "~> 0.5.1"},
{:exla, "~> 0.5.1", sparse: "exla"},
{:jason, "~> 1.0"}
Anyone have an insight or tips of what I could try?
Most Liked
stocks29
I was able to get this working by setting the optimization level to -O1 in exla’s Makefile as @thomasf had suggested. The piece I was missing before was clearing the library cache.
Here are the steps I followed to get this working:
mix deps.clean exlamix deps.get- Modify
deps/exla/Makefileto use-O1instead of-O3. - delete the exla library cache:
rm -rf ~/Library/Caches/xla/exla(this was missing step) mix deps.compile exla
With this Bumblebee is now working as expected.
josevalim
EXLA v0.5.3 released.
josevalim
Thank you for debugging. I tried to reproduce the error but I failed but I thought I should give your finding a try and push a fix.
Can you folks please try using EXLA from the v0.5 branch?
{:exla, github: "elixir-nx/nx", sparse: "exla", branch: "v0.5", override: true}
If it still fails, then I recommend following the suggestions posted by @seanmor5.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance










