This guide walks you through using a Development Container configured with all the tools needed to build and run Triton (or Triton-CPU). The setup is optimized for local development using Visual Studio Code. Full VSCode Dev Container setup details can be found official Visual Studio Code documentation.
- VSCode
- VSCode Dev Containers Extension
- A container engine: Podman (preferred) or Docker (still a work in progress, may not work)
- GPU support (only needed for GPU use):
jq(used by setup scripts)
GPU users must install the NVIDIA Container Toolkit/ROCm for GPU support.
Podman users: The VSCode Dev Container extension needs the additional settings shown below when using podman.
docker-composeorpodman-composecan be used with podman.
Below is the basic workflow for developing Triton using VSCode in a Dev Container:
- Clone Triton Repository: Clone one of the Triton repository and
cdinto the top-level of the cloned repository. - Bootstrap
triton-dev-containers: Run the bootstrap command or clone and build the Dev Container. - Launch VSCode Dev Container: Launch Dev Container from the VSCode command palette.
- Development: Work as usual, with access to tools and dependencies defined in the container.
VS Code Device Containers allow development using VS Code, but within a container. This provide consistent and reproducible development environments for developing with Triton. The pre-configured development containers are designed to work with one of:
triton: https://github.com/triton-lang/tritontriton-amd: https://github.com/triton-lang/tritontriton-cpu: https://github.com/triton-lang/triton-cpu
Clone the repository that is being developed and cd into the top-level of the
cloned repository.
This repository is intended to be be cloned under the repository being developed. It is recommended to only checkout what is needed for a given development environment (Sparse Checkout), but it is possible to do a full checkout of this repository.
The Dev Container Configuration file, .devcontainer/triton/devcontainer.json,
is setup with configuration details, like the Docker image to use, extensions to
install, environment variables, etc.
The Dev Container configuration provided supports both root (not recommended)
and non-root (recommended) users.
This option clones only what is needed for a given variant.
Once the script completes, there should be a .devcontainer/ directory in the
top-level of the repository being developed.
wget -qO- https://raw.githubusercontent.com/redhat-et/triton-dev-containers/main/.devcontainer/scripts/bootstrap-devcontainer.sh | bash -s triton-cpuReplace
triton-cpu(above) with one of the supported variants:
tritontriton-cputriton-amd
This option clones the entire triton-dev-containers repository.
git clone https://github.com/redhat-et/triton-dev-containers.git
cd triton-dev-containers
make devcontainersFollow these steps to launch and work with the Dev Container in Visual Studio Code.
Open the project in Visual Studio Code. A pop up will appear asking to reopen the project in a Dev Container.
If the pop up doesn't appear, the container can be launched by accessing the
Visual Studio Code Command Palette and looking for the:
Dev Containers: Reopen in Container option as shown below.
Visual Studio Code will relaunch inside the Dev Container.
When the container is ready the Triton tutorials can be installed as follows (This step can take a few minutes to complete):
pip install -e './python[tutorials]'Once the Triton tutorials are installed, they can be run to verify everything is
installed correctly.
If developing with triton-cpu, some of the tutorials may not succeed as is.
Run tutorials with -cpu in the name, like 02-fused-softmax-cpu.py
and 03-matrix-multiplication-cpu.py.
python python/tutorials/01-vector-add.py

