bdarla

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

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

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 Top

brianokken
Many tasks_proj/tests directories exist in chapters 2, 3, 5 that have tests that use the custom markers smoke and get, which are not decl...
New
yulkin
your book suggests to use Image.toByteData() to convert image to bytes, however I get the following error: "the getter ‘toByteData’ isn’t...
New
sdmoralesma
Title: Web Development with Clojure, Third Edition - migrations/create not working: p159 When I execute the command: user=> (create-...
New
jdufour
Hello! On page xix of the preface, it says there is a community forum "… for help if your’re stuck on one of the exercises in this book… ...
New
herminiotorres
Hi! I know not the intentions behind this narrative when called, on page XI: mount() |> handle_event() |> render() but the correc...
New
jeremyhuiskamp
Title: Web Development with Clojure, Third Edition, vB17.0 (p9) The create table guestbook syntax suggested doesn’t seem to be accepted ...
New
gilesdotcodes
In case this helps anyone, I’ve had issues setting up the rails source code. Here were the solutions: In Gemfile, change gem 'rails' t...
New
patoncrispy
I’m new to Rust and am using this book to learn more as well as to feed my interest in game dev. I’ve just finished the flappy dragon exa...
New
brunogirin
When installing Cards as an editable package, I get the following error: ERROR: File “setup.py” not found. Directory cannot be installe...
New
creminology
Skimming ahead, much of the following is explained in Chapter 3, but new readers (like me!) will hit a roadblock in Chapter 2 with their ...
New

Other popular topics Top

wolf4earth
@AstonJ prompted me to open this topic after I mentioned in the lockdown thread how I started to do a lot more for my fitness. https://f...
New
AstonJ
Do the test and post your score :nerd_face: :keyboard: If possible, please add info such as the keyboard you’re using, the layout (Qw...
New
Rainer
Not sure if following fits exactly this thread, or if we should have a hobby thread… For many years I’m designing and building model air...
New
DevotionGeo
The V Programming Language Simple language for building maintainable programs V is already mentioned couple of times in the forum, but I...
New
mafinar
Crystal recently reached version 1. I had been following it for awhile but never got to really learn it. Most languages I picked up out o...
New
AstonJ
Biggest jackpot ever apparently! :upside_down_face: I don’t (usually) gamble/play the lottery, but working on a program to predict the...
New
New
First poster: joeb
The File System Access API with Origin Private File System. WebKit supports new API that makes it possible for web apps to create, open,...
New
AstonJ
Was just curious to see if any were around, found this one: I got 51/100: Not sure if it was meant to buy I am sure at times the b...
New
PragmaticBookshelf
Author Spotlight Rebecca Skinner @RebeccaSkinner Welcome to our latest author spotlight, where we sit down with Rebecca Skinner, auth...
New

Latest in PragProg

View all threads ❯