-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8266a71
commit f2d7df3
Showing
9 changed files
with
250 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# Installation Tutorial | ||
This document describes how to install the software used in the artifact on a node with NVIDIA GPU. All scripts are assumed to be run from `nnfusion/artifacts` directory. | ||
|
||
## Prerequirements | ||
We assume that you have a node with NVIDIA GPU and CUDA installed. We also assume that you have installed conda and nvcc. If you have not installed conda, you can install it by following the instructions [here](https://docs.conda.io/projects/conda/en/latest/user-guide/install/linux.html) (Miniconda is enough, and this artifact assumes that miniconda is installed at the default path `~/miniconda3`). If you have not installed nvcc, you can install it by following the instructions [here](https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html). | ||
|
||
## TensorFlow | ||
The onnx-tf for TF 1.15 needs to be built from source because the pre-compiled version depends on TF2. We also fix some bugs in that commit to properly support the control flow operations. The following commands will prepare the conda env for TF 1.15. | ||
|
||
```bash | ||
conda create python=3.8 --name baseline_tf1 -y | ||
conda activate baseline_tf1 | ||
pip install nvidia-pyindex | ||
pip install -r env/requirements_tf.txt | ||
mkdir -p third-party && cd third-party | ||
git clone https://github.com/onnx/onnx-tensorflow.git | ||
cd onnx-tensorflow | ||
git checkout 0e4f4836 # v1.7.0-tf-1.15m | ||
git apply ../../env/onnx_tf.patch | ||
pip install -e . | ||
conda deactivate | ||
``` | ||
## JAX | ||
The following commands will prepare the conda env for JAX. | ||
```bash | ||
conda create python=3.8 --name baseline_jax -y | ||
conda activate baseline_jax | ||
pip install nvidia-pyindex | ||
pip install -r env/requirements_jax.txt -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html -f https://download.pytorch.org/whl/torch_stable.html | ||
conda deactivate | ||
``` | ||
|
||
## TVM | ||
The following commands will prepare the conda env for TVM. | ||
```bash | ||
conda create python==3.8 --name kerneldb -y | ||
conda activate kerneldb | ||
pip install ply==3.11 | ||
mkdir -p third-party && cd third-party | ||
git clone https://github.com/apache/tvm.git | ||
cd tvm | ||
git checkout 22ba6523c | ||
git submodule init && git submodule update | ||
git apply ../../env/tvm.patch | ||
mkdir build | ||
cd build | ||
cp ../../../env/tvm.config.cmake config.cmake | ||
make -j | ||
cd ../python | ||
pip install -e . | ||
``` | ||
|
||
## NNFusion | ||
The following commands will build nnfusion. Please use the [script](../maint/script/install_dependency.sh) (needs sudo) to prepare the environment for nnfusion before running the following commands. | ||
|
||
```bash | ||
cd .. # to $YOUR_DIR_FOR_NNFUSION/nnfusion | ||
mkdir build && cd build && cmake .. && make -j | ||
``` | ||
|
||
## Pytorch & Grinder | ||
```bash | ||
conda create python=3.7 --name grinder -y | ||
conda activate grinder | ||
pip install nvidia-pyindex | ||
pip install -r env/requirements_pytorch.txt -f https://download.pytorch.org/whl/torch_stable.html | ||
pip install -e . | ||
conda deactivate | ||
``` | ||
|
||
TODO get data | ||
|
||
TODO prepare kerneldb | ||
|
||
docker: --shm-size="32g" | ||
docker build -t grinder:latest -f env/Dockerfile.rocm --network=host . | ||
|
||
|
||
|
||
|
||
|
||
assume running at artifacts directory | ||
|
||
|
||
## Pre-requisites | ||
conda, nvcc ...... | ||
|
||
|
||
|
||
|
||
srun --pty -w nico3 -p Long --exclusive ./run_nv_gpu.sh | ||
|
||
cd plot && ./plot_nv.sh && cd - |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
cd nnfusion | ||
mkdir build && cd build && cmake .. && make -j && cd - | ||
|
||
cd artifacts | ||
conda activate grinder | ||
pip install -e . | ||
conda deactivate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/bin/bash -e | ||
|
||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT License. | ||
|
||
echo "Running NNFusion install_dependency.sh" | ||
DEB_PACKAGES="build-essential cmake git curl zlib1g zlib1g-dev libtinfo-dev unzip \ | ||
autoconf automake libtool ca-certificates gdb sqlite3 libsqlite3-dev libcurl4-openssl-dev \ | ||
libprotobuf-dev protobuf-compiler libgflags-dev libgtest-dev" | ||
|
||
ubuntu_codename=$(. /etc/os-release;echo $UBUNTU_CODENAME) | ||
|
||
if [[ $ubuntu_codename != "focal" ]]; then | ||
DEB_PACKAGES="${DEB_PACKAGES} clang-3.9 clang-format-3.9" | ||
fi | ||
|
||
if [[ "$(whoami)" != "root" ]]; then | ||
SUDO=sudo | ||
fi | ||
|
||
if ! dpkg -L $DEB_PACKAGES >/dev/null 2>&1; then | ||
#Thirdparty deb for ubuntu 18.04(bionic) | ||
$SUDO sh -c "apt update && apt install -y --no-install-recommends software-properties-common apt-transport-https ca-certificates gnupg wget" | ||
$SUDO sh -c "wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null" | ||
$SUDO sh -c "apt-add-repository 'deb https://apt.kitware.com/ubuntu/ $ubuntu_codename main'" | ||
$SUDO sh -c "apt update && apt install -y --no-install-recommends $DEB_PACKAGES" | ||
|
||
if [[ $ubuntu_codename != "focal" ]]; then | ||
# Install protobuf 3.6.1 from source | ||
$SUDO sh -c "wget https://github.com/protocolbuffers/protobuf/releases/download/v3.6.1/protobuf-cpp-3.6.1.tar.gz -P /tmp" | ||
$SUDO sh -c "cd /tmp && tar -xf /tmp/protobuf-cpp-3.6.1.tar.gz && rm /tmp/protobuf-cpp-3.6.1.tar.gz" | ||
$SUDO sh -c "cd /tmp/protobuf-3.6.1/ && ./configure && make && make check && make install && ldconfig && rm -rf /tmp/protobuf-3.6.1/" | ||
fi | ||
fi | ||
|
||
# if [[ $ubuntu_codename == "focal" ]]; then | ||
# # Install clang-format-3.9 | ||
# $SUDO sh -c "cd /tmp && wget https://releases.llvm.org/3.9.0/clang+llvm-3.9.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz && tar -xf clang+llvm-3.9.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz" | ||
# $SUDO sh -c "cp /tmp/clang+llvm-3.9.0-x86_64-linux-gnu-ubuntu-16.04/bin/clang-format /usr/bin/clang-format-3.9 && ln -s /usr/bin/clang-format-3.9 /usr/bin/clang-format" | ||
# $SUDO sh -c "rm -rf /tmp/clang+llvm-3.9.0-x86_64-linux-gnu-ubuntu-16.04/bin/clang-format /tmp/clang+llvm-3.9.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz" | ||
# fi | ||
|
||
echo "- Dependencies are installed in system." | ||
|
||
if [ ! -f "/usr/lib/libgtest.a" ]; then | ||
|
||
# if Ubuntu 16.04, we have some dev node using ubuntu 16.04 | ||
if [[ $ubuntu_codename == "xenial" ]]; then | ||
$SUDO sh -c "mkdir /usr/src/googletest && ln -s /usr/src/gtest /usr/src/googletest/googletest" | ||
fi | ||
|
||
# Compile gtest | ||
$SUDO sh -c "cd /usr/src/googletest/googletest/ && mkdir -p build && cd build && cmake .. -DCMAKE_CXX_FLAGS=\"-std=c++11\" && make -j" | ||
|
||
if [[ $ubuntu_codename == "focal" ]]; then | ||
$SUDO sh -c "cp /usr/src/googletest/googletest/build/lib/libgtest*.a /usr/lib/" | ||
else | ||
$SUDO sh -c "cp /usr/src/googletest/googletest/build/libgtest*.a /usr/lib/" | ||
fi | ||
|
||
$SUDO sh -c "rm -rf /usr/src/googletest/googletest/build" | ||
$SUDO sh -c "mkdir /usr/local/lib/googletest" | ||
$SUDO sh -c "ln -s /usr/lib/libgtest.a /usr/local/lib/googletest/libgtest.a" | ||
$SUDO sh -c "ln -s /usr/lib/libgtest_main.a /usr/local/lib/googletest/libgtest_main.a" | ||
fi | ||
echo "- libgtest is installed in system." | ||
|
||
# Install numpy | ||
$SUDO sh -c "apt install -y python3 python3-pip" | ||
if [[ $ubuntu_codename == "xenial" ]]; then | ||
$SUDO sh -c "pip3 install numpy==1.18.5" | ||
else | ||
$SUDO sh -c "pip3 install numpy" | ||
fi | ||
|
||
echo "- Done." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Kernel DB for GrinderBase and Grinder | ||
|
||
The `reproduce_kernel_db.sh` scripts will leverage AutoTVM, Ansor, Roller, and manual implementation to generate kernels. The result kernels will be injected in to a kernel database, located in *~/.cache/nnfusion/kernel_cache.db*, which will be finally loaded by NNFusion. | ||
|
||
This folder contains the following contents: | ||
* `*_kernels` folders: the tuning result of each source | ||
* `db`: scripts for injecting kernels into the kernel database, adapted from [https://github.com/microsoft/nnfusion/tree/osdi20_artifact/artifacts/kernel_db/kernel_db_scripts](https://github.com/microsoft/nnfusion/tree/osdi20_artifact/artifacts/kernel_db/kernel_db_scripts) | ||
* `roller`: the source code of Roller, adapted from [https://github.com/microsoft/nnfusion/tree/osdi22_artifact/artifacts/roller](https://github.com/microsoft/nnfusion/tree/osdi22_artifact/artifacts/roller) | ||
* `test_config`: the TVM implementation of each operator, adapted from [https://github.com/microsoft/nnfusion/tree/osdi22_artifact/artifacts/roller/test_config](https://github.com/microsoft/nnfusion/tree/osdi22_artifact/artifacts/roller/test_config) |