Skip to content

Commit

Permalink
Add docker image for the artifact
Browse files Browse the repository at this point in the history
  • Loading branch information
yaoyaoding committed Nov 14, 2022
1 parent 7ac396a commit 4b6b35e
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 24 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.hidet_cache
build
cmake-build-debug
**/outs
40 changes: 40 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM nvidia/cuda:11.6.0-devel-ubuntu20.04 as base

COPY . /root/hidet

ENV TZ=America/Toronto
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apt-get update && apt-get install -y \
build-essential \
wget \
git \
vim \
python3 \
llvm-10 \
ccache \
software-properties-common \
python3-pip \
&& rm -rf /var/lib/apt/lists/*

RUN python3 -m pip install --upgrade pip && \
python3 -m pip install --no-cache-dir -r /root/hidet/requirements.txt && \
python3 -m pip install --no-cache-dir --upgrade cmake && \
python3 -m pip uninstall -y onnxruntime-gpu==1.11.1 && \
python3 -m pip install --no-cache-dir onnxruntime-gpu==1.11.1 && \
hash -r # refresh the hash

RUN ln -s /usr/bin/python3 /usr/bin/python

RUN cd /root/hidet && \
mkdir build && \
cd build && \
cmake .. && \
make -j 8 && \
rm -rf /root/hidet/build/3rdparty

RUN echo export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/root/hidet/build/lib >> ~/.bashrc && \
echo export PYTHONPATH=$PYTHONPATH:/root/hidet/python:/root/hidet/3rdparty/tvm/python >> ~/.bashrc && \
echo alias python=python3 >> ~/.bashrc

WORKDIR /root/hidet/artifacts
80 changes: 69 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ This repository contains the artifacts for the paper

"Hidet: Task Mapping Programming Paradigm for Deep Learning Tensor Programs".

## Installation

### Requirements
## Hardware requirements

We did experiment on the following hardware platform

Expand All @@ -16,13 +14,76 @@ We did experiment on the following hardware platform

Other workstation equipped with a modern NVIDIA GPU should also be able to run the experiments.

On the software side, we require the following software to be installed
The experiments require a Linux system with NVIDIA GPU driver installed.

## Run experiments via docker

We provide a docker image to run the experiments, with pre-configured environment.

### Install docker and nvidia-docker

Please follow the instructions on the [official website](https://github.com/NVIDIA/nvidia-docker) to install docker and
nvidia-docker.

### Prepare the image

We provide two ways to get the docker image to use. Please choose the one you like.

#### Option 1: use the prebuilt image

```bash
docker pull yyding/hidet-artifact:latest
```

#### Option 2: build docker image from Dockerfile

```bash
git clone --recursive git@github.com:yaoyaoding/hidet-artifacts hidet
cd hidet
docker build -t yyding/hidet-artifact:latest .
```

### Run experiments inside docker container

After above step, you can see a docker image named `yyding/hidet-artifact:latest` in your local docker image list via:

```bash
docker image ls
```

You should be able to see something like this:

```text
REPOSITORY TAG IMAGE ID CREATED SIZE
yyding/hidet-artifact latest 1074c09962c0 33 minutes ago 13.7GB
```

To run experiments, you need to start a docker container from the image:

```bash
# the following command will start a container based on the image
# you will enter the container after the command at working directory /root/hidet/artifacts
docker run -it --gpus all --rm yyding/hidet-artifact:latest
# when you are in the container, run
bash run.sh
# to run all experiments
```

You can also run experiments in the container one by one. See [here](#run-the-experiments) for details.

## Build and run experiments from source

You can also build and run experiments from source on your host environment.

### Installation

We require the following software to be installed

- cmake 3.19+
- llvm (required by TVM, we used llvm-10)
- ccache (used to accelerate duplicated compilation)

### NVIDIA CUDA Toolkit
#### NVIDIA CUDA Toolkit

Please follow https://developer.nvidia.com/cuda-downloads guide to install the CUDA toolkit.

Expand All @@ -35,15 +96,12 @@ nvidia-smi
nvcc --version
```

### Install Hidet and baselines
#### Install Hidet and baselines

```bash
# clone hidet repository
git clone git@github.com:yaoyaoding/hidet
git clone --recursive git@github.com:yaoyaoding/hidet-artifacts hidet
cd hidet
git checkout artifact
git submodule init
git submodule update --recursive --init

# install the dependencies of hidet and the baselines (e.g., TensorRT, PyTorch, Onnx Runtime)
# the versions of baselines are specified in requirements.txt file.
Expand All @@ -70,7 +128,7 @@ python3 -c "import hidet"
python3 -c "import artifact"
```

# Run the experiments
### Run the experiments

This artifact contains all the experiments in the evaluation section of the paper:

Expand Down
18 changes: 9 additions & 9 deletions artifacts/2_input_sensitivity/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ def main():
]:
for model in [
'--model op_matmul_nn_4', # 2048x2048x2048
'--model op_matmul_nn_5', # 2047x2047x2047
'--model op_matmul_nn_6', # 2046x2046x2046
'--model op_matmul_nn_7', # 2045x2045x2045
'--model op_matmul_nn_8', # 2044x2044x2044
'--model op_matmul_nn_9', # 2043x2043x2043
'--model op_matmul_nn_10', # 2042x2042x2042
'--model op_matmul_nn_11', # 2041x2041x2041
'--model op_matmul_nn_5', # 2039x2039x2039
'--model op_matmul_nn_6', # 2047x2047x2047
'--model op_matmul_nn_7', # 2046x2046x2046
'--model op_matmul_nn_8', # 2045x2045x2045
'--model op_matmul_nn_9', # 2044x2044x2044
'--model op_matmul_nn_10', # 2043x2043x2043
'--model op_matmul_nn_11', # 2042x2042x2042
]:
if '11' in model and ('ansor' in executor or 'autotvm' in executor):
# both schedulers failed to find a schedule for this input 2041x2041x2041, skip
if '_5' in model and ('ansor' in executor or 'autotvm' in executor):
# both schedulers failed to find a schedule for this input 2039x2039x2039, skip
# for autotvm, it will fall back to a default schedule.
# for ansor, it will fall into a dead loop.
continue
Expand Down
10 changes: 10 additions & 0 deletions artifacts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@
export TVM_BIND_THREADS=0
export TVM_NUM_THREADS=24

# The first run would generate a lot of logs and take a long time
python ./0_end2end/main.py
python ./1_latency_distribution/main.py
python ./2_input_sensitivity/main.py
python ./3_batch_size/main.py
python ./4_prologue_epilogue_fusion/main.py
python ./5_tensorrt/main.py

# The second run would use the cached results and take a short time
# The output would be clear (not scattered with logs)
python ./0_end2end/main.py
python ./1_latency_distribution/main.py
python ./2_input_sensitivity/main.py
Expand Down
2 changes: 2 additions & 0 deletions build_docker_image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
docker build -t hidet-artifact:latest .
10 changes: 6 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ nvtx

# for onnx frontend
onnx==1.10.2
protobuf==3.20

################################################################################
# Optional packages
Expand All @@ -31,13 +32,14 @@ onnx==1.10.2
torch==1.11
torchvision==0.12

# for language model converting
transformers==4.19.2
transformers[onnx]

# for onnx runtime baseline
onnxruntime==1.11.1
onnxruntime-gpu==1.11.1

# for language model converting
transformers==4.19.2
transformers[onnx]==4.19.2

# for tensor rt baseline
--extra-index-url https://pypi.ngc.nvidia.com
nvidia-tensorrt==8.2.5.1
Expand Down
2 changes: 2 additions & 0 deletions run_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
docker run --rm --gpus all -it hidet-artifact:latest

0 comments on commit 4b6b35e

Please sign in to comment.