TF 2 building from source fails
@bergentruckung,
Have you tried the above query after trying the **bazel clean --expunge** command. Could you try once and try repeating the above steps. And also make sure you follow the steps mentioned [here](https://www.tensorflow.org/install/source).

Also usually users get this error `PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: `unable to find valid certification path to requested target due to the system firewall. The system firewall restricts the application to connect to external systems. The firewall requires a valid certificate to allow access to the external systems.

Could you please confirm, whether you're installing [Bazel](https://bazel.build/install) normally or via Bazelisk because [Bazelisk](https://github.com/bazelbuild/bazelisk) is an easy way to install Bazel and automatically downloads the correct Bazel version for TensorFlow and if you're using Bazelisk then please download manually and please follow below steps:

1. wget https://github.com/bazelbuild/bazelisk/releases/download/v1.16.0/bazelisk-darwin-arm64 (If you get any error with respect to certificate then you can use this command wget --no-check-certificate https://github.com/bazelbuild/bazelisk/releases/download/v1.16.0/bazelisk-darwin-arm64

2. `chmod +x bazelisk-darwin-arm64`

3. `sudo mv bazelisk-darwin-arm64 /usr/local/bin/bazel`

After that please try to run the below steps:

```
1. whereis bazel
2. whereis bazelisk
```
Also https://bazel.build/install/compile-source#bootstrap-unix.
please try to comment out 'for' statement and rebuild a binary version of bazel:
https://github.com/bazelbuild/bazel/blob/master/src/main/cpp/blaze.cc#L1015
Then use this to build tensorflow. Thank you! Thanks, @tilakrayal.
>Have you tried the above query after trying the bazel clean --expunge command. Could you try once and try repeating the above steps. And also make sure you follow the steps mentioned [here](https://www.tensorflow.org/install/source).

Yes, I've tried after running `bazel clean --expunge` as well. Also, I've been following the exact same docs that you linked.

>Also usually users get this error PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target due to the system firewall. The system firewall restricts the application to connect to external systems. The firewall requires a valid certificate to allow access to the external systems.

What can I do to bypass this? What's the cert that is causing the problem? Since the error seems to indicate a java application (I'm guessing bazel?), is it possible to add the required cert to its java keystore/cert bundle?

>Could you please confirm, whether you're installing [Bazel](https://bazel.build/install) normally or via [Bazelisk](https://github.com/bazelbuild/bazelisk) because Bazelisk is an easy way to install Bazel and automatically downloads the correct Bazel version for TensorFlow and if you're using Bazelisk then please download manually and please follow below steps:

Yes, I'm using `bazelisk` to install the correct version of `bazel`. @tilakrayal, were you able to check this? Any updates here? @sachinprasadhs, any updates here?
<details><summary>Click to expand!</summary> 
 
 ### Issue Type

Build/Install

### Have you reproduced the bug with TF nightly?

Yes

### Source

source

### Tensorflow Version

Commit hash: cd8247b47bd5ba25b26752b55ea54b52e5574183

### Custom Code

No

### OS Platform and Distribution

Redhat Enterprise Linux 8.7

### Mobile device

_No response_

### Python version

3.10.4

### Bazel version

5.4.0 (same as what's there in .bazelversion)

### GCC/Compiler version

clang 17.0.0

### CUDA/cuDNN version

CUDA 12.1, cuDNN 8.9.0

### GPU model and memory

H100

### Current Behaviour?

Hello,

I'm unable to build TF from source on CUDA 12.1. It tries to download a bunch of things, but that's failing with the attached error.

Please let me know what I can do to build it correctly.


Thanks in advance.

### Standalone code to reproduce the issue

```shell
* ./configure (and provide details)
* bazel --output_user_root=/var/tmp/bazel_cache/ build //tensorflow/tools/pip_package:build_pip_package --config=v2 --config=nogcp --verbose_failures
```


### Relevant log output

```shell
Build fails with the following:


WARNING: Download from https://storage.googleapis.com/mirror.tensorflow.org/github.com/llvm/llvm-project/archive/8ed9cf06e9004931e3e583a79579f3286e8d027c.tar.gz failed: class javax.net.ssl.SSLHandshakeException PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target                                                                                                                                                                                                               
WARNING: Download from https://github.com/llvm/llvm-project/archive/8ed9cf06e9004931e3e583a79579f3286e8d027c.tar.gz failed: class javax.net.ssl.SSLHandshakeException PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target                                                                                                                                                                                                                                                            
ERROR: An error occurred during the fetch of repository 'llvm-raw':                                                                                                                                                                                                                       
   Traceback (most recent call last):                                                                                                                                                                                                                                                     
        File "/var/tmp/tensorflow/third_party/repo.bzl", line 73, column 33, in _tf_http_archive_impl                                                                                                                                                                         
                ctx.download_and_extract(                                                                                                                                                                                                                                                 
Error in download_and_extract: java.io.IOException: Error downloading [https://storage.googleapis.com/mirror.tensorflow.org/github.com/llvm/llvm-project/archive/8ed9cf06e9004931e3e583a79579f3286e8d027c.tar.gz, https://github.com/llvm/llvm-project/archive/8ed9cf06e9004931e3e583a79579f3286e8d027c.tar.gz] to /var/tmp/bazel_cache/3f833e193dcf224ba1dfd4cfcb9a9327/external/llvm-raw/temp9475963496497572483/8ed9cf06e9004931e3e583a79579f3286e8d027c.tar.gz: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target                                                                                                                                                                                                                                            
ERROR: /var/tmp/tensorflow/WORKSPACE:11:14: fetching _tf_http_archive rule //external:llvm-raw: Traceback (most recent call last):                                                                                                                                            
        File "/var/tmp/tensorflow/third_party/repo.bzl", line 73, column 33, in _tf_http_archive_impl                                                                                                                                                                         
                ctx.download_and_extract(                                                                                                                                                                                                                                                 
Error in download_and_extract: java.io.IOException: Error downloading [https://storage.googleapis.com/mirror.tensorflow.org/github.com/llvm/llvm-project/archive/8ed9cf06e9004931e3e583a79579f3286e8d027c.tar.gz, https://github.com/llvm/llvm-project/archive/8ed9cf06e9004931e3e583a79579f3286e8d027c.tar.gz] to /var/tmp/bazel_cache/3f833e193dcf224ba1dfd4cfcb9a9327/external/llvm-raw/temp9475963496497572483/8ed9cf06e9004931e3e583a79579f3286e8d027c.tar.gz: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target                                                                                                                                                                                                                                            
```
```
</details>