# Compiler installation

To deploy a custom deep learning model on Mobilint's NPU, the model must be compiled into **MXQ (Mobilint ExeCUtable)** format. Mobilint’s official compiler, `qb Compiler` (also called `qubee`, `qb`), performs this conversion and ensures your model is optimized for execution on Mobilint hardware. It must be installed within the Docker environment provided by Mobilint.

You only need to install `qb Compiler` if:
- You want to use your own trained model
- An MXQ file is not available for the model

```{tip}
If you’re using **precompiled models** provided by Mobilint (e.g. in the [Model Zoo](model_zoo.md) or demo packages), you do not need to install the compiler.
```

## Requirements

- Download the appropriate compiler package from Mobilint’s official [Download Center](https://dl.mobilint.com).
- System
    - Ubuntu 20.04.6 LTS or above
    - (Required only for GPU option) NVIDIA Graphics Driver 535.183.01 or above
- Required package
    - Docker
    - (Required only for GPU option) nvidia-docker
    
    ```{seealso}
    For more details on installing Docker, please refer to the [official Docker documentations](https://docs.docker.com/desktop/).
    ```

## Installation Process

1. Download the Docker image and create a container. 
There are two environment options: **Compiling with CPU only** and **compiling with GPU acceleration**.

    Replace `{WORKING DIRECTORY}` appropriately with your working directory:

    ### CPU-only option

    ```bash
    docker pull mobilint/qbcompiler:v{QUBEE_VERSION_NUMBER}-cpu
    cd {WORKING DIRECTORY}
    docker run -it --ipc=host --name {YOUR_CONTAINER_NAME} -v $(pwd):/workspace mobilint/qbcompiler:v{QUBEE_VERSION_NUMBER}-cpu /bin/bash
    ``` 

    ### With GPU option

    ```bash
    docker pull mobilint/qbcompiler:v{QUBEE_VERSION_NUMBER}
    cd {WORKING DIRECTORY}
    docker run -it --gpus all --ipc=host --name {YOUR_CONTAINER_NAME} -v $(pwd):/workspace mobilint/qbcompiler:v{QUBEE_VERSION_NUMBER} /bin/bash
    ```

2. Run the following command to install `qb Compiler` into your docker container.

    ```bash
    docker cp {path/to/qubee.whl} {YOUR_CONTAINER_NAME}:/
    docker start {YOUR_CONTAINER_NAME}
    docker exec -it {YOUR_CONTAINER_NAME} /bin/bash
    cd /
    python -m pip install qubee-{QUBEE_VERSION_NUMBER}+aries2-py3-none-any.whl
    ```