Bazel link to torch as external dependency

I use the following WORKSPACE rule:

git_repository(
    name = "pytorch",
    init_submodules = True,
    remote = "https://github.com/pytorch/pytorch.git",
    tag = "v1.7.1",
)

Everytime I try to invoke @pytorch//:torch I get Unable to find package for @pybind11_bazel//:build_defs.bzl: The repository '@pybind11_bazel' could not be resolved.

If I download the repo and link it with local_repository, the same problem happens.
If I download the repo and just bazel build :torch everything is fine. It seems that there’s something preventing the linking of pytorch as an external dependency.

Has anyone ran into this issue before? Any thoughts on what could have gone wrong?

1 Like

If I add pybind11_bazel to my WORKSPACE, the error becomes:
no such package 'tools/config': BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package: /home/usr_name/projects/tools/config
It seems that bazel is trying to resolve dependency from my local workspace instead of pytorch’s remote workspace.

@jackshi Hi Jack, do you solve the problem?