elixir-nx / nx

Multi-dimensional arrays (tensors) and numerical definitions for Elixir
2.55k stars 190 forks source link

Trouble pulling xla precompiled build #1508

Closed nickdichev-firework closed 4 weeks ago

nickdichev-firework commented 4 weeks ago

I recently started running into trouble with exla on my mac machines. I am using nix to manage my development environment, however, I am able to have the dep correctly pull the precompiled xla on my linux servers using the same nix inputs.

Here is the exla output:

==> exla
Unpacking /Users/firework/Library/Caches/xla/0.6.0/cache/download/xla_extension-x86_64-darwin-cpu.tar.gz into /Users/firework/Workspace/stream_vortex/deps/exla/cache
clang++ -fPIC -I/nix/store/l6h6d95dm9zkn2rhyxki79322h1pxpm7-erlang-26.2.5/lib/erlang/erts-14.2.5/include -Icache/xla_extension/include -Wall -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers -Wno-comment -shared -std=c++17 -w -DLLVM_VERSION_STRING= -O3 c_src/exla/exla.cc c_src/exla/exla_nif_util.cc c_src/exla/mlir/ops.cc c_src/exla/mlir/custom_calls.cc c_src/exla/mlir/builder.cc c_src/exla/exla_ops.cc c_src/exla/exla_client.cc -o cache/libexla.so -Lcache/xla_extension/lib -lxla_extension -flat_namespace -undefined suppress -rpath @loader_path/xla_extension/lib
c_src/exla/exla_client.cc:376:53: error: no viable conversion from '__libcpp_remove_reference_t<optional<string> &>' (aka 'std::optional<std::string>') to 'absl::optional<std::string>' (aka 'optional<basic_string<char>>')
  EXLA_ASSIGN_OR_RETURN(absl::optional<std::string> fingerprint,
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
c_src/exla/exla_nif_util.h:406:7: note: expanded from macro 'EXLA_ASSIGN_OR_RETURN'
      lhs, rexpr)
      ^~~~~~~~~~~
c_src/exla/exla_nif_util.h:413:3: note: expanded from macro 'EXLA_ASSIGN_OR_RETURN_IMPL'
  lhs = std::move(statusor.value());
  ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~
cache/xla_extension/include/absl/types/optional.h:136:13: note: candidate constructor not viable: no known conversion from '__libcpp_remove_reference_t<optional<string> &>' (aka 'std::optional<std::string>') to 'nullopt_t' for 1st argument
  constexpr optional(nullopt_t) noexcept {}  // NOLINT(runtime/explicit)
            ^
cache/xla_extension/include/absl/types/optional.h:139:3: note: candidate constructor not viable: no known conversion from '__libcpp_remove_reference_t<optional<string> &>' (aka 'std::optional<std::string>') to 'const optional<string> &' for 1st argument
  optional(const optional&) = default;
  ^
cache/xla_extension/include/absl/types/optional.h:142:3: note: candidate constructor not viable: no known conversion from '__libcpp_remove_reference_t<optional<string> &>' (aka 'std::optional<std::string>') to 'optional<string> &&' for 1st argument
  optional(optional&&) = default;
  ^
cache/xla_extension/include/absl/types/optional.h:178:13: note: candidate template ignored: requirement 'absl::conjunction<absl::negation<std::is_same<absl::in_place_t, std::optional<std::string>>>, absl::negation<std::is_same<absl::optional<std::string>, std::optional<std::string>>>, std::is_convertible<std::optional<std::string> &&, std::string>, std::is_constructible<std::string, std::optional<std::string> &&>>::value' was not satisfied [with U = __libcpp_remove_reference_t<optional<string> &>]
  constexpr optional(U&& v) : data_base(in_place_t(), absl::forward<U>(v)) {}
            ^
cache/xla_extension/include/absl/types/optional.h:205:3: note: candidate template ignored: could not match 'absl::optional' against 'std::optional'
  optional(const optional<U>& rhs) {
  ^
cache/xla_extension/include/absl/types/optional.h:239:3: note: candidate template ignored: could not match 'absl::optional' against 'std::optional'
  optional(optional<U>&& rhs) {
  ^
cache/xla_extension/include/absl/types/optional.h:152:22: note: explicit constructor is not a candidate
  constexpr explicit optional(InPlaceT, Args&&... args)

cache/xla_extension/include/absl/types/optional.h:191:22: note: explicit constructor is not a candidate
  explicit constexpr optional(U&& v)
                     ^
cache/xla_extension/include/absl/types/optional.h:222:12: note: explicit constructor is not a candidate
  explicit optional(const optional<U>& rhs) {
           ^
cache/xla_extension/include/absl/types/optional.h:256:12: note: explicit constructor is not a candidate
  explicit optional(optional<U>&& rhs) {
           ^
c_src/exla/exla_client.cc:412:53: error: no viable conversion from '__libcpp_remove_reference_t<optional<string> &>' (aka 'std::optional<std::string>') to 'absl::optional<std::string>' (aka 'optional<basic_string<char>>')
  EXLA_ASSIGN_OR_RETURN(absl::optional<std::string> fingerprint,
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
c_src/exla/exla_nif_util.h:406:7: note: expanded from macro 'EXLA_ASSIGN_OR_RETURN'
      lhs, rexpr)
      ^~~~~~~~~~~
c_src/exla/exla_nif_util.h:413:3: note: expanded from macro 'EXLA_ASSIGN_OR_RETURN_IMPL'
  lhs = std::move(statusor.value());
  ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~
cache/xla_extension/include/absl/types/optional.h:136:13: note: candidate constructor not viable: no known conversion from '__libcpp_remove_reference_t<optional<string> &>' (aka 'std::optional<std::string>') to 'nullopt_t' for 1st argument
  constexpr optional(nullopt_t) noexcept {}  // NOLINT(runtime/explicit)
            ^
cache/xla_extension/include/absl/types/optional.h:139:3: note: candidate constructor not viable: no known conversion from '__libcpp_remove_reference_t<optional<string> &>' (aka 'std::optional<std::string>') to 'const optional<string> &' for 1st argument
  optional(const optional&) = default;
  ^
cache/xla_extension/include/absl/types/optional.h:142:3: note: candidate constructor not viable: no known conversion from '__libcpp_remove_reference_t<optional<string> &>' (aka 'std::optional<std::string>') to 'optional<string> &&' for 1st argument
  optional(optional&&) = default;
  ^
cache/xla_extension/include/absl/types/optional.h:178:13: note: candidate template ignored: requirement 'absl::conjunction<absl::negation<std::is_same<absl::in_place_t, std::optional<std::string>>>, absl::negation<std::is_same<absl::optional<std::string>, std::optional<std::string>>>, std::is_convertible<std::optional<std::string> &&, std::string>, std::is_constructible<std::string, std::optional<std::string> &&>>::value' was not satisfied [with U = __libcpp_remove_reference_t<optional<string> &>]
  constexpr optional(U&& v) : data_base(in_place_t(), absl::forward<U>(v)) {}
            ^
cache/xla_extension/include/absl/types/optional.h:205:3: note: candidate template ignored: could not match 'absl::optional' against 'std::optional'
  optional(const optional<U>& rhs) {
  ^
cache/xla_extension/include/absl/types/optional.h:239:3: note: candidate template ignored: could not match 'absl::optional' against 'std::optional'
  optional(optional<U>&& rhs) {
  ^
cache/xla_extension/include/absl/types/optional.h:152:22: note: explicit constructor is not a candidate
  constexpr explicit optional(InPlaceT, Args&&... args)
                     ^
cache/xla_extension/include/absl/types/optional.h:191:22: note: explicit constructor is not a candidate
  explicit constexpr optional(U&& v)
                     ^
cache/xla_extension/include/absl/types/optional.h:222:12: note: explicit constructor is not a candidate
  explicit optional(const optional<U>& rhs) {
           ^
cache/xla_extension/include/absl/types/optional.h:256:12: note: explicit constructor is not a candidate
  explicit optional(optional<U>&& rhs) {
           ^
3 errors generated.
make: *** [Makefile:61: cache/libexla.so] Error 1
could not compile dependency :exla, "mix compile" failed. Errors may have been logged above. You can recompile this dependency with "mix deps.compile exla --force", update it with "mix deps.update exla" or clean it with "mix deps.clean exla"
==> stream_vortex
** (Mix) Could not compile with "make" (exit status: 2).
You need to have gcc and make installed. Try running the
commands "gcc --version" and / or "make --version". If these programs
are not installed, you will be prompted to install them.

one thing I immediately notice is odd is that it pulled an x86 xla tarball, but this system is a m1 pro, however, I am having the same problem on my x86 mac as well (although I dont have access to it right now to check what tarball is being used).

on this system:

~> gcc --version

Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: x86_64-apple-darwin22.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

however I noticed my linux env has gcc 13, which I started explicitly pinning in my nix env. There are still problems compiling the exla dependency on this setup but they are different.

Any ideas? Let me know if there are any other details you could use. Thanks in advance!

seanmor5 commented 4 weeks ago

When you run Elixir what value do you get for:

:erlang.system_info(:system_architecture)

Your GCC target is x86, is it running with Rosetta?

seanmor5 commented 4 weeks ago

Note if you continue to have issues, you can also force XLA to use a specific archive by setting XLA_ARCHIVE_URL, but it should auto detect the correct system based on your system info

nickdichev-firework commented 4 weeks ago

Thanks for putting me on the right track, I hadn't noticed that until today. Something strange is going on with my nix environment, will have to poke at that.