Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pipeline for building python wheels for Windows/Linux CPU and GPU #15

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
182 changes: 182 additions & 0 deletions tools/ci_build/github/azure-pipelines/azure-pipelines-py-packaging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
jobs:
- job: Ubuntu1604_py_Wheels
pool: Linux-CPU
strategy:
matrix:
Python35:
python.version: '3.5'
Python36:
python.version: '3.6'
Python37:
python.version: '3.7'
steps:
- task: ShellScript@2
displayName: 'Run build script'
inputs:
scriptPath: 'tools/ci_build/github/linux/run_dockerbuild.sh'
args: '-c Release -o ubuntu16.04 -d cpu -r $(Build.BinariesDirectory) -p $(python.version) -x "--build_wheel --use_mkldnn"'

- task: CopyFiles@2
displayName: 'Copy Python Wheel to: $(Build.ArtifactStagingDirectory)'
inputs:
SourceFolder: '$(Build.BinariesDirectory)'
Contents: 'Release/dist/onnxruntime-*-manylinux1_x86_64.whl'
TargetFolder: '$(Build.ArtifactStagingDirectory)'

- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: ONNXRuntime python wheel'
inputs:
ArtifactName: onnxruntime

- script: 'sudo rm -rf $(Agent.BuildDirectory)'
displayName: 'Clean build folders/files'
condition: always()

- job: Ubuntu1604_py_GPU_Wheels
pool: Linux-GPU
strategy:
matrix:
Python35:
python.version: '3.5'
Python36:
python.version: '3.6'
steps:
- task: ShellScript@2
displayName: 'Run build script'
inputs:
scriptPath: 'tools/ci_build/github/linux/run_dockerbuild.sh'
args: '-c Release -o ubuntu16.04 -d gpu -r $(Build.BinariesDirectory) -p $(python.version) -x "--build_wheel --use_mkldnn"'

- task: CopyFiles@2
displayName: 'Copy Python Wheel to: $(Build.ArtifactStagingDirectory)'
inputs:
SourceFolder: '$(Build.BinariesDirectory)'
Contents: 'Release/dist/onnxruntime*-manylinux1_x86_64.whl'
TargetFolder: '$(Build.ArtifactStagingDirectory)'

- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: ONNXRuntime python wheel'
inputs:
ArtifactName: onnxruntime_gpu

- script: 'sudo rm -rf $(Agent.BuildDirectory)'
displayName: 'Clean build folders/files'
condition: always()

- job: Windows_py_Wheels
pool: Win-CPU
strategy:
matrix:
Python35:
python.version: '3.5'
Python36:
python.version: '3.6'
variables:
buildDirectory: '$(Build.SourcesDirectory)\build'
steps:
- task: CondaEnvironment@1
inputs:
createCustomEnvironment: true
environmentName: 'py$(python.version)'
packageSpecs: 'python=$(python.version)'
cleanEnvironment: true

- task: BatchScript@1
displayName: 'Run build script'
inputs:
filename: 'build.bat'
arguments: ' --build_dir $(buildDirectory) --config Release --build_wheel'
workingFolder: "$(Build.SourcesDirectory)"

- task: CopyFiles@2
displayName: 'Copy Python Wheel to: $(Build.ArtifactStagingDirectory)'
inputs:
SourceFolder: '$(buildDirectory)'
Contents: '**\dist\onnxruntime-*.whl'
TargetFolder: '$(Build.ArtifactStagingDirectory)'

- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: ONNXRuntime python wheel'
inputs:
ArtifactName: onnxruntime

- task: CmdLine@1
displayName: 'Clean build folders/files'
inputs:
filename: rd
arguments: '/s /q $(Agent.BuildDirectory)'
continueOnError: true
condition: always()

- task: CmdLine@1
displayName: 'Deactivating Conda Environment'
inputs:
filename: deactivate
continueOnError: true
condition: always()

- job: Windows_py_GPU_Wheels
pool: Win-GPU
variables:
buildDirectory: '$(Build.SourcesDirectory)\build'
CUDA_VERSION: '9.1'
strategy:
matrix:
Python35:
python.version: '3.5'
Python36:
python.version: '3.6'
steps:
- task: CondaEnvironment@1
inputs:
createCustomEnvironment: true
environmentName: 'py$(python.version)'
packageSpecs: 'python=$(python.version)'
cleanEnvironment: true

- task: PowerShell@1
displayName: 'Set CUDA path'
inputs:
scriptName: 'tools/ci_build/github/windows/set_cuda_path.ps1'
arguments: '-CudaMsbuildPath C:\local\cudaMsbuildIntegration-9.1.85-windows10-x64-0 -CudaVersion $(CUDA_VERSION)'

- task: BatchScript@1
displayName: 'Setup VS2017 env vars'
inputs:
filename: 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat'
arguments: 'amd64 -vcvars_ver=14.11'
modifyEnvironment: true

- task: BatchScript@1
displayName: 'Run build script'
inputs:
filename: 'build.bat'
arguments: ' --use_cuda --cuda_home="C:\local\cuda-9.1.85-windows10-x64-0" --cudnn_home="C:\local\cudnn-9.1-windows10-x64-v7.1\cuda" --build_dir $(buildDirectory) --config Release --build_wheel'
workingFolder: "$(Build.SourcesDirectory)"

- task: CopyFiles@2
displayName: 'Copy Python Wheel to: $(Build.ArtifactStagingDirectory)'
inputs:
SourceFolder: '$(buildDirectory)'
Contents: '**\dist\onnxruntime_gpu-*.whl'
TargetFolder: '$(Build.ArtifactStagingDirectory)'

- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: ONNXRuntime python wheel'
inputs:
ArtifactName: onnxruntime_gpu

- task: CmdLine@1
displayName: 'Clean build folders/files'
inputs:
filename: rd
arguments: '/s /q $(Agent.BuildDirectory)'
continueOnError: true
condition: always()

- task: CmdLine@1
displayName: 'Deactivating Conda Environment'
inputs:
filename: deactivate
continueOnError: true
condition: always()
6 changes: 3 additions & 3 deletions tools/ci_build/github/azure-pipelines/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ jobs:
pool: Win-GPU

variables:
CUDA_VERSION: '9.0'
CUDA_VERSION: '9.1'

steps:
- task: PowerShell@1
displayName: 'Set CUDA path'
inputs:
scriptName: 'tools/ci_build/github/windows/set_cuda_path.ps1'
arguments: '-CudaMsbuildPath C:\local\cudaMsbuildIntegration-9.0.176-windows10-x64-2 -CudaVersion $(CUDA_VERSION)'
arguments: '-CudaMsbuildPath C:\local\cudaMsbuildIntegration-9.1.85-windows10-x64-0 -CudaVersion $(CUDA_VERSION)'

- task: BatchScript@1
displayName: 'Setup VS2017 env vars'
Expand All @@ -87,7 +87,7 @@ jobs:
- task: BatchScript@1
inputs:
filename: build.bat
arguments: ' --enable_onnx_tests --use_cuda --cuda_home="C:\local\cuda-9.0.176-windows10-x64-0" --cudnn_home="C:\local\cudnn-9.0-windows10-x64-v7.0.5-0\cuda"'
arguments: ' --enable_onnx_tests --use_cuda --cuda_home="C:\local\cuda-9.1.85-windows10-x64-0" --cudnn_home="C:\local\cudnn-9.1-windows10-x64-v7.1\cuda"'
workingFolder: "$(Build.SourcesDirectory)"

- task: CmdLine@1
Expand Down
13 changes: 5 additions & 8 deletions tools/ci_build/github/linux/docker/Dockerfile.ubuntu_gpu
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# Tag: nvidia/cuda:9.0-cudnn7-devel-ubuntu16.04
# Created: 2017-11-21T06:34:14.675603521Z
# Label: com.nvidia.build.id: 41212533
# Label: com.nvidia.build.ref: e0edb5359ecb7bd3d86f0c9bfa18c2260b741ebb
# Label: com.nvidia.cuda.version: 9.0.176
# Label: com.nvidia.cudnn.version: 7.0.4.31
# Label: com.nvidia.nccl.version: 2.1.2
# Tag: nvidia/cuda:9.1-cudnn7-devel-ubuntu16.04
# Label: com.nvidia.cuda.version: 9.1.85
# Label: com.nvidia.cudnn.version: 7.1.2.21
# Label: com.nvidia.nccl.version: 2.2.12
# Ubuntu 16.04.5
FROM nvidia/cuda@sha256:33add9c50ab76b8f3a92187c0418ed600d5bea27690fda40711122fdc28ce2f4
FROM nvidia/cuda:9.1-cudnn7-devel-ubuntu16.04

ARG PYTHON_VERSION=3.5

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ if [ $PYTHON_VER != "3.5" ]; then
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python${PYTHON_VER} 1
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 2
update-alternatives --set python3 /usr/bin/python${PYTHON_VER}
/usr/bin/python${PYTHON_VER} -m pip install --upgrade --force-reinstall numpy
fi

rm -rf /var/lib/apt/lists/*
Expand Down
7 changes: 5 additions & 2 deletions tools/ci_build/github/linux/run_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@ while getopts c:d:x: parameter_Option
do case "${parameter_Option}"
in
d) BUILD_DEVICE=${OPTARG};;
x) BUILD_EXTR_PAR=${OPTARG};;
esac
done

if [ -z "$AZURE_BLOB_KEY" ]; then
echo "AZURE_BLOB_KEY is blank"
BUILD_EXTR_PAR="${BUILD_EXTR_PAR}"
echo "Extra parameters: ${BUILD_EXTR_PAR}"
else
echo "Downloading test data from azure"
mkdir -p /home/onnxruntimedev/models/
azcopy --recursive --source:https://onnxruntimetestdata.blob.core.windows.net/onnx-model-zoo-20181018 --destination:/home/onnxruntimedev/models/ --source-key:$AZURE_BLOB_KEY
BUILD_EXTR_PAR="--enable_onnx_tests"
BUILD_EXTR_PAR="${BUILD_EXTR_PAR} --enable_onnx_tests"
fi

if [ $BUILD_DEVICE = "gpu" ]; then
Expand All @@ -28,7 +31,7 @@ if [ $BUILD_DEVICE = "gpu" ]; then
--parallel --build_shared_lib \
--use_cuda \
--cuda_home /usr/local/cuda \
--cudnn_home /usr/local/cudnn-7.0/cuda --build_shared_lib $BUILD_EXTR_PAR
--cudnn_home /usr/local/cudnn-7.1/cuda --build_shared_lib $BUILD_EXTR_PAR
/home/onnxruntimedev/Release/onnx_test_runner -e cuda /data/onnx
else
python3 $SCRIPT_DIR/../../build.py --build_dir /home/onnxruntimedev \
Expand Down
2 changes: 1 addition & 1 deletion tools/ci_build/github/linux/run_dockerbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ echo "bo=$BUILD_OS bd=$BUILD_DEVICE bdir=$BUILD_DIR pv=$PYTHON_VER bex=$BUILD_EX

cd $SCRIPT_DIR/docker
if [ $BUILD_DEVICE = "gpu" ]; then
IMAGE="ubuntu16.04-cuda9.0-cudnn7.0"
IMAGE="ubuntu16.04-cuda9.1-cudnn7.1"
docker build -t "onnxruntime-$IMAGE" --build-arg PYTHON_VERSION=${PYTHON_VER} -f Dockerfile.ubuntu_gpu .
else
IMAGE="ubuntu16.04"
Expand Down