Skip to content

Upgrade Bazel #2495

Closed
Closed

Description

@GMNGeoffrey

TF is now on Bazel 3.1.0. We're still on 2.1.0. I think we should upgrade for a few reasons:

  1. To match TF
  2. It includes a fix that allows us to build with asan (see Add config to build with asan #2490)

We'll need to upgrade the bazel version in our bazel docker container as well. Probably best to start out by installing both and then remove the old version once everything is switched over.

Issues I've run into so far with just naively upgrading:

  1. We have to upgrade bazel_toolchains as well, which means updating our super hacky patch of the bazel toolchains file (https://github.com/google/iree/blob/8078fc65b32bff36e65f919a4b8f9c331fab7726/build_tools/bazel/bazel_toolchains.patch) because make --experimental_repo_remote_exec compatible with rbe_autconfig bazelbuild/bazel#11029 still isn't submitted. I figured out how to do that by manually re-creating the changes there 🤮

  2. There's something going on with the rbe toolchain config that I don't quite understand. I think it might require updating the hash passed to rbe_autoconfig

    DEBUG: /usr/local/google/home/gcmn/.cache/bazel/_bazel_gcmn/c17d50ae90e3b490378de262a2ee1611/external/bazel_toolchains/rules/rbe_repo/checked_in.bzl:185:13: rbe_default not using checked in configs; config struct(config_repos = [], create_cc_configs = True, create_java_configs = True, env = {"ABI_LIBC_VERSION": "glibc_2.19", "ABI_VERSION": "clang", "BAZEL_COMPILER": "clang", "BAZEL_HOST_SYSTEM": "i686-unknown-linux-gnu", "BAZEL_TARGET_CPU": "k8", "BAZEL_TARGET_LIBC": "glibc_2.19", "BAZEL_TARGET_SYSTEM": "x86_64-unknown-linux-gnu", "CC": "clang", "CC_TOOLCHAIN_NAME": "linux_gnu_x86"}, java_home = "/usr/lib/jvm/java-8-openjdk-amd64", name = "10.0.0") was picked/selected, Bazel version 3.1.0 was picked/selected but no checked in config was found in ["11.0.0"]

  3. We're running into obnoxious TF toolchain errors again about numpy (Building TF requires Numpy for Python2 #1737).

    Details

    Repository rule local_python_configure defined at:
    /usr/local/google/home/gcmn/.cache/bazel/_bazel_gcmn/c17d50ae90e3b490378de262a2ee1611/external/org_tensorflow/third_party/py/python_configure.bzl:275:26: in

    ERROR: An error occurred during the fetch of repository 'local_execution_config_python':
    Traceback (most recent call last):
    File "/usr/local/google/home/gcmn/.cache/bazel/_bazel_gcmn/c17d50ae90e3b490378de262a2ee1611/external/org_tensorflow/third_party/py/python_configure.bz
    l", line 213
    _get_numpy_include(<2 more arguments>)
    File "/usr/local/google/home/gcmn/.cache/bazel/_bazel_gcmn/c17d50ae90e3b490378de262a2ee1611/external/org_tensorflow/third_party/py/python_configure.bz
    l", line 187, in _get_numpy_include
    execute(repository_ctx, <3 more arguments>)
    File "/usr/local/google/home/gcmn/.cache/bazel/_bazel_gcmn/c17d50ae90e3b490378de262a2ee1611/external/org_tensorflow/third_party/remote_config/common.b
    zl", line 208, in execute
    fail(<1 more arguments>)
    Problem getting numpy include path.
    Traceback (most recent call last):
    File "", line 1, in
    ModuleNotFoundError: No module named 'numpy'
    Is numpy installed?

Activity

  1. added
    infrastructure
    integrations/tensorflow
    on Jul 12, 2020
  2. GMNGeoffrey commented on Jul 12, 2020

    @GMNGeoffrey
    MemberAuthor

    #2496 is my draft of doing this. It solves Problem 1, but not 2&3.

  3. GMNGeoffrey commented on Jul 12, 2020

    @GMNGeoffrey
    MemberAuthor

    I think problem 3 actually comes from the bazel_toolchains upgrade, not the bazel upgrade, per se. Going back to bazel 2.1.0 but keeping the toolchains upgrade also creates the issue.

  4. GMNGeoffrey commented on Jul 12, 2020

    @GMNGeoffrey
    MemberAuthor

    Running pip3 install numpy on my local workstation appears to have fixed 3

  5. GMNGeoffrey commented on Jul 12, 2020

    @GMNGeoffrey
    MemberAuthor

    A new issue. Trying to actually build with rbe

    $ bazel test --config=rbe --config=rs //iree/vm:list_test
    https://source.cloud.google.com/results/invocations/24c8b008-3bf8-492a-816a-38d57f346ebf

    Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.40/containers/json: dial unix /var/run/docker.sock: connect: permission denied
    : Cannot run rbe_autoconfig as running '%s ps' returned a non 0 exit code, please check you have permissions to run docker. Error message: /usr/bin/docker

    This one actually appears to be dependent on the bazel version, as does issue 2 above. If I downgrade back to Bazel 2.1.0 the build passes

    https://source.cloud.google.com/results/invocations/7d01df42-a0c0-4675-95a0-0d74a9feed52

    So I'm guessing this is actually caused by the "checked in config" issue.

  6. GMNGeoffrey commented on Jul 12, 2020

    @GMNGeoffrey
    MemberAuthor

    Ah nevermind. It's caused by my user not being in the docker group. So fixed that one. I still see the warning about the checked in config, but appear to be able to run with RBE and Bazel 3.1.0

    https://source.cloud.google.com/results/invocations/ca57770b-6be6-4120-805f-d479f73432a5

  7. GMNGeoffrey commented on Jul 13, 2020

    @GMNGeoffrey
    MemberAuthor

    Ok I think I may have figured out the issue with that warning. RBE and Bazel have some complicated (undocumented) mapping logic to choose compatible versions. The RBE toolchain container I chose to upgrade to is for a later version of Bazel, so I have to use an earlier version, which I can figure out by reversing several map lookups in https://github.com/bazelbuild/bazel-toolchains/blob/df08996080601f04eeae7bd519b5126845928073/configs/ubuntu16_04_clang/versions.bzl

  8. GMNGeoffrey commented on Jul 13, 2020

    @GMNGeoffrey
    MemberAuthor
  9. GMNGeoffrey commented on Jul 13, 2020

    @GMNGeoffrey
    MemberAuthor

    And there are 6 options to choose from. Great.

  10. GMNGeoffrey commented on Jul 13, 2020

    @GMNGeoffrey
    MemberAuthor

    Ah wait. I can update to a later version of bazel_toolchains and now it works. Unclear why

  11. GMNGeoffrey commented on Jul 13, 2020

    @GMNGeoffrey
    MemberAuthor

    Scott has suggested trying a later version of Bazel to get bazelbuild/bazel@8b9f746. We need at least 3.3, and I'd be inclined to get the later patch, so 3.3.1. Looks like TF will accept any 3.x, so that should be fine. We could also go all the way to 3.4.0.

  12. GMNGeoffrey commented on Jul 13, 2020

    @GMNGeoffrey
    MemberAuthor

    Looks like bazel_toolchains doesn't support 3.4 yet. 3.3.1 it is!

  13. changed the title [-]Upgrade to Bazel 3.1.0[/-] [+]Upgrade Bazel[/+] on Jul 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    infrastructureintegrations/tensorflow

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions