jax icon indicating copy to clipboard operation
jax copied to clipboard

Compilation error on jaxlib v0.4.16

Open mihneabastea opened this issue 3 years ago • 7 comments

Description

Following this old tutorial for Jax on Jetson Nano I am unable to successfully build jax from source on a Jetson Orin Nano.

Env setup & download JAX:

virtualenv -p /usr/bin/python3.9 py39
source ./py39/bin/activate
python3 -m pip install numpy scipy six wheel
git clone https://github.com/google/jax
cd jax

Build taken from here:

python3 build/build.py --enable_cuda --cuda_compute_capabilities=sm_87

Fails with the following output:

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


Downloading bazel from: https://github.com/bazelbuild/bazel/releases/download/6.1.2/bazel-6.1.2-linux-arm64
bazel-6.1.2-linux-arm64 [########################################] 100%
Bazel binary path: ./bazel-6.1.2-linux-arm64
Bazel version: 6.1.2
Python binary path: /home/jetson/py39/bin/python3
Python version: 3.9
NumPy version: 1.26.0
MKL-DNN enabled: yes
Target CPU: aarch64
Target CPU features: release
CUDA enabled: yes
CUDA compute capabilities: sm_87
NCCL enabled: yes
TPU enabled: no
ROCm enabled: no

Building XLA and installing it in the jaxlib source tree...
./bazel-6.1.2-linux-arm64 run --verbose_failures=true //jaxlib/tools:build_wheel -- --output_path=/home/jetson/jax/dist --cpu=aarch64
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
INFO: Options provided by the client:
  Inherited 'common' options: --isatty=0 --terminal_columns=80
INFO: Reading rc options for 'run' from /home/jetson/jax/.bazelrc:
  Inherited 'common' options: --experimental_repo_remote_exec
INFO: Reading rc options for 'run' from /home/jetson/jax/.bazelrc:
  Inherited 'build' options: --nocheck_visibility --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 --define=tsl_link_protobuf=true -c opt --config=short_logs --copt=-DMLIR_PYTHON_PACKAGE_PREFIX=jaxlib.mlir. --@xla//xla/python:enable_gpu=false
INFO: Reading rc options for 'run' from /home/jetson/jax/.jax_configure.bazelrc:
  Inherited 'build' options: --strategy=Genrule=standalone --repo_env PYTHON_BIN_PATH=/home/jetson/py39/bin/python3 --action_env=PYENV_ROOT --python_path=/home/jetson/py39/bin/python3 --config=mkl_open_source_only --config=cuda
INFO: Found applicable config definition build:short_logs in file /home/jetson/jax/.bazelrc: --output_filter=DONT_MATCH_ANYTHING
INFO: Found applicable config definition build:mkl_open_source_only in file /home/jetson/jax/.bazelrc: --define=tensorflow_mkldnn_contraction_kernel=1
INFO: Found applicable config definition build:cuda in file /home/jetson/jax/.bazelrc: --repo_env TF_NEED_CUDA=1 --action_env TF_CUDA_COMPUTE_CAPABILITIES=sm_52,sm_60,sm_70,sm_80,compute_90 --crosstool_top=@local_config_cuda//crosstool:toolchain --@local_config_cuda//:enable_cuda --@xla//xla/python:enable_gpu=true --@xla//xla/python:jax_cuda_pip_rpaths=true --define=xla_python_enable_gpu=true
INFO: Found applicable config definition build:cuda in file /home/jetson/jax/.jax_configure.bazelrc: --action_env TF_CUDA_COMPUTE_CAPABILITIES=sm_87
INFO: Found applicable config definition build:linux in file /home/jetson/jax/.bazelrc: --config=posix --copt=-Wno-unknown-warning-option --copt=-Wno-stringop-truncation --copt=-Wno-array-parameter
INFO: Found applicable config definition build:posix in file /home/jetson/jax/.bazelrc: --copt=-fvisibility=hidden --copt=-Wno-sign-compare --cxxopt=-std=c++17 --host_cxxopt=-std=c++17
Loading: 
Loading: 
Loading: 
Loading: 
DEBUG: /home/jetson/.cache/bazel/_bazel_jetson/b70491157b7ca86cdbcfe25aed60293d/external/xla/third_party/repo.bzl:132:14: 
Warning: skipping import of repository 'tf_runtime' because it already exists.
DEBUG: /home/jetson/.cache/bazel/_bazel_jetson/b70491157b7ca86cdbcfe25aed60293d/external/xla/third_party/repo.bzl:132:14: 
Warning: skipping import of repository 'llvm-raw' because it already exists.
Loading: 
Loading: 
Loading: 
Loading: 
Loading: 
Loading: 
Loading: 
Loading: 
Loading: 
Loading: 
Loading: 
Loading: 
Loading: 
WARNING: Download from https://mirror.bazel.build/github.com/bazelbuild/rules_cc/archive/081771d4a0e9d7d3aa0eed2ef389fa4700dfb23e.tar.gz failed: class java.io.FileNotFoundException GET returned 404 Not Found
DEBUG: /home/jetson/.cache/bazel/_bazel_jetson/b70491157b7ca86cdbcfe25aed60293d/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:118:10: 
Auto-Configuration Warning: 'TMP' environment variable is not set, using 'C:\Windows\Temp' as default
Loading: 
DEBUG: /home/jetson/.cache/bazel/_bazel_jetson/b70491157b7ca86cdbcfe25aed60293d/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:118:10: 
Auto-Configuration Warning: 'TMP' environment variable is not set, using 'C:\Windows\Temp' as default
Loading: 
Loading: 2 packages loaded
Analyzing: target //jaxlib/tools:build_wheel (3 packages loaded, 0 targets configured)
Analyzing: target //jaxlib/tools:build_wheel (33 packages loaded, 11 targets configured)
Analyzing: target //jaxlib/tools:build_wheel (35 packages loaded, 11 targets configured)
Analyzing: target //jaxlib/tools:build_wheel (35 packages loaded, 11 targets configured)
Analyzing: target //jaxlib/tools:build_wheel (35 packages loaded, 11 targets configured)
Analyzing: target //jaxlib/tools:build_wheel (35 packages loaded, 11 targets configured)
Analyzing: target //jaxlib/tools:build_wheel (35 packages loaded, 11 targets configured)
Analyzing: target //jaxlib/tools:build_wheel (35 packages loaded, 11 targets configured)
Analyzing: target //jaxlib/tools:build_wheel (49 packages loaded, 206 targets configured)
Analyzing: target //jaxlib/tools:build_wheel (78 packages loaded, 531 targets configured)
Analyzing: target //jaxlib/tools:build_wheel (115 packages loaded, 1121 targets configured)
Analyzing: target //jaxlib/tools:build_wheel (156 packages loaded, 2142 targets configured)
Analyzing: target //jaxlib/tools:build_wheel (192 packages loaded, 3261 targets configured)
Analyzing: target //jaxlib/tools:build_wheel (201 packages loaded, 4731 targets configured)
Analyzing: target //jaxlib/tools:build_wheel (203 packages loaded, 8602 targets configured)
Analyzing: target //jaxlib/tools:build_wheel (206 packages loaded, 12588 targets configured)
Analyzing: target //jaxlib/tools:build_wheel (222 packages loaded, 14654 targets configured)
Analyzing: target //jaxlib/tools:build_wheel (229 packages loaded, 16598 targets configured)
Analyzing: target //jaxlib/tools:build_wheel (230 packages loaded, 17622 targets configured)
INFO: Analyzed target //jaxlib/tools:build_wheel (230 packages loaded, 17622 targets configured).
INFO: Found 1 target...
[0 / 17] [Prepa] BazelWorkspaceStatusAction stable-status.txt ... (6 actions, 2 running)
[26 / 1,448] Compiling src/google/protobuf/arena.cc [for tool]; 0s local ... (6 actions running)
.
.
.
[10,073 / 12,164] Compiling xla/backends/profiler/gpu/cupti_tracer.cc; 10s local ... (6 actions, 5 running)
ERROR: /home/jetson/.cache/bazel/_bazel_jetson/b70491157b7ca86cdbcfe25aed60293d/external/xla/xla/backends/profiler/gpu/BUILD:170:16: Compiling xla/backends/profiler/gpu/cupti_tracer.cc failed: (Exit 1): crosstool_wrapper_driver_is_not_gcc failed: error executing command (from target @xla//xla/backends/profiler/gpu:cupti_tracer) 
  (cd /home/jetson/.cache/bazel/_bazel_jetson/b70491157b7ca86cdbcfe25aed60293d/execroot/__main__ && \
  exec env - \
    LD_LIBRARY_PATH=/usr/local/cuda-11.4/lib64: \
    PATH=/home/jetson/py39/bin:/usr/local/cuda-11.4/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin \
    PWD=/proc/self/cwd \
    TF_CUDA_COMPUTE_CAPABILITIES=sm_87 \
  external/local_config_cuda/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc -MD -MF bazel-out/aarch64-opt/bin/external/xla/xla/backends/profiler/gpu/_objs/cupti_tracer/cupti_tracer.pic.d '-frandom-seed=bazel-out/aarch64-opt/bin/external/xla/xla/backends/profiler/gpu/_objs/cupti_tracer/cupti_tracer.pic.o' -DEIGEN_MPL2_ONLY '-DEIGEN_MAX_ALIGN_BYTES=64' -DHAVE_SYS_UIO_H -DTF_USE_SNAPPY '-DBAZEL_CURRENT_REPOSITORY="xla"' -iquote external/xla -iquote bazel-out/aarch64-opt/bin/external/xla -iquote external/com_google_absl -iquote bazel-out/aarch64-opt/bin/external/com_google_absl -iquote external/tsl -iquote bazel-out/aarch64-opt/bin/external/tsl -iquote external/eigen_archive -iquote bazel-out/aarch64-opt/bin/external/eigen_archive -iquote external/ml_dtypes -iquote bazel-out/aarch64-opt/bin/external/ml_dtypes -iquote external/nsync -iquote bazel-out/aarch64-opt/bin/external/nsync -iquote external/snappy -iquote bazel-out/aarch64-opt/bin/external/snappy -iquote external/double_conversion -iquote bazel-out/aarch64-opt/bin/external/double_conversion -iquote external/com_google_protobuf -iquote bazel-out/aarch64-opt/bin/external/com_google_protobuf -iquote external/zlib -iquote bazel-out/aarch64-opt/bin/external/zlib -iquote external/com_googlesource_code_re2 -iquote bazel-out/aarch64-opt/bin/external/com_googlesource_code_re2 -iquote external/farmhash_archive -iquote bazel-out/aarch64-opt/bin/external/farmhash_archive -iquote external/local_config_cuda -iquote bazel-out/aarch64-opt/bin/external/local_config_cuda -iquote external/local_config_rocm -iquote bazel-out/aarch64-opt/bin/external/local_config_rocm -iquote external/local_config_tensorrt -iquote bazel-out/aarch64-opt/bin/external/local_config_tensorrt -Ibazel-out/aarch64-opt/bin/external/ml_dtypes/_virtual_includes/float8 -Ibazel-out/aarch64-opt/bin/external/ml_dtypes/_virtual_includes/int4 -Ibazel-out/aarch64-opt/bin/external/local_config_cuda/cuda/_virtual_includes/cuda_headers_virtual -Ibazel-out/aarch64-opt/bin/external/local_config_cuda/cuda/_virtual_includes/cupti_headers_virtual -Ibazel-out/aarch64-opt/bin/external/local_config_tensorrt/_virtual_includes/tensorrt_headers -isystem external/eigen_archive -isystem bazel-out/aarch64-opt/bin/external/eigen_archive -isystem external/ml_dtypes -isystem bazel-out/aarch64-opt/bin/external/ml_dtypes -isystem external/ml_dtypes/ml_dtypes -isystem bazel-out/aarch64-opt/bin/external/ml_dtypes/ml_dtypes -isystem external/nsync/public -isystem bazel-out/aarch64-opt/bin/external/nsync/public -isystem external/com_google_protobuf/src -isystem bazel-out/aarch64-opt/bin/external/com_google_protobuf/src -isystem external/zlib -isystem bazel-out/aarch64-opt/bin/external/zlib -isystem external/farmhash_archive/src -isystem bazel-out/aarch64-opt/bin/external/farmhash_archive/src -isystem external/local_config_cuda/cuda -isystem bazel-out/aarch64-opt/bin/external/local_config_cuda/cuda -isystem external/local_config_cuda/cuda/cuda/include -isystem bazel-out/aarch64-opt/bin/external/local_config_cuda/cuda/cuda/include -isystem external/local_config_cuda/cuda/cuda/extras/CUPTI/include -isystem bazel-out/aarch64-opt/bin/external/local_config_cuda/cuda/cuda/extras/CUPTI/include -isystem external/local_config_rocm/rocm -isystem bazel-out/aarch64-opt/bin/external/local_config_rocm/rocm -isystem external/local_config_rocm/rocm/rocm/include -isystem bazel-out/aarch64-opt/bin/external/local_config_rocm/rocm/rocm/include -isystem external/local_config_rocm/rocm/rocm/include/rocrand -isystem bazel-out/aarch64-opt/bin/external/local_config_rocm/rocm/rocm/include/rocrand -isystem external/local_config_rocm/rocm/rocm/include/roctracer -isystem bazel-out/aarch64-opt/bin/external/local_config_rocm/rocm/rocm/include/roctracer -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -fPIC -U_FORTIFY_SOURCE '-D_FORTIFY_SOURCE=1' -fstack-protector -Wall -fno-omit-frame-pointer -no-canonical-prefixes -fno-canonical-system-headers -DNDEBUG -g0 -O2 -ffunction-sections -fdata-sections '-fvisibility=hidden' -Wno-sign-compare -Wno-unknown-warning-option -Wno-stringop-truncation -Wno-array-parameter '-DMLIR_PYTHON_PACKAGE_PREFIX=jaxlib.mlir.' '-std=c++17' -DEIGEN_AVOID_STL_ARRAY -Iexternal/gemmlowp -Wno-sign-compare '-ftemplate-depth=900' -fno-exceptions '-DGOOGLE_CUDA=1' '-DTENSORFLOW_USE_NVCC=1' -DTENSORFLOW_MONOLITHIC_BUILD -pthread '-DGOOGLE_CUDA=1' -DNV_CUDNN_DISABLE_EXCEPTION -c external/xla/xla/backends/profiler/gpu/cupti_tracer.cc -o bazel-out/aarch64-opt/bin/external/xla/xla/backends/profiler/gpu/_objs/cupti_tracer/cupti_tracer.pic.o)
# Configuration: c555ca23f0470226472c97536f5e81cf1925438212fcc09f54ed1ecea1af9426
# Execution platform: @local_execution_config_platform//:platform
external/xla/xla/backends/profiler/gpu/cupti_tracer.cc: In member function ‘tsl::Status xla::profiler::CuptiTracer::ProcessActivityBuffer(CUcontext, uint32_t, uint8_t*, size_t)’:
external/xla/xla/backends/profiler/gpu/cupti_tracer.cc:2173:34: error: ‘TF_CUPTI_HAS_CHANNEL_ID’ was not declared in this scope
 2173 |           AddKernelActivityEvent<TF_CUPTI_HAS_CHANNEL_ID>(
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~
external/xla/xla/backends/profiler/gpu/cupti_tracer.cc:2174:76: error: no matching function for call to ‘AddKernelActivityEvent<<expression error> >(xla::profiler::CuptiTraceCollector*&, xla::profiler::{anonymous}::CuptiActivityKernelTy*)’
 2174 |               collector_, reinterpret_cast<CuptiActivityKernelTy *>(record));
      |                                                                            ^
external/xla/xla/backends/profiler/gpu/cupti_tracer.cc:747:6: note: candidate: ‘template<bool cupti_has_channel_id, class CuptiActivityKernel> void xla::profiler::{anonymous}::AddKernelActivityEvent(xla::profiler::CuptiTraceCollector*, const CuptiActivityKernel*)’
  747 | void AddKernelActivityEvent(CuptiTraceCollector *collector,
      |      ^~~~~~~~~~~~~~~~~~~~~~
external/xla/xla/backends/profiler/gpu/cupti_tracer.cc:747:6: note:   template argument deduction/substitution failed:
external/xla/xla/backends/profiler/gpu/cupti_tracer.cc:2174:76: error: template argument 1 is invalid
 2174 |               collector_, reinterpret_cast<CuptiActivityKernelTy *>(record));
      |                                                                            ^
external/xla/xla/backends/profiler/gpu/cupti_tracer.cc: In function ‘const char* xla::profiler::GetTraceEventTypeName(const xla::profiler::CuptiTracerEventType&)’:
external/xla/xla/backends/profiler/gpu/cupti_tracer.cc:1854:1: warning: control reaches end of non-void function [-Wreturn-type]
 1854 | }
      | ^
external/xla/xla/backends/profiler/gpu/cupti_tracer.cc: At global scope:
external/xla/xla/backends/profiler/gpu/cupti_tracer.cc:79:8: warning: ‘tsl::Status xla::profiler::{anonymous}::ToStatus(CUptiResult)’ defined but not used [-Wunused-function]
   79 | Status ToStatus(CUptiResult result) {
      |        ^~~~~~~~
cc1plus: warning: unrecognized command line option ‘-Wno-array-parameter’
cc1plus: warning: unrecognized command line option ‘-Wno-unknown-warning-option’
Target //jaxlib/tools:build_wheel failed to build
[10,084 / 12,164] checking cached actions
INFO: Elapsed time: 7864.725s, Critical Path: 360.25s
INFO: 10084 processes: 3843 internal, 6241 local.
FAILED: Build did NOT complete successfully
ERROR: Build failed. Not running target
Traceback (most recent call last):
  File "/home/jetson/jax/build/build.py", line 598, in <module>
    main()
  File "/home/jetson/jax/build/build.py", line 580, in main
    shell(command)
  File "/home/jetson/jax/build/build.py", line 44, in shell
    output = subprocess.check_output(cmd)
  File "/usr/lib/python3.9/subprocess.py", line 424, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/usr/lib/python3.9/subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['./bazel-6.1.2-linux-arm64', 'run', '--verbose_failures=true', '//jaxlib/tools:build_wheel', '--', '--output_path=/home/jetson/jax/dist', '--cpu=aarch64']' returned non-zero exit status 1.

I've been trying to get this working for the past weeks but I have not been able to find a proper solution. If anyone made it work and is willing to share what they did I would greatly appreciate it.

What jax/jaxlib version are you using?

jaxlib 0.4.16

Which accelerator(s) are you using?

GPU

Additional system info

Ubuntu 20.04(aarch64 NVIDIA Jetson Orin Nano), Python 3.9.18, gcc 9.4

NVIDIA GPU info

No nvidia-smi but with jtop I can list the CUDA version and the cuDNN version.

CUDA: 11.4.315
cuDNN: 8.6.0.166
CUDA Arch bin: 8.7

mihneabastea avatar Sep 28 '23 14:09 mihneabastea

I'm not 100% sure, but my guess is this is related to your CUDA version (11.4), which is much older than anything JAX supports (11.8 or newer). Can you update?

hawkinsp avatar Sep 28 '23 15:09 hawkinsp

I'll try to update today but if it fails is there any older version that works with the CUDA version that I have?

mihneabastea avatar Sep 28 '23 15:09 mihneabastea

I'm confident that's it. This code doesn't define that value for CUDA < 11.6. https://github.com/openxla/xla/blob/bdb788c2e164c661ed8390d7825b0d792d298ac1/xla/backends/profiler/gpu/cupti_tracer.cc#L63

We could fix that, but I don't know there's a lot of point: we've dropped support for that CUDA version. You should just update.

Closing since the fix is to update CUDA!

hawkinsp avatar Sep 28 '23 16:09 hawkinsp

I have tried building some older versions of jax for CUDA 11.4, haven't had any success yet. The NX series is flashed with CUDA 11.4 and cuDNN 0.8.6. Any leads regarding this would be helpful, thanks!

avirupdas55 avatar Sep 20 '24 21:09 avirupdas55

If you want to use an older version of Jax for CUDA 11.4 and cuDNN 8.6.0 you can try using this wheel. Last year when I used it I remember that it worked as intended.

mihneabastea avatar Sep 22 '24 16:09 mihneabastea

@0Unkn0wn Thanks, I've checked your wheels, really helpful! Were you able to update cuDNN on Xavier NX to build the later versions?

avirupdas55 avatar Sep 22 '24 17:09 avirupdas55

I was able to use an updated version of cuDNN and CUDA on an Orin Nano. I am not sure about an Xavier NX but it should be possible.

There are special versions for both that work on Jetson. cuDNN CUDA (these are the latest just an example)

Whatever you are trying to do remember that if it doesn't work directly you could always try to use docker with Jax, CUDA, and cuDNN but it does require some tinkering.

mihneabastea avatar Sep 22 '24 17:09 mihneabastea