wwaldner

wwaldner

How to include Ortex in a Docker container?

I am trying to include Ortex in a docker container I am building. First started with Alpine container, and that is a no go. Alpine is going to be problematic because of the musl compiler…

Compiling lib/ortex/native.ex (it's taking more than 10s)
41.10    Compiling ureq v2.9.6
41.61    Compiling ort-sys v2.0.0-rc.8
41.98 error: failed to run custom build command for `ort-sys v2.0.0-rc.8`
41.98
41.98 Caused by:
41.98   process didn't exit successfully: `/app/_build/prod/lib/ortex/native/ortex/release/build/ort-sys-d7347b282fba238c/build-script-build` (exit status: 101)
41.98   --- stdout
41.98   cargo:rerun-if-env-changed=LIBONNXRUNTIME_NO_PKG_CONFIG
41.98   cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-alpine-linux-musl
41.98   cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_alpine_linux_musl
41.98   cargo:rerun-if-env-changed=HOST_PKG_CONFIG
41.98   cargo:rerun-if-env-changed=PKG_CONFIG
41.98   cargo:rerun-if-env-changed=LIBONNXRUNTIME_STATIC
41.98   cargo:rerun-if-env-changed=LIBONNXRUNTIME_DYNAMIC
41.98   cargo:rerun-if-env-changed=PKG_CONFIG_ALL_STATIC
41.98   cargo:rerun-if-env-changed=PKG_CONFIG_ALL_DYNAMIC
41.98   cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-alpine-linux-musl
41.98   cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_alpine_linux_musl
41.98   cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
41.98   cargo:rerun-if-env-changed=PKG_CONFIG_PATH
41.98   cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-alpine-linux-musl
41.98   cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_alpine_linux_musl
41.98   cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
41.98   cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
41.98   cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-alpine-linux-musl
41.98   cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_alpine_linux_musl
41.98   cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
41.98   cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
41.98   onnxruntime not found using pkg-config, falling back to manual setup.
41.98   cargo:rerun-if-env-changed=ORT_LIB_LOCATION
41.98   cargo:rerun-if-env-changed=ORT_LIB_PROFILE
41.98   cargo:rerun-if-env-changed=ORT_PREFER_DYNAMIC_LINK
41.98   selected feature set: none
41.98
41.98   --- stderr
41.98   thread 'main' panicked at /app/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ort-sys-2.0.0-rc.8/build.rs:360:17:
41.98   downloaded binaries not available for target x86_64-alpine-linux-musl
41.98   you may have to compile ONNX Runtime from source
41.98   note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
41.98 warning: build failed, waiting for other jobs to finish...
42.31
42.31 == Compilation error in file lib/ortex/native.ex ==
42.31 ** (RuntimeError) Rust NIF compile error (rustc exit code 101)
42.31     (rustler 0.35.1) lib/rustler/compiler.ex:36: Rustler.Compiler.compile_crate/3
42.31     lib/ortex/native.ex:11: (module)
42.31 could not compile dependency :ortex, "mix compile" failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile ortex --force", update it with "mix deps.update ortex" or clean it with "mix deps.clean ortex"

However, when I tried in a Debian container, I did not get much further…

.49 Compiling 6 files (.ex)
34.56 Generated rustler app
34.57 ==> ortex
34.57 Compiling 6 files (.ex)
34.60
34.60 == Compilation error in file lib/ortex/native.ex ==
34.60 ** (ErlangError) Erlang error: :enoent
34.60     (elixir 1.15.8) lib/system.ex:1111: System.cmd("cargo", ["metadata", "--format-version=1"], [cd: "native/ortex"])
34.60     (rustler 0.35.1) lib/rustler/compiler/config.ex:76: Rustler.Compiler.Config.metadata!/1
34.60     (rustler 0.35.1) lib/rustler/compiler/config.ex:63: Rustler.Compiler.Config.build/1
34.60     (rustler 0.35.1) lib/rustler/compiler.ex:8: Rustler.Compiler.compile_crate/3
34.60     lib/ortex/native.ex:11: (module)
34.60 could not compile dependency :ortex, "mix compile" failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile ortex --force", update it with "mix deps.update ortex" or clean it with "mix deps.clean ortex"
------
debian.Dockerfile:226
--------------------

Most Liked

D4no0

D4no0

Have you installed rust in the debian container? The error says that command cargo was not found.

dimitarvp

dimitarvp

Here are the two lines in my Dockerfiles that make Rust work just fine:

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable --profile minimal --target x86_64-unknown-linux-gnu -y

ENV PATH="/root/.cargo/bin:${PATH}"

(Obviously make sure the target is the right one i.e. there are plenty of ARM containers out there.)

The key is to not only install Rust via rustup but also “activate” a toolchain – in this case stable – which is very akin to how version managers like asdf / mise work: you (1) install a tool and (2) make a version active / default.

In the example above the --default-toolchain stable does that, or you can do it manually like so (put this in your Dockerfile after installing rustup and Rust through it):

rustup default stable
D4no0

D4no0

The way you want to usually separate the docker stages is that the first stage compiles and creates a release, and the second one is a clear linux container + runtime dependencies required when you are running the elixir release.

What you are currently doing doesn’t make much sense and I am amazed it works at all.

Where Next?

Popular in Questions Top

_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
JulienCorb
I am trying to implement my new.html.eex file to create new posts on my website. new.html.eex: <h1>Create Post</h1> <%= ...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

Other popular topics Top

sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 42920 311
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New

We're in Beta

About us Mission Statement