jax-ml / jax

Composable transformations of Python+NumPy programs: differentiate, vectorize, JIT to GPU/TPU, and more
http://jax.readthedocs.io/
Apache License 2.0
29.98k stars 2.75k forks source link

jaxlib build fails on FreeBSD #6076

Open yurivict opened 3 years ago

yurivict commented 3 years ago
Analyzing: target //build:build_wheel (1 packages loaded, 0 targets configured)
DEBUG: Rule 'io_bazel_rules_docker' indicated that a canonical reproducible form can be obtained by modifying arguments shallow_since = "1556410077 -0400"
DEBUG: Repository io_bazel_rules_docker instantiated at:
  /usr/ports/math/py-jax/jax/WORKSPACE:34:10: in <toplevel>
  /usr/home/yuri/.cache/bazel/_bazel_yuri/324920dd194a60c357dae36bcca2577c/external/org_tensorflow/tensorflow/workspace0.bzl:105:34: in workspace
  /usr/home/yuri/.cache/bazel/_bazel_yuri/324920dd194a60c357dae36bcca2577c/external/bazel_toolchains/repositories/repositories.bzl:37:23: in repositories
Repository rule git_repository defined at:
  /usr/home/yuri/.cache/bazel/_bazel_yuri/324920dd194a60c357dae36bcca2577c/external/bazel_tools/tools/build_defs/repo/git.bzl:199:33: in <toplevel>
Analyzing: target //build:build_wheel (14 packages loaded, 13 targets configured)
Analyzing: target //build:build_wheel (14 packages loaded, 13 targets configured)
Analyzing: target //build:build_wheel (14 packages loaded, 13 targets configured)
Analyzing: target //build:build_wheel (139 packages loaded, 3068 targets configured)
INFO: Repository llvm-project instantiated at:
  /usr/ports/math/py-jax/jax/WORKSPACE:30:10: in <toplevel>
  /usr/home/yuri/.cache/bazel/_bazel_yuri/324920dd194a60c357dae36bcca2577c/external/org_tensorflow/tensorflow/workspace2.bzl:1083:21: in workspace
  /usr/home/yuri/.cache/bazel/_bazel_yuri/324920dd194a60c357dae36bcca2577c/external/org_tensorflow/tensorflow/workspace2.bzl:632:9: in _tf_repositories
  /usr/home/yuri/.cache/bazel/_bazel_yuri/324920dd194a60c357dae36bcca2577c/external/org_tensorflow/third_party/llvm/workspace.bzl:10:20: in repo
  /usr/home/yuri/.cache/bazel/_bazel_yuri/324920dd194a60c357dae36bcca2577c/external/org_tensorflow/third_party/repo.bzl:112:21: in tf_http_archive
Repository rule _tf_http_archive defined at:
  /usr/home/yuri/.cache/bazel/_bazel_yuri/324920dd194a60c357dae36bcca2577c/external/org_tensorflow/third_party/repo.bzl:65:35: in <toplevel>
INFO: Repository boringssl instantiated at:
  /usr/ports/math/py-jax/jax/WORKSPACE:30:10: in <toplevel>
  /usr/home/yuri/.cache/bazel/_bazel_yuri/324920dd194a60c357dae36bcca2577c/external/org_tensorflow/tensorflow/workspace2.bzl:1083:21: in workspace
  /usr/home/yuri/.cache/bazel/_bazel_yuri/324920dd194a60c357dae36bcca2577c/external/org_tensorflow/tensorflow/workspace2.bzl:670:20: in _tf_repositories
  /usr/home/yuri/.cache/bazel/_bazel_yuri/324920dd194a60c357dae36bcca2577c/external/org_tensorflow/third_party/repo.bzl:112:21: in tf_http_archive
Repository rule _tf_http_archive defined at:
  /usr/home/yuri/.cache/bazel/_bazel_yuri/324920dd194a60c357dae36bcca2577c/external/org_tensorflow/third_party/repo.bzl:65:35: in <toplevel>
INFO: Repository double_conversion instantiated at:
  /usr/ports/math/py-jax/jax/WORKSPACE:30:10: in <toplevel>
  /usr/home/yuri/.cache/bazel/_bazel_yuri/324920dd194a60c357dae36bcca2577c/external/org_tensorflow/tensorflow/workspace2.bzl:1083:21: in workspace
  /usr/home/yuri/.cache/bazel/_bazel_yuri/324920dd194a60c357dae36bcca2577c/external/org_tensorflow/tensorflow/workspace2.bzl:844:20: in _tf_repositories
  /usr/home/yuri/.cache/bazel/_bazel_yuri/324920dd194a60c357dae36bcca2577c/external/org_tensorflow/third_party/repo.bzl:112:21: in tf_http_archive
Repository rule _tf_http_archive defined at:
  /usr/home/yuri/.cache/bazel/_bazel_yuri/324920dd194a60c357dae36bcca2577c/external/org_tensorflow/third_party/repo.bzl:65:35: in <toplevel>
ERROR: While resolving toolchains for target @org_tensorflow//tensorflow/tools/git:gen_git_source: No matching toolchains found for types @bazel_tools//tools/cpp:toolchain_type. Maybe --incompatible_use_cc_configure_from_rules_cc has been flipped and there is no default C++ toolchain added in the WORKSPACE file? See https://github.com/bazelbuild/bazel/issues/10134 for details and migration instructions.
ERROR: Analysis of target '//build:build_wheel' failed; build aborted: No matching toolchains found for types @bazel_tools//tools/cpp:toolchain_type. Maybe --incompatible_use_cc_configure_from_rules_cc has been flipped and there is no default C++ toolchain added in the WORKSPACE file? See https://github.com/bazelbuild/bazel/issues/10134 for details and migration instructions.
INFO: Elapsed time: 59.817s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (141 packages loaded, 3079 targets configured)
ERROR: Build failed. Not running target
FAILED: Build did NOT complete successfully (141 packages loaded, 3079 targets configured)
Traceback (most recent call last):
  File "build/build.py", line 521, in <module>
    main()
  File "build/build.py", line 516, in main
    shell(command)
  File "build/build.py", line 51, in shell
    output = subprocess.check_output(cmd)
  File "/usr/local/lib/python3.7/subprocess.py", line 411, in check_output
    **kwargs).stdout
  File "/usr/local/lib/python3.7/subprocess.py", line 512, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['/usr/local/bin/bazel', 'run', '--verbose_failures=true', '--config=short_logs', '--config=mkl_open_source_only', ':build_wheel', '--', '--output_path=/usr/ports/math/py-jax/jax/dist']' returned non-zero exit status 1.

Compiler: clang-10 OS: FreeBSD 12.2

hawkinsp commented 3 years ago

We don't support FreeBSD ourselves. That said, we welcome PRs from the community to make FreeBSD work!

One general suggestion is that jaxlib reuses a lot of build infrastructure from TensorFlow. So I would first figure out what is needed to make TensorFlow build, and hopefully making jaxlib build is then a small extension (or none at all).

yurivict commented 3 years ago

TensorFlow can't be built on FreeBSD because Bazel can only work in Google's environment and isn't viable outside.

hawkinsp commented 3 years ago

bazel is open source and not specific to Google's environment. However I don't know what level of FreeBSD support it has.

As I mentioned, we don't have the engineering cycles to support FreeBSD ourselves. This is something the community will have to contribute, if there is interest. We welcome PRs!

yurivict commented 3 years ago

No, this isn't a matter of a level of OS support. It's a matter of bazel featureset being immature and WIP.

For example, Bazel project would assume that downloading files from the web/wan is fine, when it isn't fine for a package builder due to the build reproducibility requirement.

Bazel doesn't support easy switch to using pre-downloaded files, and doesn't play well with same software being installed from packages. It also fails with cryptic messages like the above one. Maybe these shortcomings aren't a big deal inside of Google, but they are a big deal outside.

No level of community support would ever help to fix that, especially when community primarily uses more mature tools like cmake and meson, and doesn't use bazel.

hawkinsp commented 3 years ago

We have no interest in supporting non-Bazel builds, I'm afraid. It would be a very large task to maintain a separate build system. Feel free to raise feature requests with the Bazel project, if it doesn't fulfill your needs.

It's also unlikely we can ever use many OS-vendored packages. For example, our single largest dependency (via XLA) is LLVM, but we track LLVM head very closely (e.g., there is no released version of LLVM that we can use or that most likely even builds, barring the specific commit hashes that we use. I doubt any version more than a few days old would work, given the frequency with which we submit changes upstream). That said, I believe the TensorFlow community is working on allowing more use of OS-vendored packages in cases where it makes sense, and we would inherit whatever work happens there for JAX. I should point out that's a relatively small amount of code for JAX, though.

Lilyo commented 3 years ago

Any updates?

jxy commented 2 years ago

https://github.com/bazelbuild/bazel/issues/13227#issuecomment-1185231470

Lilyo commented 2 years ago

Hi @jxy, Thank you for your reply.

fsmv commented 2 years ago

Thank you very much @jxy, your patches worked for me!

Hopefully we can get these checked into all the repos!

hawkinsp commented 2 years ago

As I mentioned on the Bazel issue, please send PRs and tag me. I'll review them.