2018-11-19 13:29:47 -08:00
|
|
|
# Copyright 2018 Google LLC
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# https://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
2018-12-11 15:45:56 -08:00
|
|
|
from setuptools import setup, find_packages
|
2019-02-13 20:02:14 -08:00
|
|
|
|
2022-06-21 12:41:26 -07:00
|
|
|
_current_jaxlib_version = '0.3.14'
|
2022-02-10 11:29:06 -08:00
|
|
|
# The following should be updated with each new jaxlib release.
|
2022-06-28 13:01:27 -07:00
|
|
|
_latest_jaxlib_version_on_pypi = '0.3.14'
|
2021-10-18 19:55:51 -07:00
|
|
|
_available_cuda_versions = ['11']
|
|
|
|
_default_cuda_version = '11'
|
|
|
|
_available_cudnn_versions = ['82', '805']
|
|
|
|
_default_cudnn_version = '82'
|
2022-06-27 09:21:54 -04:00
|
|
|
_libtpu_version = '0.1.dev20220627'
|
2019-08-04 12:12:53 -04:00
|
|
|
|
2021-03-17 10:46:38 -07:00
|
|
|
_dct = {}
|
2019-02-13 20:02:14 -08:00
|
|
|
with open('jax/version.py') as f:
|
2021-03-17 10:46:38 -07:00
|
|
|
exec(f.read(), _dct)
|
|
|
|
__version__ = _dct['__version__']
|
|
|
|
_minimum_jaxlib_version = _dct['_minimum_jaxlib_version']
|
2018-11-18 15:17:32 -08:00
|
|
|
|
|
|
|
setup(
|
|
|
|
name='jax',
|
2019-02-13 20:02:14 -08:00
|
|
|
version=__version__,
|
2018-11-18 15:17:32 -08:00
|
|
|
description='Differentiate, compile, and transform Numpy code.',
|
|
|
|
author='JAX team',
|
2018-12-06 21:35:03 -05:00
|
|
|
author_email='jax-dev@google.com',
|
2019-04-06 14:16:22 -07:00
|
|
|
packages=find_packages(exclude=["examples"]),
|
2021-01-14 15:08:53 -05:00
|
|
|
package_data={'jax': ['py.typed']},
|
2021-07-15 09:50:30 -04:00
|
|
|
python_requires='>=3.7',
|
2019-01-15 20:14:19 -05:00
|
|
|
install_requires=[
|
2020-12-30 11:29:34 +00:00
|
|
|
'absl-py',
|
2022-01-04 12:11:00 -08:00
|
|
|
'numpy>=1.19',
|
2020-12-30 11:29:34 +00:00
|
|
|
'opt_einsum',
|
2022-06-24 15:01:16 -04:00
|
|
|
'scipy>=1.5',
|
Cleanup internal representation of XLA translation rules.
Over time JAX has sprouted many variants of XLA translation rules, each with slightly different but overlapping arguments. This change consolidates them into a new xla.TranslationRule signature:
rule(ctx, avals_in, avals_out, *args, **params)
where ctx contains the parts of the other signatures that were typically not specific to a particular equation.
Since there are many JAX rules to migrate, and even a number of translation rules belonging to projects downstream of JAX, we leave backwards compatibility shims around `xla.translations`, `xla.backend_specific_translations`, and `xla.call_translations` which seem to be the only ones used outside JAX itself.
In passing, this change alters the semantics of `backend` arguments to nested `jit` blocks. We now always canonicalize the backend to a specific backend at the outermost `jit`, and do not complain if an inner `jit` has an explicit `backend` that matches the current default choice.
PiperOrigin-RevId: 403607667
2021-10-16 07:52:57 -07:00
|
|
|
'typing_extensions',
|
2022-05-31 12:46:54 -07:00
|
|
|
'etils[epath]'
|
2019-01-15 20:14:19 -05:00
|
|
|
],
|
2021-03-16 11:40:46 -07:00
|
|
|
extras_require={
|
2021-03-17 10:46:38 -07:00
|
|
|
# Minimum jaxlib version; used in testing.
|
|
|
|
'minimum-jaxlib': [f'jaxlib=={_minimum_jaxlib_version}'],
|
|
|
|
|
2021-03-16 11:40:46 -07:00
|
|
|
# CPU-only jaxlib can be installed via:
|
|
|
|
# $ pip install jax[cpu]
|
2021-07-02 09:49:49 -07:00
|
|
|
'cpu': [f'jaxlib=={_current_jaxlib_version}'],
|
2021-03-16 11:40:46 -07:00
|
|
|
|
2022-02-10 11:29:06 -08:00
|
|
|
# Used only for CI builds that install JAX from github HEAD.
|
2022-02-10 11:58:30 -08:00
|
|
|
'ci': [f'jaxlib=={_latest_jaxlib_version_on_pypi}'],
|
2022-02-10 11:29:06 -08:00
|
|
|
|
2021-06-23 02:18:53 +00:00
|
|
|
# Cloud TPU VM jaxlib can be installed via:
|
2021-06-23 14:13:15 -07:00
|
|
|
# $ pip install jax[tpu] -f https://storage.googleapis.com/jax-releases/jax_releases.html
|
2021-06-23 02:18:53 +00:00
|
|
|
'tpu': [f'jaxlib=={_current_jaxlib_version}',
|
Changes to make jax[tpu] work better in a docker container.
1. In cloud_tpu_init.py, check whether we're on a Cloud TPU VM by
looking for the libtpu Python package, instead of /lib/libtpu.so
(which isn't necessarily present in a docker container). JAX now
relies on the libtpu package instead of the system libtpu.so, so
this makes more sense either way. This means we'll try/catch an
ImportError in all non-TPU environments when importing jax, which
hopefully isn't noticeably slow.
2. Add requests as a jax[tpu] dependency, since it's needed by
cloud_tpu_init.py. This comes pre-installed on Cloud TPU VMs, but
may not be installed in docker containers, virtualenvs, etc.
I manually tested by creating the following Dockerfile on a Cloud TPU VM:
```
FROM ubuntu:18.04
RUN apt update && apt install git python3-pip -y
RUN git clone https://github.com/skye/jax && cd jax && git checkout tpu_docker
WORKDIR jax
RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install .[tpu] -f https://storage.googleapis.com/jax-releases/libtpu_releases.html
CMD ["python3", "-c", "import jax; print(jax.device_count())"]
```
And then running the following commands:
```
$ sudo docker build -t jax-test .
$ sudo docker run --privileged jax-test
8
```
Note the `--privileged` flags is necessary to let the container access
the TPU devices in /dev.
2021-07-12 16:57:45 -07:00
|
|
|
f'libtpu-nightly=={_libtpu_version}',
|
|
|
|
# Required by cloud_tpu_init.py
|
|
|
|
'requests'],
|
2021-06-23 02:18:53 +00:00
|
|
|
|
2021-03-16 11:40:46 -07:00
|
|
|
# CUDA installations require adding jax releases URL; e.g.
|
2021-10-18 19:55:51 -07:00
|
|
|
# Cuda installation defaulting to a CUDA and Cudnn version defined above.
|
|
|
|
# $ pip install jax[cuda] -f https://storage.googleapis.com/jax-releases/jax_releases.html
|
|
|
|
'cuda': [f"jaxlib=={_current_jaxlib_version}+cuda{_default_cuda_version}.cudnn{_default_cudnn_version}"],
|
|
|
|
|
|
|
|
# CUDA installations require adding jax releases URL; e.g.
|
2021-10-19 06:24:27 -07:00
|
|
|
# $ pip install jax[cuda11_cudnn82] -f https://storage.googleapis.com/jax-releases/jax_releases.html
|
|
|
|
# $ pip install jax[cuda11_cudnn805] -f https://storage.googleapis.com/jax-releases/jax_releases.html
|
|
|
|
**{f'cuda{cuda_version}_cudnn{cudnn_version}': f"jaxlib=={_current_jaxlib_version}+cuda{cuda_version}.cudnn{cudnn_version}"
|
2021-10-18 19:55:51 -07:00
|
|
|
for cuda_version in _available_cuda_versions for cudnn_version in _available_cudnn_versions}
|
2021-03-16 11:40:46 -07:00
|
|
|
},
|
2018-11-18 15:17:32 -08:00
|
|
|
url='https://github.com/google/jax',
|
|
|
|
license='Apache-2.0',
|
2020-12-30 11:29:34 +00:00
|
|
|
classifiers=[
|
|
|
|
"Programming Language :: Python :: 3.7",
|
2020-12-30 13:20:13 -08:00
|
|
|
"Programming Language :: Python :: 3.8",
|
2021-07-09 12:42:39 -07:00
|
|
|
"Programming Language :: Python :: 3.9",
|
2022-05-07 13:38:55 +01:00
|
|
|
"Programming Language :: Python :: 3.10",
|
2021-06-10 16:06:11 +02:00
|
|
|
],
|
|
|
|
zip_safe=False,
|
2018-11-18 15:17:32 -08:00
|
|
|
)
|