Installation#

This guide covers how to install NKIPy and its dependencies on an AWS Trainium instance.

Prerequisites#

NKIPy requires a Trainium instance with the Neuron Driver and Runtime installed.

Install Neuron Driver and Runtime#

If you are using a Neuron Multi-Framework DLAMI, the driver and runtime are already installed. You can skip to the next section.

Otherwise, follow the Neuron Setup Guide up to the “Install Drivers and Tools” section for your OS. Note that NKIPy does not require PyTorch, but it supports Torch tensors if available.


Alternative: Installation with pip#

If you prefer using pip instead of uv, follow these instructions.

Create a Virtual Environment#

python3.10 -m venv nkipy_venv
source nkipy_venv/bin/activate

Configure Neuron Repository#

NKIPy depends on the Neuron Compiler (neuronx-cc). Configure pip to use the Neuron repository:

pip config set global.extra-index-url https://pip.repos.neuron.amazonaws.com

Install Packages#

# Install both packages in editable mode
pip install -e nkipy -e spike

# Or install without editable mode
pip install nkipy spike

Building Wheels with pip#

# Install build tool
pip install build

# Build wheel packages
python -m build nkipy --wheel --outdir dist
python -m build spike --wheel --outdir dist

# Install the built wheels
pip install dist/*.whl

Verifying Installation#

After installation, verify that everything works:

# With uv
uv run python -c "import nkipy; import spike; print('Installation successful!')"

# With pip (after activating venv)
python -c "import nkipy; import spike; print('Installation successful!')"

Troubleshooting#

neuronx-cc not found#

If you see an error about neuronx-cc not being found:

With uv: The Neuron repository is already configured in pyproject.toml. Try running uv sync --refresh.

With pip: Make sure you’ve configured the extra index URL:

pip config set global.extra-index-url https://pip.repos.neuron.amazonaws.com

spike build fails#

The spike package contains C++ code that requires compilation. Ensure you have:

  • CMake installed (apt install cmake)

  • A C++ compiler (gcc/clang)

  • Python development headers (apt install python3-dev)

  • Neuron Runtime (libnrt) installed