···2424, flatbuffers
2525, isPy39
2626, lib
2727+, python
2728, scipy
2829, stdenv
2930 # Options:
3031, cudaSupport ? config.cudaSupport or false
3132}:
32333333-# Note that these values are tied to the specific version of the GPU wheel that
3434-# we fetch. When updating, try to go for the latest possible versions that are
3535-# still compatible with the cudatoolkit and cudnn versions available in nixpkgs.
3434+# There are no jaxlib wheels targeting cudnn <8.0.5, and although there are
3535+# wheels for cudatoolkit <11.1, we don't support them.
3636assert cudaSupport -> lib.versionAtLeast cudatoolkit_11.version "11.1";
3737assert cudaSupport -> lib.versionAtLeast cudnn.version "8.0.5";
38383939let
4040- device = if cudaSupport then "gpu" else "cpu";
4141-in
4242-buildPythonPackage rec {
4343- pname = "jaxlib";
4440 version = "0.3.0";
4545- format = "wheel";
46414747- # At the time of writing (8/19/21), there are releases for 3.7-3.9. Supporting
4848- # all of them is a pain, so we focus on 3.9, the current nixpkgs python3
4949- # version.
5050- disabled = !isPy39;
4242+ pythonVersion = python.pythonVersion;
51435252- # Find new releases at https://storage.googleapis.com/jax-releases.
5353- src = {
5454- cpu = fetchurl {
4444+ # Find new releases at https://storage.googleapis.com/jax-releases. When
4545+ # upgrading, you can get these hashes from prefetch.sh.
4646+ cpuSrcs = {
4747+ "3.9" = fetchurl {
5548 url = "https://storage.googleapis.com/jax-releases/nocuda/jaxlib-${version}-cp39-none-manylinux2010_x86_64.whl";
5656- sha256 = "151p4vqli8x0iqgrzrr8piqk7d76a2xq2krf23jlb142iam5bw01";
4949+ hash = "sha256-AfBVqoqChEXlEC5PgbtQ5rQzcbwo558fjqCjSPEmN5Q=";
5750 };
5858- gpu = fetchurl {
5959- # Note that there's also a release targeting cuDNN 8.2, but unfortunately
6060- # we don't yet have that packaged at the time of writing (02/03/2022).
6161- # Check pkgs/development/libraries/science/math/cudnn/default.nix for more
6262- # details.
5151+ "3.10" = fetchurl {
5252+ url = "https://storage.googleapis.com/jax-releases/nocuda/jaxlib-${version}-cp310-none-manylinux2010_x86_64.whl";
5353+ hash = "sha256-9uBkFOO8LlRpO6AP+S8XK9/d2yRdyHxQGlbAjShqHRQ=";
5454+ };
5555+ };
5656+5757+ gpuSrcs = {
5858+ "3.9-805" = fetchurl {
6359 url = "https://storage.googleapis.com/jax-releases/cuda11/jaxlib-${version}+cuda11.cudnn805-cp39-none-manylinux2010_x86_64.whl";
6464- sha256 = "0z15rdw3a8sq51rpjmfc41ix1q095aasl79rvlib85ir6f3wh2h8";
6565-6666- # This is what the cuDNN 8.2 download looks like for future reference:
6767- # url = "https://storage.googleapis.com/jax-releases/cuda11/jaxlib-${version}+cuda11.cudnn82-cp39-none-manylinux2010_x86_64.whl";
6868- # sha256 = "000mnm2masm3sx3haddcmgw43j4gxa3m4fcm14p9nb8dnncjkgpb";
6060+ hash = "sha256-CArIhzM5FrQi3TkdqpUqCeDQYyDMVXlzKFgjNXjLJXw=";
6161+ };
6262+ "3.9-82" = fetchurl {
6363+ url = "https://storage.googleapis.com/jax-releases/cuda11/jaxlib-${version}+cuda11.cudnn82-cp39-none-manylinux2010_x86_64.whl";
6464+ hash = "sha256-Q0plVnA9pUNQ+gCHSXiLNs4i24xCg8gBGfgfYe3bot4=";
6565+ };
6666+ "3.10-805" = fetchurl {
6767+ url = "https://storage.googleapis.com/jax-releases/cuda11/jaxlib-${version}+cuda11.cudnn805-cp310-none-manylinux2010_x86_64.whl";
6868+ hash = "sha256-JopevCEAs0hgDngIId6NqbLam5YfcS8Lr9cEffBKp1U=";
6969+ };
7070+ "3.10-82" = fetchurl {
7171+ url = "https://storage.googleapis.com/jax-releases/cuda11/jaxlib-${version}+cuda11.cudnn82-cp310-none-manylinux2010_x86_64.whl";
7272+ hash = "sha256-2f5TwbdP7EfQNRM3ZcJXCAkS2VXBwNYH6gwT9pdu3Go=";
6973 };
7070- }.${device};
7474+ };
7575+in
7676+buildPythonPackage rec {
7777+ pname = "jaxlib";
7878+ inherit version;
7979+ format = "wheel";
8080+8181+ # At the time of writing (2022-03-03), there are releases for <=3.10.
8282+ # Supporting all of them is a pain, so we focus on 3.9, the current nixpkgs
8383+ # python3 version, and 3.10.
8484+ disabled = !(pythonVersion == "3.9" || pythonVersion == "3.10");
8585+8686+ src =
8787+ if !cudaSupport then cpuSrcs."${pythonVersion}" else
8888+ let
8989+ # jaxlib wheels are currently provided for cudnn versions at least 8.0.5 and
9090+ # 8.2. Try to use 8.2 whenever possible.
9191+ cudnnVersion = if (lib.versionAtLeast cudnn.version "8.2") then "82" else "805";
9292+ in
9393+ gpuSrcs."${pythonVersion}-${cudnnVersion}";
71947295 # Prebuilt wheels are dynamically linked against things that nix can't find.
7396 # Run `autoPatchelfHook` to automagically fix them.