Closed zacky1972 closed 2 years ago
Hi @zacky1972! Thanks for reporting the issue, and sorry I was busy with other things in the past 4 days. I'll look into this later today!
In my test I found that EXLA seems to require some setup when running in mix test
, but it works as expected when running with:
$ iex -S mix
iex> Mix.Tasks.Exla.Benchmark.run(["--backend", "EXLA.Backend"])
07:25:34.349 [info] XLA service 0x7f50544cc500 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
07:25:34.354 [info] StreamExecutor device (0): Host, Default Version
+---------------------+--------------+--------------+------------------+-----------------+----------------+-----------------+---------------+
| :callback | :data_type | :succeeded | :mean | :std | :min | :max | :note |
+---------------------+--------------+--------------+------------------+-----------------+----------------+-----------------+---------------+
| "Nx.dot/2" | :f32 | 5 | "805.279 µs" | "1.545 ms" | "27.4 µs" | "3.895 ms" | "100x100" |
| "Nx.dot/2" | :f64 | 5 | "22.644 µs" | "4.586 µs" | "18.98 µs" | "31.2 µs" | "100x100" |
| "Nx.constant/3" | :f32 | 5 | "39.6 µs" | "23.672 µs" | "25.14 µs" | "86.441 µs" | nil |
| "Nx.constant/3" | :f64 | 5 | "17.502 µs" | "10.831 µs" | "7.48 µs" | "34.991 µs" | nil |
+---------------------+--------------+--------------+------------------+-----------------+----------------+-----------------+---------------+
:ok
I'm unsure how to initialise EXLA (the XLA service) when running a mix task as it seems that erlang is complaining that the GenServer process is not alive or not started.
I saw that there is an EXLAHelper
in the EXLA tests, but I don’t know which code are the necessary steps to set up the XLA service…maybe @josevalim knows how to do that properly?
Make sure your mix tasks has:
@requirements [“app.start”]
So it starts the current app and all dependencies. :) does that work?
Oh, it works! Thank you @josevalim!
It works! Thanks!
$ mix exla.benchmark --backend EXLA.Backend
==> nx_scaffolding
Compiling 1 file (.ex)
Generated nx_scaffolding app
==> nx_scaffolding_test
Compiling 2 files (.ex)
Generated nx_scaffolding_test app
10:28:55.772 [info] XLA service 0x7f3abc7267e0 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
10:28:55.777 [info] StreamExecutor device (0): Host, Default Version
+---------------------+--------------+--------------+-----------------+-----------------+----------------+-----------------+---------------+
| :callback | :data_type | :succeeded | :mean | :std | :min | :max | :note |
+---------------------+--------------+--------------+-----------------+-----------------+----------------+-----------------+---------------+
| "Nx.dot/2" | :f32 | 5 | "1.576 ms" | "2.979 ms" | "57.3 µs" | "7.535 ms" | "100x100" |
| "Nx.dot/2" | :f64 | 5 | "78.314 µs" | "5.013 µs" | "71.53 µs" | "87.041 µs" | "100x100" |
| "Nx.constant/3" | :f32 | 5 | "37.722 µs" | "20.53 µs" | "26.61 µs" | "78.751 µs" | nil |
| "Nx.constant/3" | :f64 | 5 | "41.408 µs" | "14.234 µs" | "31.32 µs" | "68.92 µs" | nil |
+---------------------+--------------+--------------+-----------------+-----------------+----------------+-----------------+---------------+
mix.exs
:lib/mix/tasks/exla/backend.ex
Run the benchmark and I got the following error: