Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix and cleanup jax EC #13758

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 26 additions & 30 deletions easybuild/easyconfigs/j/jax/jax-0.2.19-foss-2020b.eb
Original file line number Diff line number Diff line change
Expand Up @@ -4,61 +4,61 @@ easyblock = 'PythonBundle'

name = 'jax'
version = '0.2.19'
local_jaxlib_ver = '0.1.70'
homepage = 'https://pypi.python.org/pypi/jax'
description = """Composable transformations of Python+NumPy programs: differentiate, vectorize, JIT to GPU/TPU, and
more"""
description = """Composable transformations of Python+NumPy programs:
differentiate, vectorize, JIT to GPU/TPU, and more"""

toolchain = {'name': 'foss', 'version': '2020b'}

builddependencies = [
('Bazel', '3.7.2'),
('Cython', '0.29.22'),
('pytest-xdist', '2.3.0'),
('pytest-benchmark', '3.4.1'),
]

dependencies = [
('Python', '3.8.6'),
('SciPy-bundle', '2020.11'),
('Cython', '0.29.22'),
('flatbuffers-python', '1.12'),
]

# downloading TensorFlow tarball to avoid that Bazel downloads it during the build
# note: this *must* be the exact same commit as used in jaxlib-*/WORKSPACE
local_tf_commit = '4039feeb743bc42cd0a3d8146ce63fc05d23eb8d'
local_tf_dir = 'tensorflow-%s' % local_tf_commit
local_tf_builddir = '%(builddir)s/' + local_tf_dir

local_tf_builddir = "%%(builddir)s/tensorflow-%s" % local_tf_commit

local_jax_prebuildopts = "sed -i -e 's$pathToSed$%s$g' WORKSPACE && " % local_tf_builddir
local_jax_prebuildopts = "sed -i 's$pathToSed$%s$g' WORKSPACE && " % local_tf_builddir

local_jax_build_cmd = 'python build/build.py '
local_jax_build_cmd += '--target_cpu_features=native '
local_jax_build_cmd += '--bazel_startup_options="--output_user_root=%(builddir)s" '
local_jax_build_cmd += '--bazel_path="$EBROOTBAZEL/bin/bazel" '
local_jax_build_cmd += '--bazel_options=--subcommands '
local_jax_build_cmd += '--bazel_options=--jobs=%(parallel)s --bazel_options=--action_env=PYTHONPATH '
local_jax_build_cmd += '--bazel_options=--jobs=%(parallel)s '
local_jax_build_cmd += '--bazel_options=--action_env=PYTHONPATH '
local_jax_build_cmd += '--bazel_options=--action_env=EBPYTHONPREFIXES'

use_pip = True

default_easyblock = 'PythonPackage'
default_component_specs = {
'sources': [SOURCE_TAR_GZ],
'source_urls': [PYPI_SOURCE],
'start_dir': '%(name)s-%(version)s',
'use_pip': True,
'sanity_pip_check': True,
'download_dep_fail': True,
}

components = [
('absl-py', '0.13.0', {
'options': {'modulename': 'absl'},
'easyblock': 'PythonPackage',
'checksums': ['6953272383486044699fd0e9f00aad167a27e08ce19aae66c6c4b10e7e767793'],
'use_pip': True,
}),
('jaxlib', local_jaxlib_ver, {
'easyblock': 'PythonPackage',
('jaxlib', '0.1.70', {
'sources': [
'jaxlib-v%s.zip' % local_jaxlib_ver,
'%(name)s-v%(version)s.tar.gz',
{
'download_filename': '%s.tar.gz' % local_tf_commit,
'filename': 'tensorflow-%s.tar.gz' % local_tf_commit,
Expand All @@ -69,24 +69,24 @@ components = [
'https://github.com/tensorflow/tensorflow/archive/'
],
'patches': [
('jaxlib-%s_no-tensorflow-download.patch' % local_jaxlib_ver, 1),
('TensorFlow-%s_mlir-build-env.patch' % local_tf_commit, '../tensorflow-%s' % local_tf_commit),
'%(name)s-%(version)s_add-bazel-args-to-shutdown.patch',
'%(name)s-%(version)s_no-tensorflow-download.patch',
('TensorFlow-%s_mlir-build-env.patch' % local_tf_commit, '../' + local_tf_dir),
],
'checksums': [
# jaxlib-v0.1.70.zip
'1205b180de70c98899d842f75bb589599c10a3c7a1c6099475c3a7d39b2e44ac',
# jaxlib-v0.1.70.tar.gz
'5d136c4b72bb254a3700cbac276ebe77108841936ff6d728050775f24a8e36fe',
# tensorflow-4039feeb743bc42cd0a3d8146ce63fc05d23eb8d.tar.gz
'0f13410284b9186e436350e9617b3bed2d65f1dc1a220fd37ad9ef43c2035663',
# jaxlib-0.1.70_add-bazel-args-to-shutdown.patch
'c0ea6abd7827d3c37bdd60c30c7b0613fc86b91274c6a1a4cf13a3c7f9ce7631',
# jaxlib-0.1.70_no-tensorflow-download.patch
'1496c6be9336fb563b997f8da83d690a9b3a0a6e29fdd87fac60409300a2fd95',
# TensorFlow-4039feeb743bc42cd0a3d8146ce63fc05d23eb8d-build-env.patch
'd067836b1d18d66a8c69fb3db311855c8a56c0106d42a11299a1733c385e9c22',
],
'start_dir': 'jax-jaxlib-v%s' % local_jaxlib_ver,
'start_dir': 'jax-jaxlib-v%(version)s',
'prebuildopts': local_jax_prebuildopts,
'use_pip': True,
'sanity_pip_check': True,
'download_dep_fail': True,
'buildcmd': local_jax_build_cmd,
'install_src': 'dist/*.whl',
}),
Expand All @@ -97,17 +97,13 @@ exts_list = [
'checksums': ['59f6475f77bbc37dcf7cd748519c0ec60722e91e63ca114e68821c0c54a46549'],
}),
(name, version, {
'checksums': ['e55534680a05b6ced92dadde307bd3b2207efd1aaaec304e96197b00ad7560d3'],
'source_tmpl': '%(name)s-v%(version)s.tar.gz',
'source_urls': ['https://github.com/google/jax/archive/'],
'checksums': ['fb6f665b1461ac67954c1004da00d12e1c41b65b744a5fa0311d26d1a784a96c'],
'runtest': 'pytest -n %(parallel)s tests',
}),
]

# can't run tests in sanity check step, because build dependencies must be available
postinstallcmds = [
"cd %%(builddir)s/jax-jaxlib-v%s && "
"PYTHONPATH=%%(installdir)s/lib/python%%(pyshortver)s/site-packages:$PYTHONPATH "
"pytest -n auto tests" % local_jaxlib_ver,
]

sanity_pip_check = True

moduleclass = 'tools'
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Pass bazel_startup_options also to the shutdown call to avoid it still using $HOME.
See https://github.com/google/jax/issues/7639

Author: Alexander Grund (TU Dresden)

diff --git a/build/build.py b/build/build.py
index dc275042..44a68a71 100755
--- a/build/build.py
+++ b/build/build.py
@@ -597,7 +597,7 @@ def main():
f"--cpu={wheel_cpu}"])
print(" ".join(command))
shell(command)
- shell([bazel_path, "shutdown"])
+ shell([bazel_path] + args.bazel_startup_options + ["shutdown"])


if __name__ == "__main__":