Skip to content

Commit 8799720

Browse files
author
Richard Top
committed
{2023.06}[foss/2023a] TensorFlow v2.15.1 w/ CUDA 12.1.1 + eb_hooks
1 parent 66b8ffc commit 8799720

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
easyconfigs:
2+
- TensorFlow-2.15.1-foss-2023a-CUDA-12.1.1.eb

eb_hooks.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,56 @@ def post_prepare_hook(self, *args, **kwargs):
256256
post_prepare_hook_ignore_zen4_gcccore1220_error(self, *args, **kwargs)
257257

258258

259+
def parse_hook_tensorflow_CUDA(ec, eprefix):
260+
"""
261+
Fix the Python and environment used while building and running tests for TensorFlow with CUDA
262+
"""
263+
if ec.name == 'TensorFlow' and ec.version == '2.15.1' :
264+
# Check if CUDA is in dependencies
265+
has_cuda = any(
266+
(isinstance(dep, (list, tuple)) and dep[0] == 'CUDA') or
267+
(isinstance(dep, dict) and dep.get('name') == 'CUDA')
268+
for dep in ec.get('dependencies', [])
269+
)
270+
271+
if has_cuda:
272+
ec['preconfigopts'] = (
273+
'export TF_NEED_CUDA=1 && '
274+
'export CUDA_TOOLKIT_PATH=$EBROOTCUDA && '
275+
'export TF_CUDA_INCLUDE_PATH=$EBROOTCUDA/include && '
276+
'export CUDNN_INSTALL_PATH=$EBROOTCUDNN && '
277+
'export GCC_HOST_COMPILER_PATH=$EBROOTGCC/bin/gcc && '
278+
'sed -i \'s|--define=PREFIX=/usr|--define=PREFIX=\\$EESSI_EPREFIX|g\' .bazelrc && '
279+
)
280+
281+
ec['buildopts'] = [
282+
'--linkopt=-Wl,--disable-new-dtags --host_linkopt=-Wl,--disable-new-dtags --action_env=GCC_HOST_COMPILER_PATH=$EBROOT
283+
GCC/bin/gcc --host_action_env=GCC_HOST_COMPILER_PATH=$EBROOTGCC/bin/gcc --linkopt=-Wl,-rpath,$EBROOTCUDA/lib:$EBROOTCUDNN/lib:$EBROOT
284+
NCCL/lib --host_linkopt=-Wl,-rpath,$EBROOTCUDA/lib:$EBROOTCUDNN/lib:$EBROOTNCCL/lib',
285+
]
286+
287+
ec['pretestopts'] = (
288+
#'patchelf --set-interpreter "$EESSI_EPREFIX/lib64/ld-linux-%(arch)s.so.1" '
289+
#'"%(builddir)s/%(name)s/bazel-root/0b9648e0837f9e5bb579e0e2e64adf3f/external/python_aarch64-unknown-linux-gnu/bin/python%(pyshortver)s" && '
290+
291+
'mv "%(builddir)s/%(name)s/bazel-root/0b9648e0837f9e5bb579e0e2e64adf3f/external/python_aarch64-unknown-linux-gnu/bin/python%(pyshortver)s" "%(builddir)s/%(name)s/bazel-root/0b9648e0837f9e5bb579e0e2e64adf3f/external/python_aarch64-unknown-linux-gnu/bin/python%(pyshortver)s.old" && cp -f $EBROOTPYTHON/bin/python%(pyshortver)s "%(builddir)s/%(name)s/bazel-root/0b9648e0837f9e5bb579e0e2e64adf3f/external/python_aarch64-unknown-linux-gnu/bin/python%(pyshortver)s" && '
292+
293+
294+
295+
#'LD_LIBRARY_PATH=$EBROOTCUDA/lib:$EBROOTCUDNN/lib:$EBROOTNCCL/lib:$LD_LIBRARY_PATH && '
296+
)
297+
298+
ec['postinstallcmds'] = [
299+
'mkdir -p %(installdir)s/bin',
300+
'ln -s $EBROOTCUDA/bin/cuobjdump %(installdir)s/bin/cuobjdump',
301+
'chmod 755 -R %(builddir)s',
302+
]
303+
304+
print_msg("TensorFlow-CUDA required changes are applied!!!"),
305+
else:
306+
raise EasyBuildError("TensorFlow-CUDA specific hook triggered for non-TensorFlow-CUDA easyconfig?!")
307+
308+
259309
def parse_hook_casacore_disable_vectorize(ec, eprefix):
260310
"""
261311
Disable 'vectorize' toolchain option for casacore 3.5.0 on aarch64/neoverse_v1
@@ -1298,6 +1348,7 @@ def post_module_hook(self, *args, **kwargs):
12981348

12991349

13001350
PARSE_HOOKS = {
1351+
'TensorFlow': parse_hook_tensorflow_CUDA,
13011352
'casacore': parse_hook_casacore_disable_vectorize,
13021353
'CGAL': parse_hook_cgal_toolchainopts_precise,
13031354
'fontconfig': parse_hook_fontconfig_add_fonts,

0 commit comments

Comments
 (0)