The TT-Buda software stack can compile models from several different frameworks and execute them in many different ways on Tenstorrent hardware.
This user guide is intended to help you setup your system with the appropriate device drivers, firmware, system dependencies, and compiler / runtime software.
Note on terminology:
While TT-Buda is the official Tenstorrent AI/ML compiler stack, PyBuda is the Python interface for TT-Buda. TT-Buda is the core technology; however, PyBuda allows users to access and utilize TT-Buda's features directly from Python. This includes directly importing model architectures and weights from PyTorch, TensorFlow, ONNX, and TFLite.
Currently, Tenstorrent software is supported on Ubuntu 20.04 LTS (Focal Fossa) and Ubuntu 22.04 LTS (Jammy Jellyfish) operating systems.
To access the PyBuda software and associated files, please navigate to the Releases section of this repository.
Once you have identified the release version you would like to install, you can download the individual files by clicking on their name.
PyBuda can be installed using two methods: Docker or Python virtualenv.
If you would like to run PyBuda in a Docker container, then follow the instructions for PCI Driver Installation and Device Firmware Update and followed by Docker Container Installation.
If you would like to run PyBuda in a Python virtualenv, then follow the instructions for the Setup HugePages, PCI Driver Installation, Device Firmware Update, and Backend Compiler Dependencies, followed by the Python Environment Installation.
# Clone System Tools Repo
git clone https://github.com/tenstorrent/tt-system-tools.git
cd tt-system-tools
chmod +x hugepages-setup.sh
sudo ./hugepages-setup.sh
# Install `.deb`
wget https://github.com/tenstorrent/tt-system-tools/releases/download/upstream%2F1.1/tenstorrent-tools_1.1-5_all.deb
sudo dpkg -i tenstorrent-tools_1.1-5_all.deb
# Start Services
sudo systemctl enable --now tenstorrent-hugepages.service
sudo systemctl enable --now 'dev-hugepages\x2d1G.mount'
# System Reboot
sudo reboot
Please navigate to tt-kmd homepage and follow instructions within the README. Pro-Tip: ensure that you are within the home directory of the local clone version of tt-kmd when performing the installation steps
The tt-firmware file needs to be installed using the tt-flash utility, for more details visit TT-Flash homepage and follow instructions within the README.
Instructions to install the Tenstorrent backend compiler dependencies on a fresh install of Ubuntu Server 20.04 or Ubuntu Server 22.04.
You may need to append each apt
command with sudo
if you do not have root permissions.
For both operating systems run the following commands:
apt update -y
apt upgrade -y --no-install-recommends
apt install -y build-essential curl libboost-all-dev libgl1-mesa-glx libgoogle-glog-dev libhdf5-serial-dev ruby software-properties-common libzmq3-dev clang wget python3-pip python-is-python3 python3-venv
For Ubuntu 20.04, add:
apt install -y libyaml-cpp-dev
For Ubuntu 22.04, add:
wget http://mirrors.kernel.org/ubuntu/pool/main/y/yaml-cpp/libyaml-cpp-dev_0.6.2-4ubuntu1_amd64.deb
wget http://mirrors.kernel.org/ubuntu/pool/main/y/yaml-cpp/libyaml-cpp0.6_0.6.2-4ubuntu1_amd64.deb
dpkg -i libyaml-cpp-dev_0.6.2-4ubuntu1_amd64.deb libyaml-cpp0.6_0.6.2-4ubuntu1_amd64.deb
rm libyaml-cpp-dev_0.6.2-4ubuntu1_amd64.deb libyaml-cpp0.6_0.6.2-4ubuntu1_amd64.deb
Please navigate to tt-smi homepage and follow instructions within the README.
If you are running on a TT-LoudBox or TT-QuietBox system, please navigate to tt-topology homepage and follow instructions within the README.
There are two ways to install PyBuda within the host environment: using Python virtual environment or Docker container.
It is strongly recommended to use virtual environments for each project utilizing PyBuda and Python dependencies. Creating a new virtual environment with PyBuda and libraries is very easy.
Step 1. Navigate to Releases
Step 2. Scroll to find the latest release package in .zip
format under "Assets" that corresponds to your device and operating system
python3 -m venv env
source env/bin/activate
pip install --upgrade pip==24.0
pip install torchvision-<version>.whl pybuda-<version>.whl tvm-<version>.whl
The pybuda-<version>.whl
file contains the PyBuda library, the tvm-<version>.whl
file contains the latest TVM downloaded release, and the torchvision-<version>.whl
file bundles the torchvision library.
For enhanced debugging capabilities, you may opt to install the Debuda library:
pip install debuda-<version>.whl
This wheel file installs the Debuda tool designed for debugging purposes.
Alternatively, PyBuda and its dependencies are provided as Docker images which can run in separate containers. The Docker containers can be found under: https://github.com/orgs/tenstorrent/packages?repo_name=tt-buda
To pull the Docker image, use the following command:
sudo docker pull ghcr.io/tenstorrent/tt-buda/<OS-VERSION>/<TT-DEVICE>:<TAG>
Supported OS <OS-VERSION>
Versions:
- ubuntu-20-04-amd64
- ubuntu-22-04-amd64
Supported Tenstorrent <TT-DEVICE>
Devices:
- gs
- wh_b0
For example, to run on an Ubuntu version 20.04 on a Grayskull device, use this command:
sudo docker pull ghcr.io/tenstorrent/tt-buda/ubuntu-20-04-amd64/gs:<TAG>
where <TAG>
is the release version number from: https://github.com/tenstorrent/tt-buda/tags
sudo docker run --rm -ti --cap-add=sys_nice --shm-size=4g --device /dev/tenstorrent -v /dev/hugepages-1G:/dev/hugepages-1G -v $(pwd)/:/home/ ghcr.io/tenstorrent/tt-buda/<OS-VERSION>/<TT-DEVICE>:<TAG> bash
cd home/
Verify the correct installation of the PyBuda library and environment by conducting a smoke test.
With your Python environment with PyBuda install activated, run the following Python script:
import pybuda
import torch
# Sample PyTorch module
class PyTorchTestModule(torch.nn.Module):
def __init__(self):
super().__init__()
self.weights1 = torch.nn.Parameter(torch.rand(32, 32), requires_grad=True)
self.weights2 = torch.nn.Parameter(torch.rand(32, 32), requires_grad=True)
def forward(self, act1, act2):
m1 = torch.matmul(act1, self.weights1)
m2 = torch.matmul(act2, self.weights2)
return m1 + m2, m1
def test_module_direct_pytorch():
input1 = torch.rand(4, 32, 32)
input2 = torch.rand(4, 32, 32)
# Run single inference pass on a PyTorch module, using a wrapper to convert to PyBuda first
output = pybuda.PyTorchModule("direct_pt", PyTorchTestModule()).run(input1, input2)
print(output)
print("PyBuda installation was a success!")
if __name__ == "__main__":
test_module_direct_pytorch()