2. Environment Setup
This chapter describes the development environment configuration. The code is compiled and run in docker.
2.1. Code Download
Github link: https://github.com/sophgo/tpu-mlir
After cloning this code, it needs to be compiled in docker. For specific steps, please refer to the following.
2.2. Docker Configuration
TPU-MLIR is developed in the Docker environment, and it can be compiled and run after Docker is configured.
Download the required image from DockerHub https://hub.docker.com/r/sophgo/tpuc_dev :
$ docker pull sophgo/tpuc_dev:v2.2
If you are using docker for the first time, you can execute the following commands to install and configure it (only for the first time):
1$ sudo apt install docker.io
2$ sudo systemctl start docker
3$ sudo systemctl enable docker
4$ sudo groupadd docker
5$ sudo usermod -aG docker $USER
6$ newgrp docker
Make sure the installation package is in the current directory, and then create a container in the current directory as follows:
$ docker run --privileged --name myname -v $PWD:/workspace -it sophgo/tpuc_dev:v2.2
# "myname" is just an example, you can use any name you want
Note that the path of the TPU-MLIR project in docker should be /workspace/tpu-mlir
2.3. ModelZoo (Optional)
TPU-MLIR comes with the yolov5s model. If you want to run other models, you need to download them from ModelZoo. The path is as follows:
https://github.com/sophgo/model-zoo
After downloading, put it in the same directory as tpu-mlir. The path in docker should be /workspace/model-zoo
2.4. Compilation
In the docker container, the code is compiled as follows:
$ cd tpu-mlir
$ source ./envsetup.sh
$ ./build.sh
Regression validation:
# This project contains the yolov5s.onnx model, which can be used directly for validation
$ pushd regression
$ ./run_model.sh yolov5s
$ popd
You can validate more networks with model-zoo, but the whole regression takes a long time:
# The running time is very long, so it is not necessary
$ pushd regression
$ ./run_all.sh
$ popd