Commit Graph

194 Commits

Author SHA1 Message Date
A. Unique TensorFlower
fdcc8a6888 Replace RBE Docker container image: use Docker image without pre-installed CUDA packages.
Enable CUDA forward-compatibility mode in all RBE jobs by default.

Forward compatibility mode in hermetic CUDA allows the linker to use the user-mode driver from Bazel cache, so there is no need to install UMD in the RBE Docker image.

UMD on RBE machines is rarely updated, thus RBE jobs need forward compatibility mode to enable the most recent CUDA features usage in the tests.

The non-RBE job runners are updated more often, hence we can update the drivers on those machines and not rely on forward compatibility mode.

PiperOrigin-RevId: 810595379
2025-09-23 15:16:44 -07:00
A. Unique TensorFlower
5feca55740 Put NVIDIA wheels in ci/official/requirements_updater/nvidia-requirements.txt to have central place defining wheel versions.
This change is made to have consistency in parsing NVIDIA dependencies with [JAX repository](https://github.com/jax-ml/jax/pull/30706)

`nvidia-requirements.txt` is used in Bazel hermetic python lock files and in the `tools/pip_package/setup.py` with the package requirements.

The file content is saved in the `nvidia_wheel_versions repository` and passed as an argument to `modify_setup_py.py` that populates `setup_py.tpl` script.

PiperOrigin-RevId: 802755816
2025-09-03 16:57:17 -07:00
A. Unique TensorFlower
26f7ae5cab Update rules_ml_toolchain dependency to latest version.
PiperOrigin-RevId: 791817714
2025-08-06 13:43:08 -07:00
A. Unique TensorFlower
f4ee7a188e Remove local_config_nvshmem repository from XLA and Tensorflow WORKSPACE files.
Upgrading manylinux compliancy tag in [JAX PR](https://github.com/jax-ml/jax/pull/29672) enabled building targets with linked `nvshmem` libraries.

PiperOrigin-RevId: 786533277
2025-07-23 20:39:56 -07:00
A. Unique TensorFlower
f7dfba3f74 Add Hermetic C++ Toolchains for Linux x86_64 builds.
Hermetic toolchains give us builds that are isolated from the host system, cutting down on unexpected dependencies and side effects.

With these changes, TensorFlow will build for Linux x86_64 architectures (both CPU and CUDA-enabled GPU) using self-contained C++ toolchains. If you need to use a non-hermetic toolchain, you can do so by adding the flag --config=clang_local. For remote builds with a non-hermetic toolchain, simply append _clang_local to your existing RBE flag. For example, if your hermetic RBE build uses --config=rbe_linux_cpu, the non-hermetic version would be --config=rbe_linux_cpu_clang_local.

    Example: Run CPU tests for Linux x86_64

    For hermetic tests, run following command (no env variables like CC, CXX, BAZEL_COMPILER, CLANG_COMPILER_PATH):
	bazel test \
		--config=avx_linux \
		--config=release_linux_base \
		--config=linux_cpu_pycpp_test_filters \
		--repo_env=HERMETIC_PYTHON_VERSION=3.11 \
		//tensorflow/... -- -//tensorflow/compiler/tf2tensorrt/... -//tensorflow/core/tpu/... -//tensorflow/lite/...  -//tensorflow/tools/toolchains/...

    For Linux x86_64 non-hermetic tests use commands with the flag "--config=clang_local" and env variables CC, CXX, BAZEL_COMPILER, CLANG_COMPILER_PATH, etc.:
	bazel test \
		--config=clang_local \
		--config=avx_linux \
		--config=release_linux_base \
		--config=linux_cpu_pycpp_test_filters \
		--repo_env=HERMETIC_PYTHON_VERSION=3.11 \
		--action_env=CLANG_COMPILER_PATH=/usr/lib/llvm-18/bin/clang \
		--host_action_env=CLANG_COMPILER_PATH=/usr/lib/llvm-18/bin/clang \
		--repo_env=CC=/usr/lib/llvm-18/bin/clang \
		--repo_env=CXX=/usr/lib/llvm-18/bin/clang++ \
		--repo_env=BAZEL_COMPILER=/usr/lib/llvm-18/bin/clang \
		//tensorflow/... -- -//tensorflow/compiler/tf2tensorrt/... -//tensorflow/core/tpu/... -//tensorflow/lite/...  -//tensorflow/tools/toolchains/...

PiperOrigin-RevId: 783911228
2025-07-16 15:21:17 -07:00
A. Unique TensorFlower
ac56b0e840 Integrate hermetic ML toolchains for TensorFlow.
Hermetic C++ toolchains and CUDA are enabled for Linux x86_64 platform by default. List of covered OSs will be extended in a few closest months. Developers still could use  non hermetic toolchains with help of --config=clang_local flag.

std::reduce replace with a traditional for loop. This is necessary because GCC 8 offers only partial support for C++17, and using std::reduce in this environment leads to "Undefined method" error.
PiperOrigin-RevId: 775771057
2025-06-25 11:43:53 -07:00
Vadym Matsishevskyi
724f36e009 Major deps update:
-Protobuf 5.28.3
-Grpc 1.68.2
-Abseil: LTS 20240116.3
-Plus some other transitive/related deps, riegeli and pybind11 in particular.
-rules_python & rules_cc will be updated in a subsequent CL as they are their own can of worms, plus there are a few pending changes in rules_python which were not pushed yet.

This also switches default protobuf implementation we rely on for bazel builds from cpp to upb, meaning all projects dependin on htis one must be built with build --action_env=PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=upb.

PiperOrigin-RevId: 773586210
2025-06-20 01:35:16 -07:00
A. Unique TensorFlower
707048b1b9 Integrate hermetic nvshmem repository in XLA and TF projects.
TF wheel build rule implementation is also updated to exclude accidental dependencies on NVSHMEM libraries in the wheel content. If the wheel needs to be built with these dependencies, provide `--@local_config_nvshmem//:override_include_nvshmem_libs=True` in Bazel options.

`NVSHMEM` binaries are included in the dependencies if `CUDA` binary dependencies are added as well, e.g. `--@local_config_cuda//:enable_cuda`.

`NVSHMEM` libraries are included in the dependencies if `--@local_config_nvshmem//:include_nvshmem_libs=True` (the default flag value is `False`). Please note that this is a temporary solution, and it should be removed after GLIBC is updated on RBE runners. At the moment `libnvshmem.so` files can't be linked to the targets because they are built with GLIBC version higher then on RBE runners. In the future `--@local_config_cuda//cuda:include_cuda_libs=True` should be used.

The next change will contain adding `NVSHMEM` deps to individual Bazel targets via `select`.

PiperOrigin-RevId: 769344482
2025-06-09 16:48:48 -07:00
A. Unique TensorFlower
4ae9062af1 Use the shell rules https://github.com/bazelbuild/rules_shell.
In the future, the shell rules will no longer be packaged as part of
Bazel. This pulls the rules from their new home.

PiperOrigin-RevId: 759601729
2025-05-16 07:23:09 -07:00
Ezekiel Calubaquib
c0093bfb21 Add python 3.13 requirements and conditions for TF
the code below creates a condition to run specific Python.h code in cpp for python3.13 as the following functions are deprecated:

_PyArg_NoKeywords (removed)
_PyObject_VisitManagedDict (renamed to PyObject_VisitManagedDict)
_PyObject_ClearManagedDict (renamed to PyObject_ClearManagedDict)

PiperOrigin-RevId: 745284443
2025-04-08 15:00:52 -07:00
David Dunleavy
40998f44c0 Move TSL's third_party to XLA, update users
Mostly updating `WORKSPACE` and related files from `@tsl//third_party` -> `@xla//third_party`. Please tag me if this change breaks you.

PiperOrigin-RevId: 733489153
2025-03-04 15:51:50 -08:00
A. Unique TensorFlower
805775fcb5 Refactor mechanisms of building TF wheel and storing TF project version.
This change introduces a uniform way of building the TF wheel and controlling the filename version suffixes.

A new repository rule `python_wheel_version_suffix_repository` provides information about project and wheel version suffixes. The final value depends on environment variables passed to Bazel command: `_ML_WHEEL_WHEEL_TYPE, _ML_WHEEL_BUILD_DATE, _ML_WHEEL_GIT_HASH, _ML_WHEEL_VERSION_SUFFIX`

`tf_version.bzl` defines the TF project version and loads the version suffix information calculated by `python_wheel_version_suffix_repository`.

The targets `//tensorflow/core/public:release_version, //tensorflow:tensorflow_bzl //tensorflow/tools/pip_package:setup_py` use the version chunks defined above.

The version of the wheel in the build rule output depends on the environment variables.

Environment variables combinations for creating wheels with different versions:
  * snapshot (default build rule behavior): `--repo_env=ML_WHEEL_TYPE=snapshot`
  * release: `--repo_env=ML_WHEEL_TYPE=release`
  * release candidate: `--repo_env=ML_WHEEL_TYPE=release --repo_env=ML_WHEEL_VERSION_SUFFIX=-rc1`
  * nightly build with date as version suffix: `--repo_env=ML_WHEEL_TYPE=nightly --repo_env=ML_WHEEL_BUILD_DATE=<YYYYmmdd>`
  * build with git data as version suffix: `--repo_env=ML_WHEEL_TYPE=custom --repo_env=ML_WHEEL_BUILD_DATE=$(git show -s --format=%as HEAD) --repo_env=ML_WHEEL_GIT_HASH=$(git rev-parse HEAD)`

PiperOrigin-RevId: 733444080
2025-03-04 14:39:12 -08:00
A. Unique TensorFlower
17a9f49912 Add tf_nightly prefix to the local wheel inclusion list.
PiperOrigin-RevId: 684860066
2024-10-11 09:49:28 -07:00
A. Unique TensorFlower
7ba00ec863 Fix import_api_packages_test for the cases when WHEEL_NAME is passed to Bazel options.
Add `--@xla//xla/tsl:wheel_dependency=true` flag to wheel tests.

PiperOrigin-RevId: 684610277
2024-10-10 16:22:54 -07:00
Vadym Matsishevskyi
5720ab7845 Introduce pywrap bazel rules and migrate Tensorflow to it
The gist of this change (the new rules implementation) is contained within `rules_pywrap` folder. The rules are generic and not tensorflow-specific

1) (internal-specific)

2) (internal-specific)

3) It provides same linking strategy of final artifacts on all 3 supported platforms (no major differences between Linux, Mac and Windows).

4) It makes it possible to abandon usage of header-only targets to prevent ODR violations. Simply speaking you can now depend on generated protobuf message classes normally, without need to worry how that is linked afterwards.

5) The current version is backward-compatible and unless explicitly enabled is a no-op. To enable the new rules pass `--repo_env=USE_PYWRAP_RULES=True` flag to build/test command.

6) The `if_pywrap` construct is temporary and will be removed once full migration is completed. Currently if_pywrap is mainly used to pass normal dependencies (instead of header-only). The header-only stuff is kept for backward compatibility and smoother migration but will be eventually removed.

7) This CL migrates TF and the most problematic among all google ML repositories. Once TF is sabilized the other repositories, such as JAX and XLA will be migrated too (which should be way easier than migrating TF anyways)

PiperOrigin-RevId: 684324990
2024-10-10 00:12:03 -07:00
A. Unique TensorFlower
cd8973732f Add "tf_nightly*" to local wheels inclusion list.
PiperOrigin-RevId: 676966274
2024-09-20 14:19:38 -07:00
A. Unique TensorFlower
55ca3b150c Add TF wheel API test.
This test verifies whether the API v2 packages can be imported from the
current build. It utilizes the `_api/v2/api_packages.txt` list of packages from
the local wheel file specified in the `requirements_lock_<python_version>.txt`.

The test should be executed after the TF wheel was built and put into `dist` dir inside Tensorflow repository.

PiperOrigin-RevId: 676893008
2024-09-20 10:43:17 -07:00
A. Unique TensorFlower
9b5fa66dc6 Introduce hermetic CUDA in Google ML projects.
1) Hermetic CUDA rules allow building wheels with GPU support on a machine without GPUs, as well as running Bazel GPU tests on a machine with only GPUs and NVIDIA driver installed. When `--config=cuda` is provided in Bazel options, Bazel will download CUDA, CUDNN and NCCL redistributions in the cache, and use them during build and test phases.

    [Default location of CUNN redistributions](https://developer.download.nvidia.com/compute/cudnn/redist/)

    [Default location of CUDA redistributions](https://developer.download.nvidia.com/compute/cuda/redist/)

    [Default location of NCCL redistributions](https://pypi.org/project/nvidia-nccl-cu12/#history)

2) To include hermetic CUDA rules in your project, add the following in the WORKSPACE of the downstream project dependent on XLA.

   Note: use `@local_tsl` instead of `@tsl` in Tensorflow project.

   ```
   load(
      "@tsl//third_party/gpus/cuda/hermetic:cuda_json_init_repository.bzl",
      "cuda_json_init_repository",
   )

   cuda_json_init_repository()

   load(
      "@cuda_redist_json//:distributions.bzl",
      "CUDA_REDISTRIBUTIONS",
      "CUDNN_REDISTRIBUTIONS",
   )
   load(
      "@tsl//third_party/gpus/cuda/hermetic:cuda_redist_init_repositories.bzl",
      "cuda_redist_init_repositories",
      "cudnn_redist_init_repository",
   )

   cuda_redist_init_repositories(
      cuda_redistributions = CUDA_REDISTRIBUTIONS,
   )

   cudnn_redist_init_repository(
      cudnn_redistributions = CUDNN_REDISTRIBUTIONS,
   )

   load(
      "@tsl//third_party/gpus/cuda/hermetic:cuda_configure.bzl",
      "cuda_configure",
   )

   cuda_configure(name = "local_config_cuda")

   load(
      "@tsl//third_party/nccl/hermetic:nccl_redist_init_repository.bzl",
      "nccl_redist_init_repository",
   )

   nccl_redist_init_repository()

   load(
      "@tsl//third_party/nccl/hermetic:nccl_configure.bzl",
      "nccl_configure",
   )

   nccl_configure(name = "local_config_nccl")
   ```

PiperOrigin-RevId: 662981325
2024-08-14 11:47:44 -07:00
Vadym Matsishevskyi
ec90bea08d Migrate TensorFlow on newest Hermetic Python set of rules
This makes Tensorflow consistent with JAX and XLA

PiperOrigin-RevId: 647832813
2024-06-28 17:19:18 -07:00
A. Unique TensorFlower
5b1f2fb809 Internal cleanup of BUILD/.bzl files
PiperOrigin-RevId: 622283235
2024-04-05 15:27:48 -07:00
A. Unique TensorFlower
6733b822d2 Add load() statements for the builtin Bazel java rules
Loads are being added in preparation for moving the rules out of Bazel and into `rules_java`.

PiperOrigin-RevId: 622055151
2024-04-04 21:04:20 -07:00
A. Unique TensorFlower
aa6da142f3 Merged commit includes the following changes:
619575611  by A. Unique TensorFlower<gardener@tensorflow.org>:

    Run buildifier on all files where it sorts loads differently

--
619498661  by A. Unique TensorFlower<gardener@tensorflow.org>:

    [XLA:GPU][IndexAnalysis] Rename GetDefaultThreadIdToOutputIndexingMap to GetDefaultThreadIdIndexingMap.

    The "output" part was a bit confusing. We use this function for threadId->input
    mapping as well.

--
619490165  by A. Unique TensorFlower<gardener@tensorflow.org>:

    Convert S8 to BF16 in one step without going though F32.

--

PiperOrigin-RevId: 619575611
2024-03-27 18:00:18 +00:00
A. Unique TensorFlower
b945983cd7 Change default hermetic python version to 3.11. Change HERMETIC_PYTHON_VERSION to TF_PYTHON_VERSION for less confusion.
PiperOrigin-RevId: 575046805
2023-10-19 17:19:46 -07:00
A. Unique TensorFlower
f91457f258 Update rules_python: 0.25.0 -> 0.26.0.
PiperOrigin-RevId: 571910358
2023-10-09 05:34:50 -07:00
Namrata Bhave
3156d03172
Update rules_python version to 0.25.0 2023-08-29 13:43:17 +05:30
A. Unique TensorFlower
930a3845bf Update rules_python version to 0.23.1
PiperOrigin-RevId: 547306878
2023-07-11 15:06:34 -07:00
A. Unique TensorFlower
e85860e838 use hermetic Python in Tensorflow.
See ci/official/requirements_updater/README.md for details.

PiperOrigin-RevId: 546059481
2023-07-06 12:29:19 -07:00
A. Unique TensorFlower
7f39a389d5 ROLLBACK
use hermetic Python in Tensorflow/XLA/TSL builds. See ci/official/requirements_updater/README.md for details.

PiperOrigin-RevId: 540651045
2023-06-15 12:07:23 -07:00
A. Unique TensorFlower
66b9b9befa use hermetic Python in Tensorflow/XLA/TSL builds. See ci/official/requirements_updater/README.md for details.
PiperOrigin-RevId: 540478942
2023-06-14 23:08:30 -07:00
Christian Sigg
e70a5f4243 Prevent buildifier warning in WORKSPACE file.
PiperOrigin-RevId: 354993799
Change-Id: If1ed5db7cb3f9ba82b179ed9070b027088ca0493
2021-02-01 12:06:13 -08:00
Christian Sigg
da0884c7d4 [NFC, internal change] Polish copybara workflow file.
PiperOrigin-RevId: 352434171
Change-Id: I15d05e4fbd02d02cbb544100c92c79c0c8fdcc40
2021-01-18 11:07:07 -08:00
Christian Sigg
36d0f2e194 Simplify initialization of bazel repositories that TensorFlow depends on.
Repositories depending on TensorFlow should use the content of the WORKSPACE file to initialize TensorFlow and its dependencies. This will make it much less likely for us to break dependent projects when we add/change TensorFlow's dependencies.

PiperOrigin-RevId: 345391447
Change-Id: Ia5f66a341247d0da491e40aee39f460ac10d5c9b
2020-12-02 23:58:52 -08:00
Haiming Bao
04458594a8 Migrate the remote config toolchains from tensorflow to the toolchains repo.
PiperOrigin-RevId: 345158948
Change-Id: Id09fabbee85baaf2cfec6124457ddc1a13259f2e
2020-12-01 21:12:23 -08:00
Amit Patankar
0d4b7e2b08 Migrate the remote config toolchains from tensorflow to the toolchains repo.
PiperOrigin-RevId: 345065642
Change-Id: Id8ce10895bda0b2b76517f1873d69bbc56fe365b
2020-12-01 11:48:35 -08:00
Amit Patankar
4858553802 Migrate the remote config toolchains from tensorflow to the toolchains repo.
PiperOrigin-RevId: 342367364
Change-Id: I2c077b3c5d6b1d7ffd3dcd1eaa625af05094824a
2020-11-13 17:21:08 -08:00
Amit Patankar
8ef785452a Migrate the remote config toolchains from tensorflow to the toolchains repo.
PiperOrigin-RevId: 342283052
Change-Id: I75b84860268a7b941d304a5c97197638843be343
2020-11-13 10:14:48 -08:00
Jason Zaman
e6e4c60700 systemlibs: Update to build against system GRPC
- Add libgpr
    Newer grpc-1.28 has a libgpr.so that is also needed during link time
    so add it to the linkopts
- Add starlark files
    Several starlark files are load()'d from the GRPC repo, vendor them
    or add stubs as appropriate when using the system version of grpc.
- grpc WORKSPACE deps
    Several deps were loaded in WORKSPACE that were needed by grpc, they
    are not needed when building against the system but are difficult to
    stub out causing the build to fail.
    grpc_extra_deps.bzl is provided to load all the requirements, so use
    that from WORKSPACE instead of directly loading each individually.
    This is also more maintainable going forward since there is less to
    keep in sync in TF's WORKSPACE file.

Signed-off-by: Jason Zaman <jason@perfinion.com>
2020-10-21 21:14:24 -07:00
Christian Sigg
6a6071412a Remove @io_bazel_rules_docker dependencies, we no longer use them.
PiperOrigin-RevId: 318212634
Change-Id: Iada36cd6cf549b4c615be29b76803637de36d5de
2020-06-24 23:03:35 -07:00
Pete Warden
1de7105aeb Test that person detection example binary can run
PiperOrigin-RevId: 313275958
Change-Id: Ie128cccabb6e168b85920f72618530e15477a026
2020-05-26 15:14:00 -07:00
Christina Sorokin
a659b93433 rollback of change
Add two repository rules:
- @local_execution_config_platform: local platform to allow selecting locally
  executed tools on
- @local_execution_config_python: python configured for execution...

PiperOrigin-RevId: 307862682
Change-Id: Ie0320f2f137a40b418632989981c9dc072ef80e6
2020-04-22 11:47:06 -07:00
A. Unique TensorFlower
f5bb643360 Add two repository rules:
- @local_execution_config_platform: local platform to allow selecting locally
  executed tools on
- @local_execution_config_python: python configured for execution on the local
  machine during otherwise remote builds

Mark rules that are required to run locally to require our local platform.

This allows pyth...

PiperOrigin-RevId: 307771596
Change-Id: If1f0013ec88a35d507b2b622894208aab2416fe5
2020-04-22 01:47:55 -07:00
Taehee Jeong
0f631f8fb1 Add two repository rules:
- @local_execution_config_platform: local platform to allow selecting locally
  executed tools on
- @local_execution_config_python: python configured for execution on the local
  machine during otherwise remote builds

Mark rules that are required to run locally to require our local platform.

This allows python paths to differ between the remote docker image and local
machine.

For example, the local machine might have python 3.7 installed in
/usr/bin/python3, while the remote docker should use a python installed
in /usr/local/bin/python3.8.

PiperOrigin-RevId: 307585019
Change-Id: I29313121beb967b77ae123e7d1b614c688cb40ca
2020-04-21 05:20:54 -07:00
A. Unique TensorFlower
d68284a16f Add two repository rules:
- @local_execution_config_platform: local platform to allow selecting locally
  executed tools on
- @local_execution_config_python: python configured for execution on the local
  machine during otherwise remote builds

Mark rules that are required to run locally to require our local platform.

This allows python paths to differ between the remote docker image and local
machine.

For example, the local machine might have python 3.7 installed in
/usr/bin/python3, while the remote docker should use a python installed
in /usr/local/bin/python3.8.

PiperOrigin-RevId: 307558811
Change-Id: I0dc2d877a7c26b294bf2b569b4f121cf6506e7fc
2020-04-21 01:10:05 -07:00
A. Unique TensorFlower
b9e1252bcb Upgrade external dependency googleapis for GCP monitoring
PiperOrigin-RevId: 301897769
Change-Id: I03bcc9430857d2cb61aadbc5ba928b257a5b6c3c
2020-03-19 14:42:04 -07:00
A. Unique TensorFlower
f396035891 Upgrade and rename external dependency grpc in workspace for bazel.
Fixes #33758

Downstream projects depending on TensorFlow: If bazel complains, please substitute `@zlib_archive` with `@zlib`, and `@grpc` with `@com_github_grpc_grpc` in WORKPLACE.

PiperOrigin-RevId: 295824868
Change-Id: If2259d59e9d82543369e5670916b1398374c9889
2020-02-18 14:40:26 -08:00
Yifei Feng
4d4c956cd3 Automated rollback of commit 9d6198d555
PiperOrigin-RevId: 294299428
Change-Id: I70c30c3e7b855fac8d2b43bfa456b1972662b5ac
2020-02-10 14:11:18 -08:00
Brian Zhao
9d6198d555 Patching rules closure's maven download to an https url, since the current one is causing a 501.
PiperOrigin-RevId: 289903847
Change-Id: Ia34f27fd4e2a6f1116d49a77d81f613e18f73563
2020-01-15 11:48:15 -08:00
Brian Zhao
8782b7679c Move tflite http_archive and http_file WORKSPACE http_archive rules into tensorflow/workspace.bzl, where the rest of the external dependency configuration lives. This change also converts these rules into tf_http_archive, and adds appropriate mirrors.
PiperOrigin-RevId: 289569601
Change-Id: I6d9382a5f61e9a53f627efd632097062c17b9a79
2020-01-13 19:37:21 -08:00
Gunhan Gulsoy
aaea541431 Bump minimum bazel version requirement to 1.0.0
PiperOrigin-RevId: 283114685
Change-Id: Ie7160112ff379fcc7e4c4794db20f4eb24f5f8df
2019-11-30 13:23:11 -08:00
A. Unique TensorFlower
98ecdee8e6 Add python toolchains definition in python configuration
--python_path will be removed in future Bazel, we should switch to use python toolchain. But currently we want Bazel to always use the same python binary specified in configure.py regardless of what's specified in py_binary rule (PY2 or PY3). So we point both py2 and py3 runtime to the same PYTHON_BIN_PATH.

PiperOrigin-RevId: 273032026
2019-10-05 02:37:00 -07:00