Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build on Windows #4843

Merged
merged 1 commit into from
Nov 19, 2020
Merged

Build on Windows #4843

merged 1 commit into from
Nov 19, 2020

Conversation

cloudhan
Copy link
Contributor

@cloudhan cloudhan commented Nov 9, 2020

Fix #438, Enables building jax natively on Windows.

@google-cla
Copy link

google-cla bot commented Nov 9, 2020

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added the cla: no label Nov 9, 2020
@cloudhan
Copy link
Contributor Author

cloudhan commented Nov 9, 2020

@googlebot I signed it!

@google-cla google-cla bot added cla: yes and removed cla: no labels Nov 9, 2020
WORKSPACE Outdated Show resolved Hide resolved
@cloudhan cloudhan changed the title [WIP] build on Windows WIP: build on Windows Nov 9, 2020
@cloudhan

This comment has been minimized.

Copy link
Collaborator

@hawkinsp hawkinsp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a promising start, although it seems some things are missing?

WORKSPACE Outdated Show resolved Hide resolved
build/BUILD.bazel Show resolved Hide resolved
@cloudhan
Copy link
Contributor Author

I rebuilt it with my local copy of latest tensorflow with patch tensorflow/tensorflow#44731, and jax now imports.

Copy link
Collaborator

@hawkinsp hawkinsp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

You say this allows JAX to build, which is a great start. Does it also allow some/all of the tests to pass?

WORKSPACE Outdated Show resolved Hide resolved
build/build.py Show resolved Hide resolved
build/build.py Outdated
@@ -206,14 +208,40 @@ def check_bazel_version(bazel_path, min_version, max_version):
build --define=no_ignite_support=true
build --define=grpc_no_ares=true

build --define=with_xla_support=true
build --action_env=TF_ENABLE_XLA=1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised these two are needed, but I would believe you if you say they are...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They seems to be left over during playing with bazelrc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

build/install_xla_in_source_tree.py Show resolved Hide resolved
r = runfiles.Create()

def _is_windows():
return sys.platform.startswith("win32")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: To be consistent with the other Python in the project, use 2-space indentation.

copy(r.Rlocation("org_tensorflow/tensorflow/compiler/xla/python/xla_extension.so"))
patch_copy_xla_client_py()

if _is_windows():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just negate the if condition and skip the pass case.

def patch_copy_xla_client_py(dst_dir=os.path.join(args.target, "jaxlib")):
with open(r.Rlocation("org_tensorflow/tensorflow/compiler/xla/python/xla_client.py")) as f:
src = f.read()
src = src.replace("from tensorflow.compiler.xla.python import xla_extension as _xla", "from . import xla_extension as _xla")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for this PR, but I'm reminded that we can probably avoid this by just changing the code in the TF tree.

jax/random.py Outdated
@@ -82,10 +82,10 @@ def PRNGKey(seed: int) -> jnp.ndarray:
if isinstance(seed, (int, np.ndarray)):
# Special handling of raw integer values, which may have be 64bit even
# when jax_enable_x64=False and we don't want to drop the top 32 bits
k1 = convert(np.bitwise_and(np.right_shift(seed, 32), 0xFFFFFFFF))
k1 = convert(np.bitwise_and(np.right_shift(seed, 32), np.uint32(0xFFFFFFFF)))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, what caused this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See that commit.

image

Simply put, 0xFFFFFFFF does not fit into 4bytes signed integer and is automatically promoted to 8bytes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jakevdp as an FYI

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I was curious why 0x7FFFFFFF is not 28bytes python object, then I found https://stackoverflow.com/a/10365639/2091555

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still not sure why this would differ between windows and linux/mac, however. That said, the change seems fine.

@cloudhan
Copy link
Contributor Author

test.log.zip

========= 164 failed, 9684 passed, 974 skipped in 2676.21s (0:44:36) ==========

Copy link
Collaborator

@hawkinsp hawkinsp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like great progress: I see from your test log that a majority of the tests pass!

I'd be happy to merge this as is, if you like (with the remaining items fixed) and to keep iterating in future PRs. Or you can keep iterating in this one. Up to you!



def copy(src_file, dst_dir=os.path.join(args.target, "jaxlib")):
# NOTE: this might be useful for debugging on Windows to inspect into the
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd just remove this kind of debugging code. It's better not to leave it cluttering things up.

jax/random.py Outdated
@@ -82,10 +82,10 @@ def PRNGKey(seed: int) -> jnp.ndarray:
if isinstance(seed, (int, np.ndarray)):
# Special handling of raw integer values, which may have be 64bit even
# when jax_enable_x64=False and we don't want to drop the top 32 bits
k1 = convert(np.bitwise_and(np.right_shift(seed, 32), 0xFFFFFFFF))
k1 = convert(np.bitwise_and(np.right_shift(seed, 32), np.uint32(0xFFFFFFFF)))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still not sure why this would differ between windows and linux/mac, however. That said, the change seems fine.

@cloudhan
Copy link
Contributor Author

@hawkinsp
Copy link
Collaborator

Just a heads-up: I made an additional edit on top of your if_nccl change to the TF tree: tensorflow/tensorflow@b7060f1

It appears we need both if_nccl and if_cuda.

@cloudhan cloudhan force-pushed the winbuild branch 2 times, most recently from 6292492 to 2b38e6a Compare November 17, 2020 12:24
@cloudhan
Copy link
Contributor Author

with JAX_ENABLE_X64=1 93 failed, 6583 passed
test.log.zip

and 15 of them should be caused by missing tensorflow.

@hawkinsp
Copy link
Collaborator

This looks pretty promising. Should we merge it as is and work on the remaining issues in subsequent PRs?

@enojoker
Copy link

really excited to find this. Thanks a lot for your guy's work. Is there a quick manual on how to test the build on windows?

@cloudhan
Copy link
Contributor Author

I might add some building instruction in this PR and then I think we are good to go.

@cloudhan cloudhan changed the title WIP: build on Windows Build on Windows Nov 18, 2020
Copy link
Collaborator

@hawkinsp hawkinsp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking pretty good! A couple of small edits.

build/build.py Show resolved Hide resolved
Additional Notes for Building ``jaxlib`` from source on Windows
...............................................................

On Windows, following `Install Visual Studio <https://docs.microsoft.com/en-us/visualstudio/install/install-visual-studio?view=vs-2019>`_
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor grammar edits:
"On Windows, follow "

`CUDA Installation Guide <https://docs.nvidia.com/cuda/cuda-installation-guide-microsoft-windows/index.html>`_
to setup CUDA environment.

Install `bazelisk <https://github.com/bazelbuild/bazelisk/releases/latest>`_.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually suspect this step is optional now the build.py script will download bazel for you on Windows.

pacman -S patch realpath


Once everything is installed. Open PowerShell, make sure you've added MSYS2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once everything is installed, open PowerShell, and make sure MSYS2 is in the path of the current session.


Once everything is installed. Open PowerShell, make sure you've added MSYS2
path to current session. Ensure ``bazel``, ``patch`` and ``realpath`` are
accessible. Activate conda environment. Folllowing command build with cuda
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Activate the conda environment. The following command builds with CUDA enabled::

--cuda_compute_capabilities='6.1' `
--cuda_version='10.1' `
--cudnn_version='7.6.5' `
--bazel_options='--copt' `
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would leave these out by default, and instead I would say something like "To build with debug information, add the flag: --bazel_options=--copt=/Z7."

Copy link
Contributor Author

@cloudhan cloudhan Nov 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These version things seem to be needed currently. Blame bazel xD

enabled with PDB generated, adjust it to whatever suitable for you.::
Once everything is installed. Open PowerShell, and make sure MSYS2 is in the
path of the current session. Ensure ``bazel``, ``patch`` and ``realpath`` are
accessible. Activate the conda environment. The folllowing command build with
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:
"The following command builds with CUDA enabled; adjust it to whatever is suitable for you::"
(Typo in "following"; "builds" needs an "s", and we need a break before "adjust")

docs/developer.rst Outdated Show resolved Hide resolved
@hawkinsp
Copy link
Collaborator

Please rebase on top of github head and squash your commits.

WORKSPACE Show resolved Hide resolved
@hawkinsp
Copy link
Collaborator

Would you mind removing the .bazelversion file from this PR (and squashing again)? It's no longer needed and is causing a problem with our CI. I'll add it separately in another PR.

1. Build on Windows

2. Fix OverflowError

    When calling `key = random.PRNGKey(0)` OverflowError: Python int too
    large to convert to C long for casting value 4294967295 (0xFFFFFFFF)
    from python int to int32.

3. fix file path in regex of errors_test

4. handle ValueError of os.path.commonpath
@hawkinsp
Copy link
Collaborator

Thanks @cloudhan ! This is awesome work!

@hawkinsp
Copy link
Collaborator

FYI, #4962 added the .bazelversion file back.

@steveyang687
Copy link

I encountered this when building GPU version. Bazel and MSYS2 are both installed. The only failure is the realpath in MSYS2 as the instruction says. Wonder what I missed
image

@steveyang687
Copy link

It seems this comes from cudaV11.x not storing its version info in cuda.h, and thus bazel cannot locate it anymore. Still stranded by it

@elephaint
Copy link

elephaint commented Feb 22, 2021

@steveyang687 Same error here, did you find a fix for this? I also could not install realpath with MSYS2, the package does not seem to exist; there is also no reference to it at the MSYS2 package repository .

Edit: you need to remove the accents from the version information, i.e. write:
--cuda_version=11.0

instead of:
--cuda_version='11.0'

However, it will then (still) fail on the absence of the realpath package:

afbeelding

@cloudhan
Copy link
Contributor Author

realpath is in coreutils package, install it with pacman -S coreutils in your msys2 bash command prompt.

@elephaint
Copy link

realpath is in coreutils package, install it with pacman -S coreutils in your msys2 bash command prompt.

Thanks, I installed coreutils from msys2 bash but I still get the same error though, probably because realpath still can't be found when executing the script. Any idea how I can make sure realpath is accessible?

@elchorro
Copy link

elchorro commented Mar 8, 2021

I tried building from source and after a while I am getting this error:
"Illegal ambiguous match on configurable attribute "deps" in @org_tensorflow//tensorflow/core/common_runtime:core_cpu_internal:
@org_tensorflow//tensorflow:windows
@org_tensorflow//tensorflow:with_tpu_support
Multiple matches are not allowed unless one is unambiguously more specialized."

I was using Bazel 3.7.2 but the same thing happens with Bazel 4.0.0. Any idea what might be happening?

image

@cloudhan
Copy link
Contributor Author

cloudhan commented Mar 9, 2021

@elchorro That might be due to upstream tensorflow introduce some conflicting configurations in some corner cases. You might want to play around with build/build.py with build:windows --define=with_tpu_support=false or something the like, maybe...

@hawkinsp
Copy link
Collaborator

hawkinsp commented Mar 9, 2021

@elchorro #5983 may have fixed that.

@steveyang687
Copy link

@steveyang687 Same error here, did you find a fix for this? I also could not install realpath with MSYS2, the package does not seem to exist; there is also no reference to it at the MSYS2 package repository .

Edit: you need to remove the accents from the version information, i.e. write:
--cuda_version=11.0

instead of:
--cuda_version='11.0'

However, it will then (still) fail on the absence of the realpath package:

afbeelding

I just build and install the CPU-only version since I dont use it for computation-intensive jobs lol :-(

@elchorro
Copy link

@steveyang687 @elephaint Is realpath accessible from MSYS prompt? I found it in msys64\usr\bin so I added it to path and it worked.

@caxelrud
Copy link

caxelrud commented Mar 21, 2021

Hi, I tried to build the "vanilla" version but I got the following error. Please, give me some ideas. Thanks!

python build\build.py --noenable_cuda --noenable_tpu

`     _   _  __  __
    | | / \ \ \/ /
 _  | |/ _ \ \  /
| |_| / ___ \/  \
 \___/_/   \/_/\_\


Starting local Bazel server and connecting to it...
Bazel binary path: C:\Apps\Bazel\bazel.EXE
Python binary path: C:/Users/inter/AppData/Local/Continuum/anaconda3/python.exe
Python version: 3.7
MKL-DNN enabled: yes
Target CPU features: release
CUDA enabled: no
TPU enabled: no
ROCm enabled: no

Building XLA and installing it in the jaxlib source tree...
C:\Apps\Bazel\bazel.EXE run --verbose_failures=true --config=short_logs --config=mkl_open_source_only :build_wheel -- --output_path=C:\Apps\jax\dist
INFO: Options provided by the client:
  Inherited 'common' options: --isatty=1 --terminal_columns=80
INFO: Reading rc options for 'run' from c:\apps\jax\.bazelrc:
  Inherited 'common' options: --experimental_repo_remote_exec
INFO: Options provided by the client:
  Inherited 'build' options: --python_path=C:/Users/inter/AppData/Local/Continuum/anaconda3/python.exe
INFO: Reading rc options for 'run' from c:\apps\jax\.bazelrc:
  Inherited 'build' options: --repo_env PYTHON_BIN_PATH=C:/Users/inter/AppData/Local/Continuum/anaconda3/python.exe --action_env=PYENV_ROOT --python_path=C:/Users/inter/AppData/Local/Continuum/anaconda3/python.exe --repo_env TF_NEED_CUDA=0 --action_env TF_CUDA_COMPUTE_CAPABILITIES=3.5,5.2,6.0,6.1,7.0 --repo_env TF_NEED_ROCM=0 --action_env TF_ROCM_AMDGPU_TARGETS=gfx803,gfx900,gfx906,gfx1010 --distinct_host_configuration=false -c opt --apple_platform_type=macos --macos_minimum_os=10.9 --announce_rc --define open_source_build=true --define=no_kafka_support=true --define=no_ignite_support=true --define=grpc_no_ares=true --spawn_strategy=standalone --strategy=Genrule=standalone --enable_platform_specific_config
INFO: Found applicable config definition build:short_logs in file c:\apps\jax\.bazelrc: --output_filter=DONT_MATCH_ANYTHING
INFO: Found applicable config definition build:mkl_open_source_only in file c:\apps\jax\.bazelrc: --define=tensorflow_mkldnn_contraction_kernel=1
INFO: Found applicable config definition build:windows in file c:\apps\jax\.bazelrc: --copt=/D_USE_MATH_DEFINES --host_copt=/D_USE_MATH_DEFINES --copt=-DWIN32_LEAN_AND_MEAN --host_copt=-DWIN32_LEAN_AND_MEAN --copt=-DNOGDI --host_copt=-DNOGDI --copt=/Zc:preprocessor --cxxopt=/std:c++14 --host_cxxopt=/std:c++14 --linkopt=/DEBUG --host_linkopt=/DEBUG --linkopt=/OPT:REF --host_linkopt=/OPT:REF --linkopt=/OPT:ICF --host_linkopt=/OPT:ICF --experimental_strict_action_env=true
INFO: Analyzed target //build:build_wheel (164 packages loaded, 13568 targets configured).
INFO: Found 1 target...
ERROR: C:/users/inter/_bazel_inter/iofngzaw/external/org_tensorflow/tensorflow/core/tpu/BUILD:105:11: Compiling tensorflow/core/tpu/tpu_initializer_helper.cc failed: (Exit 2): cl.exe failed: error executing command
  cd C:/users/inter/_bazel_inter/iofngzaw/execroot/__main__
  SET INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29910\include;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared;C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt
    SET PATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29910\bin\HostX64\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\VC\VCPackages;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\bin\Roslyn;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64\;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\devinit;C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x64;C:\Program Files (x86)\Windows Kits\10\bin\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\\MSBuild\Current\Bin;C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\;;C:\WINDOWS\system32;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja
    SET PWD=/proc/self/cwd
    SET RUNFILES_MANIFEST_ONLY=1
    SET TEMP=C:\Users\inter\AppData\Local\Temp
    SET TF_CUDA_COMPUTE_CAPABILITIES=3.5,5.2,6.0,6.1,7.0
    SET TF_ROCM_AMDGPU_TARGETS=gfx803,gfx900,gfx906,gfx1010
    SET TMP=C:\Users\inter\AppData\Local\Temp
  C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.28.29910/bin/HostX64/x64/cl.exe /nologo /DCOMPILER_MSVC /DNOMINMAX /D_WIN32_WINNT=0x0601 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /bigobj /Zm500 /EHsc /wd4351 /wd4291 /wd4250 /wd4996 /Iexternal/org_tensorflow /Ibazel-out/x64_windows-opt/bin/external/org_tensorflow /Iexternal/eigen_archive /Ibazel-out/x64_windows-opt/bin/external/eigen_archive /Iexternal/com_google_absl /Ibazel-out/x64_windows-opt/bin/external/com_google_absl /Iexternal/nsync /Ibazel-out/x64_windows-opt/bin/external/nsync /Iexternal/eigen_archive /Ibazel-out/x64_windows-opt/bin/external/eigen_archive /Iexternal/nsync/public /Ibazel-out/x64_windows-opt/bin/external/nsync/public /DEIGEN_MPL2_ONLY /DEIGEN_MAX_ALIGN_BYTES=64 /D__CLANG_SUPPORT_DYN_ANNOTATION__ /showIncludes /MD /O2 /Oy- /DNDEBUG /wd4117 -D__DATE__="redacted" -D__TIMESTAMP__="redacted" -D__TIME__="redacted" /Gy /Gw /D_USE_MATH_DEFINES -DWIN32_LEAN_AND_MEAN -DNOGDI /Zc:preprocessor /std:c++14 /Fobazel-out/x64_windows-opt/bin/external/org_tensorflow/tensorflow/core/tpu/_objs/tpu_initializer_helper/tpu_initializer_helper.obj /c external/org_tensorflow/tensorflow/core/tpu/tpu_initializer_helper.cc
Execution platform: @local_execution_config_platform//:platform
Target //build:build_wheel failed to build
INFO: Elapsed time: 239.300s, Critical Path: 23.89s
INFO: 635 processes: 68 internal, 567 local.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully
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 "C:\Users\inter\AppData\Local\Continuum\anaconda3\lib\subprocess.py", line 411, in check_output
    **kwargs).stdout
  File "C:\Users\inter\AppData\Local\Continuum\anaconda3\lib\subprocess.py", line 512, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['C:\\Apps\\Bazel\\bazel.EXE', 'run', '--verbose_failures=true', '--config=short_logs', '--config=mkl_open_source_only', ':build_wheel', '--', '--output_path=C:\\Apps\\jax\\dist']' returned non-zero exit status 1.

@caxelrud
Copy link

Hi, tried with all "--noenable" and got a different error. Any help?

python build\build.py --noenable_cuda --noenable_tpu --noenable_mkl_dnn --noenable_rocm

ERROR: C:/users/inter/_bazel_inter/iofngzaw/external/llvm-project/llvm/BUILD:4037:11: Compiling llvm/lib/Support/COM.cpp failed: (Exit 2): cl.exe failed: error

python build\build.py --noenable_cuda --noenable_tpu --noenable_mkl_dnn --noenable_rocm

     _   _  __  __
    | | / \ \ \/ /
 _  | |/ _ \ \  /
| |_| / ___ \/  \
 \___/_/   \/_/\_\


Starting local Bazel server and connecting to it...
Bazel binary path: C:\Apps\Bazel\bazel.EXE
Python binary path: C:/Users/inter/AppData/Local/Continuum/anaconda3/python.exe
Python version: 3.7
MKL-DNN enabled: no
Target CPU features: release
CUDA enabled: no
TPU enabled: no
ROCm enabled: no

Building XLA and installing it in the jaxlib source tree...
C:\Apps\Bazel\bazel.EXE run --verbose_failures=true --config=short_logs :build_wheel -- --output_path=C:\Apps\jax\dist
INFO: Options provided by the client:
  Inherited 'common' options: --isatty=1 --terminal_columns=80
INFO: Reading rc options for 'run' from c:\apps\jax\.bazelrc:
  Inherited 'common' options: --experimental_repo_remote_exec
INFO: Options provided by the client:
  Inherited 'build' options: --python_path=C:/Users/inter/AppData/Local/Continuum/anaconda3/python.exe
INFO: Reading rc options for 'run' from c:\apps\jax\.bazelrc:
  Inherited 'build' options: --repo_env PYTHON_BIN_PATH=C:/Users/inter/AppData/Local/Continuum/anaconda3/python.exe --action_env=PYENV_ROOT --python_path=C:/Users/inter/AppData/Local/Continuum/anaconda3/python.exe --repo_env TF_NEED_CUDA=0 --action_env TF_CUDA_COMPUTE_CAPABILITIES=3.5,5.2,6.0,6.1,7.0 --repo_env TF_NEED_ROCM=0 --action_env TF_ROCM_AMDGPU_TARGETS=gfx803,gfx900,gfx906,gfx1010 --distinct_host_configuration=false -c opt --apple_platform_type=macos --macos_minimum_os=10.9 --announce_rc --define open_source_build=true --define=no_kafka_support=true --define=no_ignite_support=true --define=grpc_no_ares=true --spawn_strategy=standalone --strategy=Genrule=standalone --enable_platform_specific_config
INFO: Found applicable config definition build:short_logs in file c:\apps\jax\.bazelrc: --output_filter=DONT_MATCH_ANYTHING
INFO: Found applicable config definition build:windows in file c:\apps\jax\.bazelrc: --copt=/D_USE_MATH_DEFINES --host_copt=/D_USE_MATH_DEFINES --copt=-DWIN32_LEAN_AND_MEAN --host_copt=-DWIN32_LEAN_AND_MEAN --copt=-DNOGDI --host_copt=-DNOGDI --copt=/Zc:preprocessor --cxxopt=/std:c++14 --host_cxxopt=/std:c++14 --linkopt=/DEBUG --host_linkopt=/DEBUG --linkopt=/OPT:REF --host_linkopt=/OPT:REF --linkopt=/OPT:ICF --host_linkopt=/OPT:ICF --experimental_strict_action_env=true
INFO: Analyzed target //build:build_wheel (164 packages loaded, 13568 targets configured).
INFO: Found 1 target...
ERROR: C:/users/inter/_bazel_inter/iofngzaw/external/llvm-project/llvm/BUILD:4037:11: Compiling llvm/lib/Support/COM.cpp failed: (Exit 2): cl.exe failed: error executing command
  cd C:/users/inter/_bazel_inter/iofngzaw/execroot/__main__
  SET INCLUDE=C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29910\include;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\shared;C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\um;C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\winrt;C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\cppwinrt
    SET PATH=C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29910\bin\HostX64\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\VC\VCPackages;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\CommonExtensions\Microsoft\TestWindow;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\bin\Roslyn;C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64\;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\devinit;C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x64;C:\Program Files (x86)\Windows Kits\10\bin\x64;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\\MSBuild\Current\Bin;C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\;;C:\WINDOWS\system32;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin;C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja
    SET PWD=/proc/self/cwd
    SET RUNFILES_MANIFEST_ONLY=1
    SET TEMP=C:\Users\inter\AppData\Local\Temp
    SET TF_CUDA_COMPUTE_CAPABILITIES=3.5,5.2,6.0,6.1,7.0
    SET TF_ROCM_AMDGPU_TARGETS=gfx803,gfx900,gfx906,gfx1010
    SET TMP=C:\Users\inter\AppData\Local\Temp
  C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.28.29910/bin/HostX64/x64/cl.exe /nologo /DCOMPILER_MSVC /DNOMINMAX /D_WIN32_WINNT=0x0601 /D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /bigobj /Zm500 /EHsc /wd4351 /wd4291 /wd4250 /wd4996 /Iexternal/llvm-project /Ibazel-out/x64_windows-opt/bin/external/llvm-project /Iexternal/zlib /Ibazel-out/x64_windows-opt/bin/external/zlib /Iexternal/llvm-project/llvm/include /Ibazel-out/x64_windows-opt/bin/external/llvm-project/llvm/include /Iexternal/zlib /Ibazel-out/x64_windows-opt/bin/external/zlib /D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_NONSTDC_NO_WARNINGS /D_SCL_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_WARNINGS /DUNICODE /D_UNICODE /DLLVM_ENABLE_STATS /D__STDC_LIMIT_MACROS /D__STDC_CONSTANT_MACROS /D__STDC_FORMAT_MACROS /DLLVM_BUILD_GLOBAL_ISEL /showIncludes /MD /O2 /Oy- /DNDEBUG /wd4117 -D__DATE__="redacted" -D__TIMESTAMP__="redacted" -D__TIME__="redacted" /Gy /Gw /D_USE_MATH_DEFINES -DWIN32_LEAN_AND_MEAN -DNOGDI /Zc:preprocessor /std:c++14 -Zc:inline -Zc:strictStrings -Zc:rvalueCast -Oi -wd4141 -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 -wd4291 -wd4345 -wd4351 -wd4355 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4800 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4324 -w14062 -we4238 /Fobazel-out/x64_windows-opt/bin/external/llvm-project/llvm/_objs/Support/COM.obj /c external/llvm-project/llvm/lib/Support/COM.cpp
Execution platform: @local_execution_config_platform//:platform
Target //build:build_wheel failed to build
INFO: Elapsed time: 47.089s, Critical Path: 21.87s
INFO: 158 processes: 12 internal, 146 local.
FAILED: Build did NOT complete successfully
FAILED: Build did NOT complete successfully
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 "C:\Users\inter\AppData\Local\Continuum\anaconda3\lib\subprocess.py", line 411, in check_output
    **kwargs).stdout
  File "C:\Users\inter\AppData\Local\Continuum\anaconda3\lib\subprocess.py", line 512, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['C:\\Apps\\Bazel\\bazel.EXE', 'run', '--verbose_failures=true', '--config=short_logs', ':build_wheel', '--', '--output_path=C:\\Apps\\jax\\dist']' returned non-zero exit status 1.

@caxelrud
Copy link

I have a question about where is the appropriate environment to build JAXLIB. For my Windows 10 installation I could do it in:

  • CMD (Administrator)
  • Developer Command Prompt for VS2019
  • Developer Powershell for VS2019
  • x64 Native Tools Command Prompt for VS2019
  • x86 Native Tools Command Prompt for VS2019
  • x64_x86 Cross Tools Command Prompt for VS2019
  • Anaconda Prompt
    Thanks!

fonnesbeck referenced this pull request in pymc-devs/pymc Sep 27, 2021
@cloudhan cloudhan deleted the winbuild branch October 11, 2021 06:39
@illtellyoulater
Copy link

illtellyoulater commented Mar 24, 2022

After launching the compilation with:

python build/build.py --enable_cuda --cuda_version 11.6 --cudnn_version 8.3.3

at some point I get the following error:

ERROR: An error occurred during the fetch of repository 'llvm-project':
   Traceback (most recent call last):
        File "C:/users/my-name/_bazel_my-name/jhqpq4oj/external/llvm-raw/utils/bazel/configure.bzl", line 73, column 25, in _llvm_configure_impl
                _overlay_directories(repository_ctx)
        File "C:/users/my-name/_bazel_my-name/jhqpq4oj/external/llvm-raw/utils/bazel/configure.bzl", line 62, column 13, in _overlay_directories
                fail(("Failed to execute overlay script: '{cmd}'\n" +
Error in fail: Failed to execute overlay script: 'C:/Users/my-name/.conda/envs/my-env/python.exe C:/users/my-name/_bazel_my-name/jhqpq4oj/external/llvm-raw/utils/bazel/overlay_directories.py --src C:/users/my-name/_bazel_my-name/jhqpq4oj/external/llvm-raw --overlay C:/users/my-name/_bazel_my-name/jhqpq4oj/external/llvm-raw/utils/bazel/llvm-project-overlay --target .'
Exited with code 1

Does anyone know how to fix it?


Full build output:

$ python build/build.py --enable_cuda --cuda_version 11.6 --cudnn_version 8.3.3

Starting local Bazel server and connecting to it...
WARNING: Option 'experimental_strict_action_env' is deprecated: Use --incompatible_strict_action_env instead
INFO: Options provided by the client:
  Inherited 'common' options: --isatty=0 --terminal_columns=80
INFO: Reading rc options for 'run' from c:\users\my-name\downloads\jax\.bazelrc:
  Inherited 'common' options: --experimental_repo_remote_exec
INFO: Options provided by the client:
  Inherited 'build' options: --python_path=C:/Users/my-name/.conda/envs/my-env/python.exe
INFO: Reading rc options for 'run' from c:\users\my-name\downloads\jax\.bazelrc:
  Inherited 'build' options: --apple_platform_type=macos --macos_minimum_os=10.9 --announce_rc --define open_source_build=true --spawn_strategy=standalone --enable_platform_specific_config --define=no_aws_support=true --define=no_gcp_support=true --define=no_hdfs_support=true --define=no_kafka_support=true --define=no_ignite_support=true --define=grpc_no_ares=true -c opt --config=short_logs --copt=-DMLIR_PYTHON_PACKAGE_PREFIX=jaxlib.mlir.
INFO: Reading rc options for 'run' from c:\users\my-name\downloads\jax\.jax_configure.bazelrc:
  Inherited 'build' options: --strategy=Genrule=standalone --repo_env PYTHON_BIN_PATH=C:/Users/my-name/.conda/envs/my-env/python.exe --action_env=PYENV_ROOT --python_path=C:/Users/my-name/.conda/envs/my-env/python.exe --action_env TF_CUDA_VERSION=11.6 --action_env TF_CUDNN_VERSION=8.3.3 --distinct_host_configuration=false
INFO: Found applicable config definition build:short_logs in file c:\users\my-name\downloads\jax\.bazelrc: --output_filter=DONT_MATCH_ANYTHING
INFO: Found applicable config definition build:mkl_open_source_only in file c:\users\my-name\downloads\jax\.bazelrc: --define=tensorflow_mkldnn_contraction_kernel=1
INFO: Found applicable config definition build:cuda in file c:\users\my-name\downloads\jax\.bazelrc: --repo_env TF_NEED_CUDA=1 --action_env TF_CUDA_COMPUTE_CAPABILITIES=3.5,5.2,6.0,7.0,8.0 --crosstool_top=@local_config_cuda//crosstool:toolchain --@local_config_cuda//:enable_cuda --define=xla_python_enable_gpu=true
INFO: Found applicable config definition build:cuda in file c:\users\my-name\downloads\jax\.jax_configure.bazelrc: --action_env TF_CUDA_COMPUTE_CAPABILITIES=3.5,5.2,6.0,7.0,8.0
INFO: Found applicable config definition build:windows in file c:\users\my-name\downloads\jax\.bazelrc: --copt=/D_USE_MATH_DEFINES --host_copt=/D_USE_MATH_DEFINES --copt=-DWIN32_LEAN_AND_MEAN --host_copt=-DWIN32_LEAN_AND_MEAN --copt=-DNOGDI --host_copt=-DNOGDI --copt=/Zc:preprocessor --cxxopt=/std:c++14 --host_cxxopt=/std:c++14 --linkopt=/DEBUG --host_linkopt=/DEBUG --linkopt=/OPT:REF --host_linkopt=/OPT:REF --linkopt=/OPT:ICF --host_linkopt=/OPT:ICF --experimental_strict_action_env=true
Loading:
Loading: 1 packages loaded
Analyzing: target //build:build_wheel (2 packages loaded, 0 targets configured)
Analyzing: target //build:build_wheel (35 packages loaded, 12 targets configured)
Analyzing: target //build:build_wheel (36 packages loaded, 13 targets configured)
Analyzing: target //build:build_wheel (66 packages loaded, 337 targets configured)
INFO: Repository llvm-project instantiated at:
  C:/users/my-name/downloads/jax/WORKSPACE:31:14: in <toplevel>
  C:/users/my-name/_bazel_my-name/jhqpq4oj/external/org_tensorflow/tensorflow/workspace2.bzl:878:21: in workspace
  C:/users/my-name/_bazel_my-name/jhqpq4oj/external/org_tensorflow/tensorflow/workspace2.bzl:518:15: in _tf_repositories
  C:/users/my-name/_bazel_my-name/jhqpq4oj/external/org_tensorflow/third_party/llvm/setup.bzl:22:19: in llvm_setup
Repository rule llvm_configure defined at:
  C:/users/my-name/_bazel_my-name/jhqpq4oj/external/llvm-raw/utils/bazel/configure.bzl:83:33: in <toplevel>
ERROR: An error occurred during the fetch of repository 'llvm-project':
   Traceback (most recent call last):
        File "C:/users/my-name/_bazel_my-name/jhqpq4oj/external/llvm-raw/utils/bazel/configure.bzl", line 73, column 25, in _llvm_configure_impl
                _overlay_directories(repository_ctx)
        File "C:/users/my-name/_bazel_my-name/jhqpq4oj/external/llvm-raw/utils/bazel/configure.bzl", line 62, column 13, in _overlay_directories
                fail(("Failed to execute overlay script: '{cmd}'\n" +
Error in fail: Failed to execute overlay script: 'C:/Users/my-name/.conda/envs/my-env/python.exe C:/users/my-name/_bazel_my-name/jhqpq4oj/external/llvm-raw/utils/bazel/overlay_directories.py --src C:/users/my-name/_bazel_my-name/jhqpq4oj/external/llvm-raw --overlay C:/users/my-name/_bazel_my-name/jhqpq4oj/external/llvm-raw/utils/bazel/llvm-project-overlay --target .'
Exited with code 1
stdout:

stderr:
Traceback (most recent call last):
  File "C:\users\my-name\_bazel_my-name\jhqpq4oj\external\llvm-raw\utils\bazel\overlay_directories.py", line 92, in <module>
    main(parse_arguments())
  File "C:\users\my-name\_bazel_my-name\jhqpq4oj\external\llvm-raw\utils\bazel\overlay_directories.py", line 80, in main
    _symlink_abs(os.path.join(args.overlay, relpath),
  File "C:\users\my-name\_bazel_my-name\jhqpq4oj\external\llvm-raw\utils\bazel\overlay_directories.py", line 64, in _symlink_abs
    os.symlink(os.path.abspath(from_path), os.path.abspath(to_path))
OSError: [WinError 1314] Il privilegio richiesto non appartiene al client: 'C:\\users\\my-name\\_bazel_my-name\\jhqpq4oj\\external\\llvm-raw\\utils\\bazel\\llvm-project-overlay\\.bazelignore' -> 'C:\\users\\my-name\\_bazel_my-name\\jhqpq4oj\\external\\llvm-project\\.bazelignore'

ERROR: C:/users/my-name/downloads/jax/WORKSPACE:31:14: fetching llvm_configure rule //external:llvm-project: Traceback (most recent call last):
        File "C:/users/my-name/_bazel_my-name/jhqpq4oj/external/llvm-raw/utils/bazel/configure.bzl", line 73, column 25, in _llvm_configure_impl
                _overlay_directories(repository_ctx)
        File "C:/users/my-name/_bazel_my-name/jhqpq4oj/external/llvm-raw/utils/bazel/configure.bzl", line 62, column 13, in _overlay_directories
                fail(("Failed to execute overlay script: '{cmd}'\n" +
Error in fail: Failed to execute overlay script: 'C:/Users/my-name/.conda/envs/my-env/python.exe C:/users/my-name/_bazel_my-name/jhqpq4oj/external/llvm-raw/utils/bazel/overlay_directories.py --src C:/users/my-name/_bazel_my-name/jhqpq4oj/external/llvm-raw --overlay C:/users/my-name/_bazel_my-name/jhqpq4oj/external/llvm-raw/utils/bazel/llvm-project-overlay --target .'
Exited with code 1
stdout:

stderr:
Traceback (most recent call last):
  File "C:\users\my-name\_bazel_my-name\jhqpq4oj\external\llvm-raw\utils\bazel\overlay_directories.py", line 92, in <module>
    main(parse_arguments())
  File "C:\users\my-name\_bazel_my-name\jhqpq4oj\external\llvm-raw\utils\bazel\overlay_directories.py", line 80, in main
    _symlink_abs(os.path.join(args.overlay, relpath),
  File "C:\users\my-name\_bazel_my-name\jhqpq4oj\external\llvm-raw\utils\bazel\overlay_directories.py", line 64, in _symlink_abs
    os.symlink(os.path.abspath(from_path), os.path.abspath(to_path))
OSError: [WinError 1314] Il privilegio richiesto non appartiene al client: 'C:\\users\\my-name\\_bazel_my-name\\jhqpq4oj\\external\\llvm-raw\\utils\\bazel\\llvm-project-overlay\\.bazelignore' -> 'C:\\users\\my-name\\_bazel_my-name\\jhqpq4oj\\external\\llvm-project\\.bazelignore'

INFO: Repository six_archive instantiated at:
  C:/users/my-name/downloads/jax/WORKSPACE:31:14: in <toplevel>
  C:/users/my-name/_bazel_my-name/jhqpq4oj/external/org_tensorflow/tensorflow/workspace2.bzl:878:21: in workspace
  C:/users/my-name/_bazel_my-name/jhqpq4oj/external/org_tensorflow/tensorflow/workspace2.bzl:318:20: in _tf_repositories
  C:/users/my-name/_bazel_my-name/jhqpq4oj/external/org_tensorflow/third_party/repo.bzl:128:21: in tf_http_archive
Repository rule _tf_http_archive defined at:
  C:/users/my-name/_bazel_my-name/jhqpq4oj/external/org_tensorflow/third_party/repo.bzl:81:35: in <toplevel>
INFO: Repository com_google_absl instantiated at:
  C:/users/my-name/downloads/jax/WORKSPACE:31:14: in <toplevel>
  C:/users/my-name/_bazel_my-name/jhqpq4oj/external/org_tensorflow/tensorflow/workspace2.bzl:871:28: in workspace
  C:/users/my-name/_bazel_my-name/jhqpq4oj/external/org_tensorflow/tensorflow/workspace2.bzl:59:9: in _initialize_third_party
  C:/users/my-name/_bazel_my-name/jhqpq4oj/external/org_tensorflow/third_party/absl/workspace.bzl:39:20: in repo
  C:/users/my-name/_bazel_my-name/jhqpq4oj/external/org_tensorflow/third_party/repo.bzl:128:21: in tf_http_archive
Repository rule _tf_http_archive defined at:
  C:/users/my-name/_bazel_my-name/jhqpq4oj/external/org_tensorflow/third_party/repo.bzl:81:35: in <toplevel>
ERROR: C:/users/my-name/downloads/jax/jaxlib/mlir/BUILD.bazel:71:15: //jaxlib/mlir:_builtin_dialect_srcs depends on @llvm-project//mlir/python:BuiltinOpsPyFiles in repository @llvm-project which failed to fetch. no such package '@llvm-project//mlir/python': Failed to execute overlay script: 'C:/Users/my-name/.conda/envs/my-env/python.exe C:/users/my-name/_bazel_my-name/jhqpq4oj/external/llvm-raw/utils/bazel/overlay_directories.py --src C:/users/my-name/_bazel_my-name/jhqpq4oj/external/llvm-raw --overlay C:/users/my-name/_bazel_my-name/jhqpq4oj/external/llvm-raw/utils/bazel/llvm-project-overlay --target .'
Exited with code 1
stdout:

stderr:
Traceback (most recent call last):
  File "C:\users\my-name\_bazel_my-name\jhqpq4oj\external\llvm-raw\utils\bazel\overlay_directories.py", line 92, in <module>
    main(parse_arguments())
  File "C:\users\my-name\_bazel_my-name\jhqpq4oj\external\llvm-raw\utils\bazel\overlay_directories.py", line 80, in main
    _symlink_abs(os.path.join(args.overlay, relpath),
  File "C:\users\my-name\_bazel_my-name\jhqpq4oj\external\llvm-raw\utils\bazel\overlay_directories.py", line 64, in _symlink_abs
    os.symlink(os.path.abspath(from_path), os.path.abspath(to_path))
OSError: [WinError 1314] Il privilegio richiesto non appartiene al client: 'C:\\users\\my-name\\_bazel_my-name\\jhqpq4oj\\external\\llvm-raw\\utils\\bazel\\llvm-project-overlay\\.bazelignore' -> 'C:\\users\\my-name\\_bazel_my-name\\jhqpq4oj\\external\\llvm-project\\.bazelignore'

ERROR: Analysis of target '//build:build_wheel' failed; build aborted:
INFO: Elapsed time: 10.372s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (66 packages loaded, 338 targets configured)
ERROR: Build failed. Not running target
FAILED: Build did NOT complete successfully (66 packages loaded, 338 targets configured)

     _   _  __  __
    | | / \ \ \/ /
 _  | |/ _ \ \  /
| |_| / ___ \/  \
 \___/_/   \/_/\_\


Bazel binary path: .\bazel-5.0.0-windows-x86_64.exe
Bazel version: 5.0.0
Python binary path: C:/Users/my-name/.conda/envs/my-env/python.exe
Python version: 3.9
NumPy version: 1.21.5
MKL-DNN enabled: yes
Target CPU: AMD64
Target CPU features: release
CUDA enabled: yes
CUDA compute capabilities: 3.5,5.2,6.0,7.0,8.0
CUDA version: 11.6
CUDNN version: 8.3.3
NCCL enabled: yes
TPU enabled: no
ROCm enabled: no

Building XLA and installing it in the jaxlib source tree...
.\bazel-5.0.0-windows-x86_64.exe run --verbose_failures=true --config=mkl_open_source_only --config=cuda :build_wheel -- --output_path=C:\Users\my-name\Downloads\jax\dist --cpu=AMD64
b''
Traceback (most recent call last):
  File "C:\Users\my-name\Downloads\jax\build\build.py", line 527, in <module>
    main()
  File "C:\Users\my-name\Downloads\jax\build\build.py", line 522, in main
    shell(command)
  File "C:\Users\my-name\Downloads\jax\build\build.py", line 53, in shell
    output = subprocess.check_output(cmd)
  File "C:\Users\my-name\.conda\envs\my-env\lib\subprocess.py", line 424, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "C:\Users\my-name\.conda\envs\my-env\lib\subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['.\\bazel-5.0.0-windows-x86_64.exe', 'run', '--verbose_failures=true', '--config=mkl_open_source_only', '--config=cuda', ':build_wheel', '--', '--output_path=C:\\Users\\my-name\\Downloads\\jax\\dist', '--cpu=AMD64']' returned non-zero exit status 1.

@illtellyoulater
Copy link

illtellyoulater commented Mar 28, 2022

[...]
ERROR: An error occurred during the fetch of repository 'llvm-project':
   Traceback (most recent call last):
        File "C:/users/my-name/_bazel_my-name/jhqpq4oj/external/llvm-raw/utils/bazel/configure.bzl", line 73, column 25, in _llvm_configure_impl
                _overlay_directories(repository_ctx)
        File "C:/users/my-name/_bazel_my-name/jhqpq4oj/external/llvm-raw/utils/bazel/configure.bzl", line 62, column 13, in _overlay_directories
                fail(("Failed to execute overlay script: '{cmd}'\n" +
Error in fail: Failed to execute overlay script: 'C:/Users/my-name/.conda/envs/my-env/python.exe C:/users/my-name/_bazel_my-name/jhqpq4oj/external/llvm-raw/utils/bazel/overlay_directories.py --src C:/users/my-name/_bazel_my-name/jhqpq4oj/external/llvm-raw --overlay C:/users/my-name/_bazel_my-name/jhqpq4oj/external/llvm-raw/utils/bazel/llvm-project-overlay --target .'
Exited with code 1
[...]

I managed to fix the above error and it finally compiled.
This helped me: tensorflow/tensorflow#54749 (comment)

Basically the problem was that the compilation tries to create symbolic links, but in Windows a process is not allowed to do so unless it's running with administrative rights, or the Developer Mode is enabled (see https://docs.microsoft.com/en-us/windows/apps/get-started/enable-your-device-for-development).

Once I activated the Developer Mode and I restarted the shell the compilation process went ahead with no errors.

In case of any other errors in Windows, make sure to run the compilation within a git-bash window, as apparently there's some incompatibility between LLVM and the windows shell.
In my case I was also using conda, so to make it available within the git-bash shell, from there I did:
. /c/ProgramData/Anaconda3/etc/profile.d/conda.sh
which successfully enabled all conda commands.

Hope it helps!


To install the newly-built jaxlib wheel, run:
  pip install C:\Users\my-name\Downloads\jax\dist\jaxlib-0.3.3-cp39-none-win_amd64.whl


     _   _  __  __
    | | / \ \ \/ /
 _  | |/ _ \ \  /
| |_| / ___ \/  \
 \___/_/   \/_/\_\


Bazel binary path: .\bazel-5.0.0-windows-x86_64.exe
Bazel version: 5.0.0
Python binary path: C:/Users/my-name/.conda/envs/my-env/python.exe
Python version: 3.9
NumPy version: 1.21.5
MKL-DNN enabled: yes
Target CPU: AMD64
Target CPU features: release
CUDA enabled: yes
CUDA compute capabilities: 3.5,5.2,6.0,7.0,8.0
CUDA version: 11.6
CUDNN version: 8.3.3
NCCL enabled: yes
TPU enabled: no
ROCm enabled: no

Building XLA and installing it in the jaxlib source tree...
.\bazel-5.0.0-windows-x86_64.exe run --verbose_failures=true --config=mkl_open_source_only --config=cuda :build_wheel -- --output_path=C:\Users\my-name\Downloads\jax\dist --cpu=AMD64

@hawkinsp
Copy link
Collaborator

@illtellyoulater Thanks, I'll add that to the docs (#10068)

@PianoMastR64
Copy link

In short: The solution to my problem was to uninstall MSYS2 including deleting the C:/msys64/ folder, then reinstall it.


I got this error:

ERROR: An error occurred during the fetch of repository 'llvm-project':
   Traceback (most recent call last):
        File "C:/users/my-name/_bazel_my-name/an6osj5g/external/llvm-raw/utils/bazel/configure.bzl", line 73, column 25, in _llvm_configure_impl
                _overlay_directories(repository_ctx)
        File "C:/users/my-name/_bazel_my-name/an6osj5g/external/llvm-raw/utils/bazel/configure.bzl", line 62, column 13, in _overlay_directories
                fail(("Failed to execute overlay script: '{cmd}'\n" +
Error in fail: Failed to execute overlay script: 'C:/msys64/usr/bin/python3.exe C:/users/my-name/_bazel_my-name/an6osj5g/external/llvm-raw/utils/bazel/overlay_directories.py --src C:/users/my-name/_bazel_my-name/an6osj5g/external/llvm-raw --overlay C:/users/my-name/_bazel_my-name/an6osj5g/external/llvm-raw/utils/bazel/llvm-project-overlay --target .'
Exited with code 2
stdout:

stderr:
/usr/bin/python3: can't open file '/c/users/my-name/_bazel_my-name/an6osj5g/external/llvm-project/C:/users/my-name/_bazel_my-name/an6osj5g/external/llvm-raw/utils/bazel/overlay_directories.py': [Errno 2] 
No such file or directory

It was trying to use C:/msys64/usr/bin/python3.exe (3.9.9) to run overlay_directories.py which ended up being an earlier version than the one my system PATH pointed to (3.10.4). I'm not sure if that was exactly the problem or not, but I eventually solved it. I uninstalled MSYS2 and even deleted the C:/msys64/ folder which still contained the python exe. Then I reinstalled it fresh. Suddenly, running the command is successfully compiling. There were a ton of files in there actually that didn't go away upon the uninstall, and nothing put anything like them back after running the command successfully, so I don't know why they were there or why they were being used. I have a copy of them floating on my system in case it's useful to know what they were exactly.

The command I used:
python .\build\build.py --enable_cuda --cuda_path='C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.7' --cudnn_path='C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.7' --cuda_version='11.7' --cudnn_version='8.4.1' --bazel_options='--copt=/Z7'

I ran the command right in the Visual Studio Code terminal. I tried the whole git-bash thing, and I had the same errors. The compilation took so long that I don't feel like testing if it would have worked fine in PowerShell, but if someone wants me to I'll do it.

An earlier problem I ran into was the build.py complaining that jax had spaces in its file path, so I just moved it to C:\ temporarily. I didn't save the error log, but if this is a new issue I can recreate it.

(I wrote all this expecting it to work, but I ran into a bunch of other problems and I finally gave up. But hopefully this is useful.)

The full log:

python .\build\build.py --enable_cuda --cuda_path='C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.7' --cudnn_path='C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.7' --cuda_version='11.7' --cudnn_version='8.4.1' --bazel_options='--copt=/Z7'

     _   _  __  __
    | | / \ \ \/ /
 _  | |/ _ \ \  / 
| |_| / ___ \/  \
 \___/_/   \/_/\_\


Bazel binary path: C:\Users\my-name\AppData\Local\bazelisk\downloads\bazelbuild\bazel-5.1.1-windows-x86_64\bin\bazel.EXE
Bazel version: 5.1.1
Python binary path: C:/Python310/python.exe
Python version: 3.10
NumPy version: 1.22.4
MKL-DNN enabled: yes
Target CPU: AMD64
Target CPU features: release
CUDA enabled: yes
CUDA toolkit path: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.7
CUDNN library path: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.7
CUDA version: 11.7
CUDNN version: 8.4.1
NCCL enabled: yes
TPU enabled: no
ROCm enabled: no

Building XLA and installing it in the jaxlib source tree...
C:\Users\my-name\AppData\Local\bazelisk\downloads\bazelbuild\bazel-5.1.1-windows-x86_64\bin\bazel.EXE run --verbose_failures=true --copt=/Z7 --config=mkl_open_source_only --config=cuda :build_wheel 
-- --output_path=C:\jax\dist --cpu=AMD64
WARNING: Option 'experimental_strict_action_env' is deprecated: Use --incompatible_strict_action_env instead
INFO: Options provided by the client:
  Inherited 'common' options: --isatty=1 --terminal_columns=80
INFO: Reading rc options for 'run' from c:\jax\.bazelrc:
  Inherited 'common' options: --experimental_repo_remote_exec
INFO: Options provided by the client:
  Inherited 'build' options: --python_path=C:/Python310/python.exe
INFO: Reading rc options for 'run' from c:\jax\.bazelrc:
  Inherited 'build' options: --apple_platform_type=macos --macos_minimum_os=10.14 --announce_rc --define open_source_build=true --spawn_strategy=standalone --enable_platform_specific_config --experimental_cc_shared_library --define=no_aws_support=true --define=no_gcp_support=true --define=no_hdfs_support=true --define=no_kafka_support=true --define=no_ignite_support=true --define=grpc_no_ares=true -c opt --config=short_logs --copt=-DMLIR_PYTHON_PACKAGE_PREFIX=jaxlib.mlir. --@org_tensorflow//tensorflow/compiler/xla/python:enable_gpu=false --@org_tensorflow//tensorflow/compiler/xla/python:enable_tpu=false
INFO: Reading rc options for 'run' from c:\jax\.jax_configure.bazelrc:
  Inherited 'build' options: --strategy=Genrule=standalone --repo_env PYTHON_BIN_PATH=C:/Python310/python.exe --action_env=PYENV_ROOT --python_path=C:/Python310/python.exe --action_env CUDA_TOOLKIT_PATH=C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.7 --action_env CUDNN_INSTALL_PATH=C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.7 --action_env TF_CUDA_PATHS=C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.7 --action_env TF_CUDA_VERSION=11.7 --action_env TF_CUDNN_VERSION=8.4.1 --distinct_host_configuration=false
INFO: Found applicable config definition build:short_logs in file c:\jax\.bazelrc: --output_filter=DONT_MATCH_ANYTHING
INFO: Found applicable config definition build:mkl_open_source_only in file c:\jax\.bazelrc: --define=tensorflow_mkldnn_contraction_kernel=1
INFO: Found applicable config definition build:cuda in file c:\jax\.bazelrc: --repo_env TF_NEED_CUDA=1 --action_env TF_CUDA_COMPUTE_CAPABILITIES=sm_35,sm_52,sm_60,sm_70,compute_80 --crosstool_top=@local_config_cuda//crosstool:toolchain --@local_config_cuda//:enable_cuda --@org_tensorflow//tensorflow/compiler/xla/python:enable_gpu=true --define=xla_python_enable_gpu=true
INFO: Found applicable config definition build:windows in file c:\jax\.bazelrc: --copt=/D_USE_MATH_DEFINES --host_copt=/D_USE_MATH_DEFINES --copt=-DWIN32_LEAN_AND_MEAN --host_copt=-DWIN32_LEAN_AND_MEAN --copt=-DNOGDI --host_copt=-DNOGDI --copt=/Zc:preprocessor --cxxopt=/std:c++17 --host_cxxopt=/std:c++17 --linkopt=/DEBUG --host_linkopt=/DEBUG --linkopt=/OPT:REF --host_linkopt=/OPT:REF --linkopt=/OPT:ICF --host_linkopt=/OPT:ICF --experimental_strict_action_env=true
INFO: Repository llvm-project instantiated at:
  C:/jax/WORKSPACE:31:14: in <toplevel>
  C:/users/my-name/_bazel_my-name/an6osj5g/external/org_tensorflow/tensorflow/workspace2.bzl:880:21: in workspace
  C:/users/my-name/_bazel_my-name/an6osj5g/external/org_tensorflow/tensorflow/workspace2.bzl:518:15: in _tf_repositories
  C:/users/my-name/_bazel_my-name/an6osj5g/external/org_tensorflow/third_party/llvm/setup.bzl:22:19: in llvm_setup
Repository rule llvm_configure defined at:
  C:/users/my-name/_bazel_my-name/an6osj5g/external/llvm-raw/utils/bazel/configure.bzl:83:33: in <toplevel>
ERROR: An error occurred during the fetch of repository 'llvm-project':
   Traceback (most recent call last):
        File "C:/users/my-name/_bazel_my-name/an6osj5g/external/llvm-raw/utils/bazel/configure.bzl", line 73, column 25, in _llvm_configure_impl
                _overlay_directories(repository_ctx)
        File "C:/users/my-name/_bazel_my-name/an6osj5g/external/llvm-raw/utils/bazel/configure.bzl", line 62, column 13, in _overlay_directories
                fail(("Failed to execute overlay script: '{cmd}'\n" +
Error in fail: Failed to execute overlay script: 'C:/msys64/usr/bin/python3.exe C:/users/my-name/_bazel_my-name/an6osj5g/external/llvm-raw/utils/bazel/overlay_directories.py --src C:/users/my-name/_bazel_my-name/an6osj5g/external/llvm-raw --overlay C:/users/my-name/_bazel_my-name/an6osj5g/external/llvm-raw/utils/bazel/llvm-project-overlay --target .'
Exited with code 2
stdout:

stderr:
/usr/bin/python3: can't open file '/c/users/my-name/_bazel_my-name/an6osj5g/external/llvm-project/C:/users/my-name/_bazel_my-name/an6osj5g/external/llvm-raw/utils/bazel/overlay_directories.py': [Errno 2] 
No such file or directory

ERROR: C:/jax/WORKSPACE:31:14: fetching llvm_configure rule //external:llvm-project: Traceback (most recent call last):
        File "C:/users/my-name/_bazel_my-name/an6osj5g/external/llvm-raw/utils/bazel/configure.bzl", line 73, column 25, in _llvm_configure_impl
                _overlay_directories(repository_ctx)
        File "C:/users/my-name/_bazel_my-name/an6osj5g/external/llvm-raw/utils/bazel/configure.bzl", line 62, column 13, in _overlay_directories
                fail(("Failed to execute overlay script: '{cmd}'\n" +
Error in fail: Failed to execute overlay script: 'C:/msys64/usr/bin/python3.exe C:/users/my-name/_bazel_my-name/an6osj5g/external/llvm-raw/utils/bazel/overlay_directories.py --src C:/users/my-name/_bazel_my-name/an6osj5g/external/llvm-raw --overlay C:/users/my-name/_bazel_my-name/an6osj5g/external/llvm-raw/utils/bazel/llvm-project-overlay --target .'
Exited with code 2
stdout:

stderr:
/usr/bin/python3: can't open file '/c/users/my-name/_bazel_my-name/an6osj5g/external/llvm-project/C:/users/my-name/_bazel_my-name/an6osj5g/external/llvm-raw/utils/bazel/overlay_directories.py': [Errno 2] 
No such file or directory

INFO: Repository com_google_absl instantiated at:
  C:/jax/WORKSPACE:31:14: in <toplevel>
  C:/users/my-name/_bazel_my-name/an6osj5g/external/org_tensorflow/tensorflow/workspace2.bzl:873:28: in workspace
  C:/users/my-name/_bazel_my-name/an6osj5g/external/org_tensorflow/tensorflow/workspace2.bzl:58:9: in _initialize_third_party
  C:/users/my-name/_bazel_my-name/an6osj5g/external/org_tensorflow/third_party/absl/workspace.bzl:39:20: in repo
  C:/users/my-name/_bazel_my-name/an6osj5g/external/org_tensorflow/third_party/repo.bzl:128:21: in tf_http_archive
Repository rule _tf_http_archive defined at:
  C:/users/my-name/_bazel_my-name/an6osj5g/external/org_tensorflow/third_party/repo.bzl:81:35: in <toplevel>
INFO: Repository pocketfft instantiated at:
  C:/jax/WORKSPACE:24:10: in <toplevel>
  C:/jax/third_party/pocketfft/workspace.bzl:20:17: in repo
Repository rule http_archive defined at:
  C:/users/my-name/_bazel_my-name/an6osj5g/external/bazel_tools/tools/build_defs/repo/http.bzl:353:31: in <toplevel>
ERROR: C:/jax/jaxlib/mlir/BUILD.bazel:71:15: //jaxlib/mlir:_builtin_dialect_srcs depends on @llvm-project//mlir/python:BuiltinOpsPyFiles in repository @llvm-project which failed to fetch. no such 
package '@llvm-project//mlir/python': Failed to execute overlay script: 'C:/msys64/usr/bin/python3.exe C:/users/my-name/_bazel_my-name/an6osj5g/external/llvm-raw/utils/bazel/overlay_directories.py --src C:/users/my-name/_bazel_my-name/an6osj5g/external/llvm-raw --overlay C:/users/my-name/_bazel_my-name/an6osj5g/external/llvm-raw/utils/bazel/llvm-project-overlay --target .'
Exited with code 2
stdout:

stderr:
/usr/bin/python3: can't open file '/c/users/my-name/_bazel_my-name/an6osj5g/external/llvm-project/C:/users/my-name/_bazel_my-name/an6osj5g/external/llvm-raw/utils/bazel/overlay_directories.py': [Errno 2] 
No such file or directory

ERROR: Analysis of target '//build:build_wheel' failed; build aborted:
INFO: Elapsed time: 0.995s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets conf\
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets conf\
igured)
    currently loading: @org_tensorflow//tensorflow/compiler/mlir/hlo
    Fetching https://github.com/...d91ba695b6e19ae2687dd60366900b928002.tar.gz
b''
Traceback (most recent call last):
  File "C:\jax\build\build.py", line 528, in <module>
    main()
  File "C:\jax\build\build.py", line 523, in main
    shell(command)
  File "C:\jax\build\build.py", line 53, in shell
    output = subprocess.check_output(cmd)
  File "C:\Python310\lib\subprocess.py", line 420, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "C:\Python310\lib\subprocess.py", line 524, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['C:\\Users\\my-name\\AppData\\Local\\bazelisk\\downloads\\bazelbuild\\bazel-5.1.1-windows-x86_64\\bin\\bazel.EXE', 'run', '--verbose_failures=true', '--copt=/Z7', '--config=mkl_open_source_only', '--config=cuda', ':build_wheel', '--', '--output_path=C:\\jax\\dist', '--cpu=AMD64']' returned non-zero exit status 1.

@PianoMastR64
Copy link

Here's another problem I solved. It ran into an infinite loop until I removed the --bazel_options='--copt=/Z7'

log:

File "C:\Python310\lib\shutil.py", line 621, in _rmtree_unsafe
    onerror(os.rmdir, path, sys.exc_info())
  File "C:\Python310\lib\tempfile.py", line 823, in onerror
    cls._rmtree(path, ignore_errors=ignore_errors)
  File "C:\Python310\lib\tempfile.py", line 832, in _rmtree
    _shutil.rmtree(name, onerror=onerror)
  File "C:\Python310\lib\shutil.py", line 747, in rmtree
    return _rmtree_unsafe(path, onerror)
  File "C:\Python310\lib\shutil.py", line 621, in _rmtree_unsafe
    onerror(os.rmdir, path, sys.exc_info())
  File "C:\Python310\lib\tempfile.py", line 823, in onerror
    cls._rmtree(path, ignore_errors=ignore_errors)
  File "C:\Python310\lib\tempfile.py", line 832, in _rmtree
    _shutil.rmtree(name, onerror=onerror)
  File "C:\Python310\lib\shutil.py", line 747, in rmtree
    return _rmtree_unsafe(path, onerror)
  File "C:\Python310\lib\shutil.py", line 621, in _rmtree_unsafe
    onerror(os.rmdir, path, sys.exc_info())
  File "C:\Python310\lib\tempfile.py", line 823, in onerror
    cls._rmtree(path, ignore_errors=ignore_errors)
  File "C:\Python310\lib\tempfile.py", line 832, in _rmtree
    _shutil.rmtree(name, onerror=onerror)
  File "C:\Python310\lib\shutil.py", line 696, in rmtree
    sys.audit("shutil.rmtree", path)
RecursionError: maximum recursion depth exceeded while calling a Python object
b''
Traceback (most recent call last):
  File "C:\jax\build\build.py", line 528, in <module>
    main()
  File "C:\jax\build\build.py", line 523, in main
    shell(command)
  File "C:\jax\build\build.py", line 53, in shell
    output = subprocess.check_output(cmd)
  File "C:\Python310\lib\subprocess.py", line 420, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "C:\Python310\lib\subprocess.py", line 524, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['C:\\Users\\my-name\\AppData\\Local\\bazelisk\\downloads\\bazelbuild\\bazel-5.1.1-windows-x86_64\\bin\\bazel.EXE', 'run', '--verbose_failures=true', '--copt=/Z7', '--config=mkl_open_source_only', '--config=cuda', ':build_wheel', '--', '--output_path=C:\\jax\\dist', '--cpu=AMD64']' returned non-zero exit status 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes pull ready Ready for copybara import and testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for Jax on Windows
9 participants