Building ONNX Runtime
类别: Linux 标签: Linux Ubuntu GPU CUDA Docker ONNX ONNXRuntime目录
NVIDIA CUDA
单步构建
- 下载onnxruntime源代码
git clone --recursive https://github.com/microsoft/onnxruntime.git
- 拉取容器(编译环境)
docker pull nvidia/cuda:11.1-cudnn8-devel-ubuntu20.04
- 运行容器
docker run -it --name build-onnxruntime-gpu --runtime nvidia \ -v $(pwd)/onnxruntime:/onnxruntime -w /onnxruntime \ nvidia/cuda:11.1-cudnn8-devel-ubuntu20.04
- 更新apt镜像源
sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list apt-get update
- 安装依赖包
apt-get install language-pack-en git cmake python3 python3-pip -y
- 修改语言环境
locale-gen en_US.UTF-8 update-locale LANG=en_US.UTF-8
- 更新pip镜像源
pip3 config set global.index-url https://mirrors.aliyun.com/pypi/simple/
- 安装numpy
pip3 install numpy
- 编译
./build.sh --parallel --build_shared_lib --enable_pybind --build_wheel \ --use_cuda --cudnn_home /usr/include/x86_64-linux-gnu/ \ --cuda_home /usr/local/cuda/ --config Release
- 安装
pip3 install /onnxruntime/build/Linux/Release/dist/onnxruntime_gpu-1.6.0-cp38-cp38-linux_x86_64.whl
- 测试
python -c "import onnxruntime"
自动化构建
参考资料
- Building ONNX Runtime
- Docker Containers for ONNX Runtime
- NVIDIA cuDNN Documentation
- onnxruntime/tools/ci_build/build.py
- onnxruntime/tools/ci_build/github/linux/docker/scripts/install_ubuntu.sh
- 编译onnxruntime-gpu 1.6.0 Ubuntu 20.04
- How to install tzdata on a ubuntu docker image?
- Unable to locate package language-pack-en
- 修改locale
- Locale
- Debian: debian_frontend=noninteractive
- ENV DEBIAN_FRONTEND noninteractive
- CUDA / Docker & GPG error
- Use multi-stage builds
- Dockerfile 中的 multi-stage(多阶段构建)