
bdarla
Machine Learning in Elixir: error thrown in code snippet (page 44)
Running the code snippet of Chapter 2 on page 44 of version B1.0, I get the following error:
Evaluation process terminated - an exception was raised:
** (FunctionClauseError) no function clause matching in String.graphemes/1
(elixir 1.15.2) lib/string.ex:1934: String.graphemes(:ok)
(benchee 1.1.0) lib/benchee/utility/erlang_version.ex:100: Benchee.Utility.ErlangVersion.parse_erlang_version/1
(benchee 1.1.0) lib/benchee/utility/erlang_version.ex:84: Benchee.Utility.ErlangVersion.includes_fixes_from?/2
(benchee 1.1.0) lib/benchee/benchmark/repeated_measurement.ex:60: Benchee.Benchmark.RepeatedMeasurement.determine_resolution_adjustment/2
(benchee 1.1.0) lib/benchee/benchmark/repeated_measurement.ex:42: Benchee.Benchmark.RepeatedMeasurement.determine_n_times/5
(benchee 1.1.0) lib/benchee/benchmark/runner.ex:226: Benchee.Benchmark.Runner.measure_runtimes/4
(benchee 1.1.0) lib/benchee/benchmark/runner.ex:102: Benchee.Benchmark.Runner.measure_scenario/2
(elixir 1.15.2) lib/task/supervised.ex:101: Task.Supervised.invoke_mfa/2
I run the code on an Apple Silicon M2 and I use Elixir 1.15.4 and Erlang/OTP 26.
I have not found any solution to this issue yet.
Marked As Solved

johnmacshea
I had the same issue with Benchee - I saw someone mention in the elixir forum that Benchee was crashing the LiveBook cells a while back. I’m also on Apple Silicon - LiveBook v0.9.3, Elixir v1.14.2.
I was curious so:
{exla_time, exla_result} = :timer.tc(fn →
apply(EXLA.jit(&Softmax.softmax/1), [tensor])
end)
{standard_time, standard_result} = :timer.tc(fn →
Softmax.softmax(tensor)
end)
IO.puts “exla is #{standard_time/exla_time} times faster”
result (one run):
exla is 66.25130208333333 times faster
On multiple runs its between 450 and 500 times faster.
Also Liked

bdarla
Update:
By visiting the Elixir forum, I discovered that with switching to Benchee
from the master branch on GitHub, the problem is solved.
Hence, I modified initial setup cell to:
Mix.install([
{:nx, "~> 0.5"},
{:exla, "~> 0.5"},
{:benchee, github: "bencheeorg/benchee", override: true},
])
For the record, the improvement I noted was 337 times faster. I guess this is without using GPU, yet.
Popular Prag Prog topics










Other popular topics










Latest in PragProg
Latest (all)
Categories:
Popular Portals
- /elixir
- /rust
- /wasm
- /ruby
- /erlang
- /phoenix
- /keyboards
- /js
- /rails
- /python
- /security
- /go
- /swift
- /vim
- /clojure
- /haskell
- /java
- /emacs
- /svelte
- /onivim
- /typescript
- /crystal
- /c-plus-plus
- /tailwind
- /kotlin
- /gleam
- /react
- /flutter
- /elm
- /ocaml
- /vscode
- /opensuse
- /centos
- /ash
- /php
- /deepseek
- /scala
- /zig
- /html
- /debian
- /nixos
- /lisp
- /agda
- /textmate
- /sublime-text
- /react-native
- /kubuntu
- /arch-linux
- /revery
- /ubuntu
- /manjaro
- /spring
- /django
- /diversity
- /nodejs
- /lua
- /slackware
- /julia
- /c
- /neovim