From 7c21c1573269f8bf1619e7cd7dc8847c0cebf396 Mon Sep 17 00:00:00 2001 From: jignparm Date: Tue, 29 Jan 2019 09:20:07 -0800 Subject: [PATCH] Jignparm/addcsharptestgpu (#393) * add file for cshar test using CUDA docker image * add gpu csharp end to end test scripts * uncomment data download * minor change to kick off ci build * small change to kick off build * Add windows GPU test runner script --- ...ft.ML.OnnxRuntime.EndToEndTests.Gpu.csproj | 45 ++++++++++++++++++ .../runtest-docker-gpu.sh | 46 +++++++++++++++++++ .../runtest-docker.sh | 2 + .../runtest-gpu.bat | 29 ++++++++++++ .../runtest-gpu.sh | 44 ++++++++++++++++++ 5 files changed, 166 insertions(+) create mode 100644 csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/Microsoft.ML.OnnxRuntime.EndToEndTests.Gpu.csproj create mode 100755 csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest-docker-gpu.sh create mode 100644 csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest-gpu.bat create mode 100644 csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest-gpu.sh diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/Microsoft.ML.OnnxRuntime.EndToEndTests.Gpu.csproj b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/Microsoft.ML.OnnxRuntime.EndToEndTests.Gpu.csproj new file mode 100644 index 0000000000..12d3535138 --- /dev/null +++ b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/Microsoft.ML.OnnxRuntime.EndToEndTests.Gpu.csproj @@ -0,0 +1,45 @@ + + + + netcoreapp2.0 + false + $(MSBuildThisFileDirectory)..\.. + AnyCPU + bin\$(Configuration)\ + $(OnnxRuntimeCsharpRoot)\..\build\Windows + $(OnnxRuntimeBuildDirectory)\$(Configuration)\external\protobuf\cmake\$(Configuration) + $(OnnxRuntimeCsharpRoot)\..\cmake\external\onnx\onnx + $(OnnxRuntimeBuildDirectory)\$(Configuration)\$(Configuration) + + + + + + + + + + + + + + + + + Always + false + + + + Always + false + + + + + + + + + + diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest-docker-gpu.sh b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest-docker-gpu.sh new file mode 100755 index 0000000000..36d19fe1ca --- /dev/null +++ b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest-docker-gpu.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +# build docker image for CPU + +#TODO: Get this working, not tested yet +set -x + + + +SOURCE_ROOT=$1 +BUILD_DIR=$2 +NUGET_REPO_DIRNAME=$3 # path relative to BUILD_DIR +IMAGE="ubuntu16.04-cuda10.0-cudnn7.3" +PYTHON_VER=3.5 +OldDir=$(pwd) +cd $SOURCE_ROOT/tools/ci_build/github/linux/docker +docker build -t "onnxruntime-$IMAGE" --build-arg OS_VERSION=16.04 --build-arg PYTHON_VERSION=${PYTHON_VER} -f Dockerfile.ubuntu_gpu . + + +docker rm -f "onnxruntime-gpu-container" || true + +set +e + +docker run -h $HOSTNAME \ + --rm \ + --name "onnxruntime-gpu-container" \ + --volume "$SOURCE_ROOT:/onnxruntime_src" \ + --volume "$BUILD_DIR:/home/onnxruntimedev" \ + --volume "$HOME/.cache/onnxruntime:/home/onnxruntimedev/.cache/onnxruntime" \ + -e "OnnxRuntimeBuildDirectory=/home/onnxruntimedev" \ + -e "IsReleaseBuild=$IsReleaseBuild" \ + "onnxruntime-$IMAGE" \ + /bin/bash /onnxruntime_src/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest-gpu.sh \ + /home/onnxruntimedev/$NUGET_REPO_DIRNAME /onnxruntime_src /home/onnxruntimedev $TestDataUrl $TestDataChecksum & + +wait -n + +EXIT_CODE=$? + +set -e +exit $EXIT_CODE + + +cd $OldDir diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest-docker.sh b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest-docker.sh index d7b4112876..04283c9f93 100755 --- a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest-docker.sh +++ b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest-docker.sh @@ -5,6 +5,7 @@ # build docker image for CPU #TODO: Get this working, not tested yet +set -x @@ -29,6 +30,7 @@ docker run -h $HOSTNAME \ --volume "$BUILD_DIR:/home/onnxruntimedev" \ --volume "$HOME/.cache/onnxruntime:/home/onnxruntimedev/.cache/onnxruntime" \ -e "OnnxRuntimeBuildDirectory=/home/onnxruntimedev" \ + -e "IsReleaseBuild=$IsReleaseBuild" \ "onnxruntime-$IMAGE" \ /bin/bash /onnxruntime_src/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest.sh \ /home/onnxruntimedev/$NUGET_REPO_DIRNAME /onnxruntime_src /home/onnxruntimedev $TestDataUrl $TestDataChecksum & diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest-gpu.bat b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest-gpu.bat new file mode 100644 index 0000000000..b9e210929f --- /dev/null +++ b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest-gpu.bat @@ -0,0 +1,29 @@ +REM Copyright (c) Microsoft Corporation. All rights reserved. +REM Licensed under the MIT License. + +@echo off +SETLOCAL EnableDelayedExpansion + +set LocalNuGetRepo=%1 +REM WorkingDirectory is Build.SourcesDirectory\csharp +set /p MajorVersionNumber=<..\VERSION_NUMBER +set VersionSuffix= +IF NOT DEFINED IsReleaseBuild ( + FOR /F "tokens=* USEBACKQ" %%F IN (`git rev-parse --short HEAD`) DO ( + set VersionSuffix=-dev-%%F + ) +) + +set CurrentOnnxRuntimeVersion=%MajorVersionNumber%%VersionSuffix% +@echo %CurrentOnnxRuntimeVersion% +dotnet restore test\Microsoft.ML.OnnxRuntime.EndToEndTests\Microsoft.ML.OnnxRuntime.EndToEndTests.Gpu.csproj -s %LocalNuGetRepo% --configfile .\Nuget.CSharp.config +if NOT errorlevel 0 ( + @echo "Failed to restore nuget packages for the test project" + Exit 1 +) + +dotnet test test\Microsoft.ML.OnnxRuntime.EndToEndTests\Microsoft.ML.OnnxRuntime.EndToEndTests.csproj --no-restore +if NOT errorlevel 0 ( + @echo "Failed to build or execute the end-to-end test" + Exit 1 +) diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest-gpu.sh b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest-gpu.sh new file mode 100644 index 0000000000..127630cc85 --- /dev/null +++ b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest-gpu.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +LocalNuGetRepo=$1 +SourceRoot=$2 +BuildDir=$3 +TestDataUrl=$4 +TestDataChecksum=$5 + +#TestDataUrl and TestDataChecksum comes from the build env variable +set -x + +echo "Downloading test data" +python3 $SourceRoot/tools/ci_build/build.py --update --download_test_data --build_dir $BuildDir --test_data_url $TestDataUrl --test_data_checksum $TestDataChecksum +if [ $? -ne 0 ]; then + echo "Failed to download test data" + exit 1 +fi + +OldDir=`pwd` +cd $SourceRoot + +MajorVersion=$(cat $SourceRoot/VERSION_NUMBER) +VersionSuffix= +if [ "$IsReleaseBuild" != "true" ]; then + VersionSuffix=-dev-$(git rev-parse --short=8 HEAD) +fi +export CurrentOnnxRuntimeVersion=$MajorVersion$VersionSuffix +echo "Current NuGet package version is $CurrentOnnxRuntimeVersion" + +dotnet restore $SourceRoot/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/Microsoft.ML.OnnxRuntime.EndToEndTests.Gpu.csproj -s $LocalNuGetRepo -s https://api.nuget.org/v3/index.json +if [ $? -ne 0 ]; then + echo "Failed to restore nuget packages for the test project" + exit 1 +fi + +dotnet test $SourceRoot/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/Microsoft.ML.OnnxRuntime.EndToEndTests.Gpu.csproj --no-restore +if [ $? -ne 0 ]; then + echo "Failed to build or execute the end-to-end test" + exit 1 +fi + +cd $OldDir