Skip to content
Open
144 changes: 144 additions & 0 deletions easybuild/easyconfigs/t/TensorFlow/TensorFlow-2.21.0-foss-2025b.eb
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
easyblock = 'PythonBundle'

name = 'TensorFlow'
version = '2.21.0'

homepage = 'https://www.tensorflow.org/'
description = "An open-source software library for Machine Intelligence"

toolchain = {'name': 'foss', 'version': '2025b'}
toolchainopts = {'pic': True}

builddependencies = [
('hatchling', '1.27.0'),
('Bazel', '7.7.0', '-Java-21'),
# git 2.x required, see also https://github.com/tensorflow/tensorflow/issues/29053
('git', '2.50.1'),
('UnZip', '6.0'),
('NASM', '2.16.03'),
# Required to build some of the extensions
('poetry', '2.1.3'),
('Cython', '3.2.4'),
]

dependencies = [
('Python', '3.13.5'),
('Python-bundle-PyPI', '2025.07'),
('SciPy-bundle', '2025.07'),
('h5py', '3.14.0'),
('dill', '0.4.1'),
('flatbuffers-python', '25.2.10'),
('ml_dtypes', '0.5.3'),
('patchelf', '0.18.0'),
('protobuf-python', '6.31.1'),
('grpcio', '1.81.0'),
('wrapt', '1.17.3'),
('Markdown', '3.8.2'),
('absl-py', '2.3.1'),
('tensorboard', '2.20.0'),
('opt-einsum', '3.4.0'),
('optree', '0.18.0'),
('typing-extensions', '4.14.1'),
]

exts_list = [
('astor', '0.8.1', {
'checksums': ['6a6effda93f4e1ce9f618779b2dd1d9d84f1e32812c23a29b3fff6fd7f63fa5e'],
}),
('termcolor', '2.5.0', {
'checksums': ['998d8d27da6d48442e8e1f016119076b690d962507531df4890fcd2db2ef8a6f'],
}),
('Werkzeug', '3.1.3', {
'source_tmpl': '%(namelower)s-%(version)s.tar.gz',
'checksums': ['60723ce945c19328679790e3282cc758aa4a6040e4bb330f53d30fa546d44746'],
}),
('namex', '0.0.8', {
'checksums': ['32a50f6c565c0bb10aa76298c959507abdc0e850efe085dc38f3440fcb3aa90b'],
}),
('keras', '3.13.2', {
'checksums': ['62f0123488ac87c929c988617e14f293f7bc993811837d08bb37eff77adc85a9'],
}),
('google-pasta', '0.2.0', {
'modulename': 'pasta',
'checksums': ['c9f2c8dfc8f96d0d5808299920721be30c9eec37f2389f28904f454565c8a16e'],
}),
('astunparse', '1.6.3', {
'checksums': ['5ad93a8456f0d084c3456d059fd9a92cce667963232cbf763eac3bc5b7940872'],
}),
('tblib', '3.0.0', {
'checksums': ['93622790a0a29e04f0346458face1e144dc4d32f493714c6c3dff82a4adb77e6'],
}),
(name, version, {
'patches': [
'TensorFlow-2.4.0_dont-use-var-lock.patch',
'TensorFlow-2.21.0_disable-tf32-in-fused-matmul-tests.patch',
'TensorFlow-2.18.1_fix-xnnpack.patch',
'TensorFlow-2.18.1_fixedpoint.patch',
'TensorFlow-2.21.0_remove-libclang-dep.patch',
'TensorFlow-2.21.0_relax-flatbuffers-requirement.patch',
],
'source_tmpl': 'v%(version)s.tar.gz',
'source_urls': ['https://github.com/tensorflow/tensorflow/archive/'],
'test_script': 'TensorFlow-2.x_mnist-test.py',
'test_tag_filters_cpu': '-gpu,-tpu,-no_cuda_on_cpu_tap,-no_pip,-no_oss,-oss_serial,-benchmark-test,-v1only',
'test_tag_filters_gpu': (
'gpu,-no_gpu,-nogpu,-gpu_cupti,-no_cuda11,'
'-no_pip,-no_oss,-oss_serial,-benchmark-test,-v1only'
),
'test_targets': [
'//tensorflow/core/...',
'-//tensorflow/core:example_java_proto',
'//tensorflow/cc/...',
'//tensorflow/c/...',
'//tensorflow/python/...',
'-//tensorflow/c/eager:c_api_test_gpu',
'-//tensorflow/c/eager:c_api_distributed_test',
'-//tensorflow/c/eager:c_api_distributed_test_gpu',
'-//tensorflow/c/eager:c_api_cluster_test_gpu',
'-//tensorflow/c/eager:c_api_remote_function_test_gpu',
'-//tensorflow/c/eager:c_api_remote_test_gpu',
'-//tensorflow/core/common_runtime:collective_param_resolver_local_test',
'-//tensorflow/core/kernels/mkl:mkl_fused_ops_test',
'-//tensorflow/core/kernels/mkl:mkl_fused_batch_norm_op_test',
'-//tensorflow/core/ir/importexport/tests/roundtrip/...',
],
'buildopts': '--action_env=CPATH= --host_action_env=CPATH=',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

resetting CPATH all over the place looks wrong. Why is that done?

'testopts': (
'--action_env=CPATH= --host_action_env=CPATH= '
'--test_env=HOME=/tmp --test_timeout=3600 --test_size_filters=small '

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

HOME could be included to be set in the easyblock if not done yet

),
'testopts_gpu': (
'--action_env=CPATH= --host_action_env=CPATH= '
'--test_env=HOME=/tmp --test_timeout=3600 --test_size_filters=small '
'--run_under=//tensorflow/tools/ci_build/gpu_build:parallel_gpu_execute '
),
# EasyBuild 5.3.0's TF_SYSTEM_LIBS mapping is incompatible with TensorFlow 2.21 for these entries:
# absl_py has no usable system repository, while boringssl is auto-enabled whenever OpenSSL is loaded.
# Run Bazel in batch mode to avoid Netty server startup crashes on filesystems without robust locking.
# CPATH is cleared for Bazel actions so installed headers cannot shadow vendored repository headers.
'prebuildopts': (
"printf 'startup --batch\\n' >> .bazelrc && "
"sed -i 's/absl_py,//; s/,absl_py//; s/boringssl,//; s/,boringssl//' .tf_configure.bazelrc && "
),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

some stuff in this block looks like it really belong on the TensorFlow easyblock...

@Flamefire thoughts on this?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Definitely. The comment says the easyblock does something wrong, so that should be fixed in the easyblock

absl_py has no usable system repository

What does this mean exactly? It is mentioned at least: https://github.com/tensorflow/tensorflow/blob/651b8e62e7810de374ddb3f3c983ff9140aa260f/third_party/systemlibs/syslibs_configure.bzl#L12

while boringssl is auto-enabled whenever OpenSSL is loaded.

This is correct and intentional. Looks like you are disabling it here. Why? You cannot mix OpenSSL and BoringSSL IIRC

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You are right, I originally had these changes to get past certain build errors, but this might not be needed anymore. Let me retest without these absl_py and BoringSSL changes, in case I will post here the problem, or make a PR at easyblocks

'with_xla': True,
'checksums': [
{'v2.21.0.tar.gz': 'ef3568bb4865d6c1b2564fb5689c19b6b9a5311572cd1f2ff9198636a8520921'},
{'TensorFlow-2.4.0_dont-use-var-lock.patch':
'b14f2493fd2edf79abd1c4f2dde6c98a3e7d5cb9c25ab9386df874d5f072d6b5'},
{'TensorFlow-2.21.0_disable-tf32-in-fused-matmul-tests.patch':
'2f605322c9694ccf6e013f06f403496320445a093ceca6625fec616343f5fd32'},
{'TensorFlow-2.18.1_fix-xnnpack.patch': 'baf81d7b2b61b5a923cf1f171d5e2400df6b8bd9073d3afa7a356e3bbe11984c'},
{'TensorFlow-2.18.1_fixedpoint.patch': '5ea1eb3b32e7df5f9ae711a71778b4cae544b3380f18882186eea035873fb640'},
{'TensorFlow-2.21.0_remove-libclang-dep.patch':
'4ee3773d07991c7f75d6dd4033ccf1bb9b017de478b39b4ffb6563a6bd66b981'},
{'TensorFlow-2.21.0_relax-flatbuffers-requirement.patch':
'c500796a1fe1f3de8322b1a1abeefbd3714fb255e6600d65e3815e20484c45ee'},
],
}),
]

postinstallcmds = [
'mkdir -p %(installdir)s/bin && ln -sf "$EBROOTTENSORBOARD/bin/tensorboard" %(installdir)s/bin/tensorboard',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@bedroesb Any particular reason for this?

If tensorboard is a dependency, then the command will already be available when this TensorFlow module is loaded, I don't really see the point of doing this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I had an error related to this, but let me retry without, many things have changed

]

moduleclass = 'lib'
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Fixes failing FusedMatMul test on certain GPU models
--- tensorflow/core/kernels/matmul_op_test.cc.orig 2026-06-29 00:00:00.000000000 +0200
+++ tensorflow/core/kernels/matmul_op_test.cc 2026-06-29 00:00:00.000000000 +0200
@@ -24,7 +24,8 @@
#include "tensorflow/core/framework/tensor.h"
#include "tensorflow/core/framework/types.h"
#include "tensorflow/core/kernels/ops_testutil.h"
#include "tensorflow/core/lib/core/status_test_util.h"
+#include "tensorflow/core/platform/tensor_float_32_utils.h"
#include "tensorflow/core/platform/test.h"
#include "tensorflow/core/platform/test_benchmark.h"
#include "tensorflow/core/protobuf/rewriter_config.pb.h"
@@ -334,6 +335,7 @@
// -------------------------------------------------------------------------- //

TYPED_TEST_P(FusedMatMulWithBiasOpTest, MatMul256x128x64) {
+ tensorflow::enable_tensor_float_32_execution(false);
this->VerifyMatMulWithBias(256, 128, 64, false, false);
this->VerifyMatMulWithBias(256, 128, 64, true, false);
this->VerifyMatMulWithBias(256, 128, 64, false, true);
@@ -341,6 +343,7 @@
}

TYPED_TEST_P(FusedMatMulWithBiasOpTest, MatMul1x256x256) {
+ tensorflow::enable_tensor_float_32_execution(false);
this->VerifyMatMulWithBias(1, 256, 256, false, false);
this->VerifyMatMulWithBias(1, 256, 256, true, false);
this->VerifyMatMulWithBias(1, 256, 256, false, true);
@@ -348,6 +351,7 @@
}

TYPED_TEST_P(FusedMatMulWithBiasOpTest, MatMul256x256x1) {
+ tensorflow::enable_tensor_float_32_execution(false);
this->VerifyMatMulWithBias(256, 256, 1, false, false);
this->VerifyMatMulWithBias(256, 256, 1, true, false);
this->VerifyMatMulWithBias(256, 256, 1, false, true);
@@ -371,6 +375,7 @@
}

TYPED_TEST_P(FusedMatMulWithBiasOpTest, MatMul256x128x64WithActivation) {
+ tensorflow::enable_tensor_float_32_execution(false);
for (const std::string& activation : GetActivations(this->kTValueType)) {
this->VerifyConv2DWithBiasAndActivation(256, 128, 64, false, false,
activation);
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
TensorFlow 2.21.0 only uses flatbuffers as a Python runtime dependency in this
EasyBuild configuration. Keep the wheel metadata compatible with the shared
flatbuffers-python dependency used by other 2025b recipes.

--- tensorflow/tools/pip_package/setup.py.tpl.orig 2026-06-29 00:00:00.000000000 +0200
+++ tensorflow/tools/pip_package/setup.py.tpl 2026-06-29 00:00:00.000000000 +0200
@@ -97,7 +97,7 @@
REQUIRED_PACKAGES = [
'absl-py >= 1.0.0',
'astunparse >= 1.6.0',
- 'flatbuffers >= 25.9.23',
+ 'flatbuffers >= 25.2.10',
'gast >=0.2.1,!=0.5.0,!=0.5.1,!=0.5.2',
'google_pasta >= 0.1.1',
'libclang >= 13.0.0',
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
libclang was introduced in
https://github.com/tensorflow/tensorflow/commit/c211472000ff57bac7fcec9b0465cf73b37bf135
> This is in preparation to open-source TF's TFRT backend.
> TFRT generates code using libclang python bindings as part of the build.
Hence it is not currently used and as it is not (easily) available for all architectures
simply remove it.

--- tensorflow/tools/pip_package/setup.py.tpl.orig 2026-06-29 00:00:00.000000000 +0200
+++ tensorflow/tools/pip_package/setup.py.tpl 2026-06-29 00:00:00.000000000 +0200
@@ -97,7 +97,6 @@
'flatbuffers >= 25.9.23',
'gast >=0.2.1,!=0.5.0,!=0.5.1,!=0.5.2',
'google_pasta >= 0.1.1',
- 'libclang >= 13.0.0',
'opt_einsum >= 2.3.2',
'packaging',
'protobuf >= 6.31.1, < 8.0.0',
Loading