{"id":18652919,"url":"https://github.com/elixir-nx/xla","last_synced_at":"2025-05-16T01:07:40.947Z","repository":{"id":43775771,"uuid":"404832884","full_name":"elixir-nx/xla","owner":"elixir-nx","description":"Pre-compiled XLA extension","archived":false,"fork":false,"pushed_at":"2025-04-29T02:44:28.000Z","size":133,"stargazers_count":93,"open_issues_count":6,"forks_count":24,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-04-29T03:43:44.550Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elixir-nx.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-09T18:40:25.000Z","updated_at":"2025-04-25T02:51:13.000Z","dependencies_parsed_at":"2023-02-01T06:15:18.405Z","dependency_job_id":"60af064e-ba7a-4b84-a544-4e5e6f0ecabd","html_url":"https://github.com/elixir-nx/xla","commit_stats":{"total_commits":98,"total_committers":8,"mean_commits":12.25,"dds":0.2142857142857143,"last_synced_commit":"e7f24308aa27c75ed5ad44e2b11e9d134a0f4016"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-nx%2Fxla","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-nx%2Fxla/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-nx%2Fxla/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-nx%2Fxla/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elixir-nx","download_url":"https://codeload.github.com/elixir-nx/xla/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254301813,"owners_count":22047970,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T07:09:23.020Z","updated_at":"2025-05-16T01:07:35.939Z","avatar_url":"https://github.com/elixir-nx.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# XLA\n\n\u003c!-- Docs --\u003e\n\nPrecompiled [XLA](https://github.com/openxla/xla) binaries for [EXLA](https://github.com/elixir-nx/nx/tree/main/exla).\n\nCurrently supports UNIX systems, including macOS (although no built-in support for Apple Metal).\nWindows platforms are only supported upstream via [WSL](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux).\n\n## Usage\n\nEXLA already depends on this package, so you generally don't need to install it yourself.\nThere is however a number of environment variables that you may want to use in order to\ncustomize the variant of XLA binary.\n\nThe binaries are always built/downloaded to match the current configuration, so you should\nset the environment variables in `.bash_profile` or a similar configuration file so you don't\nneed to export it in every shell session.\n\n#### `XLA_TARGET`\n\nThe default value is usually `cpu`, which implies the final the binary supports targeting\nonly the host CPU. If a matching CUDA version is detected, the target is set to CUDA accordingly.\n\n| Value | Target environment |\n| --- | --- |\n| cpu | |\n| tpu | libtpu |\n| cuda12 | CUDA \u003e= 12.1, cuDNN \u003e= 9.1 and \u003c 10.0 |\n| cuda | CUDA x.y, cuDNN (building from source only) |\n| rocm | ROCm (building from source only) |\n\nTo use XLA with NVidia GPU you need [CUDA](https://developer.nvidia.com/cuda-downloads)\nand [cuDNN](https://developer.nvidia.com/cudnn) compatible with your GPU drivers.\nSee [the installation instructions](https://docs.nvidia.com/deeplearning/cudnn/install-guide/index.html)\nand [the cuDNN support matrix](https://docs.nvidia.com/deeplearning/cudnn/support-matrix/index.html)\nfor version compatibility. To use precompiled XLA binaries specify a target matching\nyour CUDA version (like `cuda12`). You can find your CUDA version by running `nvcc --version`\n(note that `nvidia-smi` shows the highest supported CUDA version, not the installed one).\nWhen building from source it's enough to specify `cuda` as the target.\n\nNote that all precompiled Linux binaries assume glibc 2.31 or newer.\n\n##### Notes for ROCm\n\nFor GPU support, we primarily rely on CUDA, because of the popularity and availability\nin the cloud. In case you use ROCm and it does not work, please open up an issue and\nwe will be happy to help.\n\nIn addition to building in a local environment, you can build the ROCm binary using\nthe Docker-based scripts in [`builds/`](https://github.com/elixir-nx/xla/tree/main/builds). You may want to adjust the ROCm\nversion in `rocm.Dockerfile` accordingly.\n\nWhen you encounter errors at runtime, you may want to set `ROCM_PATH=/opt/rocm-5.7.0`\nand `LD_LIBRARY_PATH=\"/opt/rocm-5.7.0/lib\"` (with your respective version). For further\nissues, feel free to open an issue.\n\n#### `XLA_BUILD`\n\nDefaults to `false`. If `true` the binary is built locally, which may be intended\nif no precompiled binary is available for your target environment. Once set, you\nmust run `mix deps.clean xla --build` explicitly to force XLA to recompile.\nBuilding has a number of dependencies, see *Building from source* below.\n\n#### `XLA_ARCHIVE_URL`\n\nA URL pointing to a specific build of the `.tar.gz` archive. When using this option\nyou need to make sure the build matches your OS, CPU architecture and the XLA target.\n\n#### `XLA_ARCHIVE_PATH`\n\nJust like `XLA_ARCHIVE_URL`, but pointing to a local `.tar.gz` archive file.\n\n#### `XLA_CACHE_DIR`\n\nThe directory to store the downloaded and built archives in. Defaults to the standard\ncache location for the given operating system.\n\n#### `XLA_TARGET_PLATFORM`\n\nThe target triplet describing the target platform, such as `aarch64-linux-gnu`. By default\nthis target is inferred for the host, however you may want to override this when cross-compiling\nthe project using Nerves.\n\n## Building from source\n\n\u003e Note: currently only macOS and Linux is supported. When on Windows, the best option\n\u003e to use XLA and EXLA is by running inside WSL.\n\nTo build the XLA binaries locally you need to set `XLA_BUILD=true` and possibly `XLA_TARGET`.\nKeep in mind that the compilation usually takes a very long time.\n\nYou will need the following installed in your system for the compilation:\n\n  * [Git](https://git-scm.com/) for fetching XLA source\n  * [Bazel v6.5.0](https://bazel.build/) for compiling XLA\n  * [Python3](https://python.org) with NumPy installed for compiling XLA\n\n### Common issues\n\n#### Bazel version\n\nUse `bazel --version` to check your Bazel version, make sure you are using v6.5.0.\nMost binaries are available on [Github](https://github.com/bazelbuild/bazel/releases),\nbut it can also be installed with `asdf`:\n\n```shell\nasdf plugin-add bazel\nasdf install bazel 6.5.0\nasdf global bazel 6.5.0\n```\n\n#### GCC\n\nYou may have issues with newer and older versions of GCC. XLA builds are known to work\nwith GCC versions between 7.5 and 9.3. If your system uses a newer GCC version, you can\ninstall an older version and tell Bazel to use it with `export CC=/path/to/gcc-{version}`\nwhere version is the GCC version you installed.\n\n#### Python and asdf\n\n`Bazel` cannot find `python` installed via the `asdf` version manager by default. `asdf` uses a\nfunction to lookup the specified version of a given binary, this approach prevents `Bazel` from\nbeing able to correctly build XLA. The error is `unknown command: python. Perhaps you have to reshim?`.\nThere are two known workarounds:\n\n1. Explicitly change your `$PATH` to point to a Python installation (note the build process\n   looks for `python`, not `python3`). For example:\n\n    ```shell\n    # Point directly to a specific Python version\n    export PATH=$HOME/.asdf/installs/python/3.10.8/bin:$PATH\n    ```\n\n2. Use the [`asdf direnv`](https://github.com/asdf-community/asdf-direnv) plugin to install [`direnv 2.20.0`](https://direnv.net).\n   `direnv` along with the `asdf-direnv` plugin will explicitly set the paths for any binary specified\n   in your project's `.tool-versions` files.\n\nIf you still get the error, you can also try setting `PYTHON_BIN_PATH`, like `export PYTHON_BIN_PATH=/usr/bin/python3.9`.\n\nAfter doing any of the steps above, it may be necessary to clear the build cache by removing ` ~/.cache/xla_build`\n(or the corresponding OS-specific cache location).\n\n### GPU support\n\nTo build binaries with GPU support, you need all the GPU-specific dependencies (CUDA, ROCm),\nthen you can build with either `XLA_TARGET=cuda` or `XLA_TARGET=rocm`. See the `XLA_TARGET`\nfor more details.\n\n### TPU support\n\nAll you need is setting `XLA_TARGET=tpu`.\n\n### Compilation-specific environment variables\n\nYou can use the following env vars to customize your build:\n\n  * `BUILD_CACHE` - controls where to store XLA source and builds\n\n  * `BUILD_FLAGS` - additional flags passed to Bazel\n\n  * `BUILD_MODE` - controls to compile `opt` (default) artifacts or `dbg`, example: `BUILD_MODE=dbg`\n\n## Runtime flags\n\nYou can further configure XLA runtime options with `XLA_FLAGS`,\nsee: [xla/debug_options_flags.cc](https://github.com/openxla/xla/blob/main/xla/debug_options_flags.cc)\nfor the list of available flags.\n\n\u003c!-- Docs --\u003e\n\n## Release process\n\nTo publish a new version of this package:\n\n1. Update version in `mix.exs`.\n2. Create and push a new tag.\n3. Wait for the release workflow to build all the binaries.\n4. Publish the release from draft.\n5. Publish the package to Hex.\n\n## License\n\nNote that the build artifacts are a result of compiling XLA, hence are under\nthe respective license. See [XLA](https://github.com/openxla/xla).\n\n```text\nCopyright (c) 2020 Sean Moriarity\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felixir-nx%2Fxla","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felixir-nx%2Fxla","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felixir-nx%2Fxla/lists"}