# Installation
## System requirements
We recommend using an NVIDIA GPU for faster compiles with qbcompiler, but it is not necessary. Currently, the CPU-only version of qbcompiler is also supported.

### Reference System
- [Ubuntu 22.04.4 LTS](https://ubuntu.com/)
- [NVIDIA Graphics Driver 545.29.06](https://www.nvidia.com/en-us/drivers/)

### Requirements and Recommended Packages
- [Ubuntu 20.04.6 LTS or Above](https://ubuntu.com/)
- [NVIDIA Graphics Driver 535.183.01 or Above](https://www.nvidia.com/en-us/drivers/)
- [Docker](https://www.docker.com/)
- [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/index.html#)
 
## SDK Installation
We recommend installing the qbcompiler using Mobilint’s official Docker container images. Starting with qbcompiler v0.10.0.0, the first two digits of the compiler version must match the first two digits of the Docker image tag. For example, if you use qbcompiler v1.1.0, choose an image whose tag starts with 1.1. In addition, from qbcompiler Docker 0.11 and later, the images are based on CUDA 12.8.1, which requires an NVIDIA driver from the R570 branch or newer. For best compatibility, we recommend updating your NVIDIA driver to the latest available version.

- Docker image: `mobilint/qbcompiler:1.1-cuda12.8.1-ubuntu22.04`
- Link: [https://hub.docker.com/r/mobilint/qbcompiler](https://hub.docker.com/r/mobilint/qbcompiler)

### Building Docker Container
Run the following commands to build the docker container.
```bash
# Download Docker Image
docker pull mobilint/qbcompiler:1.1-cuda12.8.1-ubuntu22.04
# mkdir {WORKING DIRECTORY} (if needed)
cd {WORKING DIRECTORY}
# Build the Docker container
docker run -it --gpus all --ipc=host --name {YOUR_CONTAINER_NAME} -v $(pwd):/workspace mobilint/qbcompiler:1.1-cuda12.8.1-ubuntu22.04 /bin/bash
```
(Recommended) If the trained models and datasets are stored in different directories, you can mount them to the docker container as follows:
```bash
docker run -it --gpus all --ipc=host --name {YOUR_CONTAINER_NAME} -v $(pwd):/workspace -v {PATH TO MODEL DIR}:/models -v {PATH TO DATASET DIR}:/datasets mobilint/qbcompiler:1.1-cuda12.8.1-ubuntu22.04 /bin/bash
```
To run the NPU inside the Docker container, add `--device /dev/aries0:/dev/aries0` when creating the Docker container.

(Optional) By building the Docker container with the CPU-only version image, users may run the Mobilint Compiler on computers without GPUs.
```bash
# Download Docker Image
docker pull mobilint/qbcompiler:1.1-cpu-ubuntu22.04
cd {WORKING DIRECTORY}
# Build the Docker container
docker run -it --ipc=host --name {YOUR_CONTAINER_NAME} -v $(pwd):/workspace mobilint/qbcompiler:1.1-cpu-ubuntu22.04 /bin/bash
```
### Installation of qbcompiler
qbcompiler packages are available in [Mobilint® Software Development Kit (SDK)](https://dl.mobilint.com/view.php). After entering the page, download the qbcompiler package for this release. The package is in the form of a Python wheel file, which can be installed using pip.

Run the following commands to install qbcompiler on the docker container.
```bash
# Download qbcompiler-{VERSION}-{BUILD_TAG}.whl file
# Copy qbcompiler whl file to Docker
docker cp /path/to/qbcompiler-{VERSION}-{BUILD_TAG}.whl {YOUR_CONTAINER_NAME}:/
# Start Docker
docker start {YOUR_CONTAINER_NAME}
# Attach to Docker container
docker exec -it {YOUR_CONTAINER_NAME} /bin/bash
# Install qbcompiler
cd /
python -m pip install qbcompiler-{VERSION}-{BUILD_TAG}.whl
```
In qbcompiler releases before 1.2, wheel filenames may include an NPU name in the local version segment, such as `+aries`. Install the exact wheel file provided for the release.
