|
| 1 | +<!-- |
| 2 | + Copyright 2023-2025 Google LLC |
| 3 | +
|
| 4 | + Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + you may not use this file except in compliance with the License. |
| 6 | + You may obtain a copy of the License at |
| 7 | +
|
| 8 | + https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | + Unless required by applicable law or agreed to in writing, software |
| 11 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + See the License for the specific language governing permissions and |
| 14 | + limitations under the License. |
| 15 | + --> |
| 16 | + |
| 17 | +# Installing MaxText |
| 18 | + |
| 19 | +This document discusses how to install MaxText. We recommend installing MaxText inside a Python virtual environment. |
| 20 | + |
| 21 | +## From PyPI (Recommended) |
| 22 | +This is the easiest way to get started with the latest stable version. |
| 23 | + |
| 24 | +```bash |
| 25 | +# 1. Create virtual environment |
| 26 | +uv venv --python 3.12 --seed maxtext_venv |
| 27 | +source maxtext_venv/bin/activate |
| 28 | + |
| 29 | +# 2. Install uv, a fast Python package installer |
| 30 | +pip install uv |
| 31 | + |
| 32 | +# 3. Install MaxText and its dependencies |
| 33 | +uv pip install maxtext --resolution=lowest |
| 34 | +install_maxtext_github_deps |
| 35 | +``` |
| 36 | +> **Note:** The `install_maxtext_github_deps` command is temporarily required to install dependencies directly from GitHub that are not yet available on PyPI. |
| 37 | +
|
| 38 | +> **Note:** The maxtext package contains a comprehensive list of all direct and transitive dependencies, with lower bounds, generated by [seed-env](https://github.com/google-ml-infra/actions/tree/main/python_seed_env). We highly recommend the `--resolution=lowest` flag. It instructs `uv` to install the specific, tested versions of dependencies defined by MaxText, rather than the latest available ones. This ensures a consistent and reproducible environment, which is critical for stable performance and for running benchmarks. |
| 39 | +
|
| 40 | +## From Source |
| 41 | +If you plan to contribute to MaxText or need the latest unreleased features, install from source. |
| 42 | + |
| 43 | +```bash |
| 44 | +# 1. Clone the repository |
| 45 | +git clone https://github.com/AI-Hypercomputer/maxtext.git |
| 46 | +cd maxtext |
| 47 | + |
| 48 | +# 2. Create virtual environment |
| 49 | +uv venv --python 3.12 --seed maxtext_venv |
| 50 | +source maxtext_venv/bin/activate |
| 51 | + |
| 52 | +# 3. Install dependencies in editable mode |
| 53 | +pip install uv |
| 54 | +# install the tpu package |
| 55 | +uv pip install -e .[tpu] --resolution=lowest |
| 56 | +# or install the gpu package by running the following line |
| 57 | +# uv pip install -e .[cuda12] --resolution=lowest |
| 58 | +install_maxtext_github_deps |
| 59 | +``` |
| 60 | + |
| 61 | +After installation, you can verify the package is available with `python3 -c "import MaxText"` and run training jobs with `python3 -m MaxText.train ...`. |
0 commit comments