8
1
お題は不問!Qiita Engineer Festa 2024で記事投稿!
Qiita Engineer Festa20242024年7月17日まで開催中!

2024/06/21 現在 Axon ONNX を使う場合の注意(GutHubから最新を取得すること)

Last updated at Posted at 2024-06-21

はじめに

久しぶりに Livebook で Axon ONNX を使ってみたらインストールできなかったので共有します

実装したノートブックはこちら

モジュールのインストール

以下のように Axon を含むモジュールをインストールします

Mix.install(
  [
    {:exla, "~> 0.7"},
    {:axon_onnx, "~> 0.4"},
    {:stb_image, "~> 0.6"},
    {:req, "~> 0.5"},
    {:kino, "~> 0.13"}
  ],
  config: [nx: [default_backend: EXLA.Backend]]
)

すると、途中で以下のようにエラーが発生します

== Compilation error in file lib/axon_onnx/shared.ex ==
** (CompileError) lib/axon_onnx/shared.ex:58: undefined function transform/2 (there is no such import)
    (nx 0.7.2) lib/nx/defn/compiler.ex:832: Nx.Defn.Compiler.compile_error!/3
    (nx 0.7.2) lib/nx/defn/compiler.ex:429: Nx.Defn.Compiler.normalize/2
    (elixir 1.15.7) lib/enum.ex:1819: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
    (elixir 1.15.7) lib/enum.ex:1819: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
    (nx 0.7.2) lib/nx/defn/compiler.ex:422: Nx.Defn.Compiler.normalize/2
    (elixir 1.15.7) lib/enum.ex:1819: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
    (elixir 1.15.7) lib/enum.ex:1819: Enum."-map_reduce/3-lists^mapfoldl/2-0-"/3
    (nx 0.7.2) lib/nx/defn/compiler.ex:422: Nx.Defn.Compiler.normalize/2
could not compile dependency :axon_onnx, "mix compile" failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile axon_onnx --force", update it with "mix deps.update axon_onnx" or clean it with "mix deps.clean axon_onnx"

この問題は GitHub の Issue にも登録されており、最新のコードでは解消されていますが、まだリリースされていません

対処

Axon ONNX を GitHub から取得するため、コードを以下のように変更します

Mix.install(
  [
    {:exla, "~> 0.7"},
    {:axon_onnx, "~> 0.4", git: "https://github.com/mortont/axon_onnx/"},
    {:stb_image, "~> 0.6"},
    {:req, "~> 0.5"},
    {:kino, "~> 0.13"}
  ],
  config: [nx: [default_backend: EXLA.Backend]]
)

差分

-    {:axon_onnx, "~> 0.4"},
+    {:axon_onnx, "~> 0.4", git: "https://github.com/mortont/axon_onnx/"},

まとめ

エラーが出た場合、 GitHub の Issue を確認してみましょう

最新版では解消していることがあります

8
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
1