From e32eff826ccb533dee444e837727a1ad2ec5f546 Mon Sep 17 00:00:00 2001 From: Ashwini Khade Date: Tue, 3 Dec 2019 10:16:45 -0800 Subject: [PATCH] enable nuget package testing on centos7 (#2527) * add centos tests to linux cpu ci pipeline * Disable failing test * use centos6 instead of centos7 * change back to centos7 * add dotnet runtime dependency * fix dotnet runtime dependencies * install dotnet sdk instead of runtimes * add more dotnet dependencies * temporary skip failing test * ix lib path * reenable failing test --- .../runtest-docker.sh | 19 +++++++++++++++---- .../InferenceTest.cs | 14 +++++++++++++- .../nuget/templates/test_linux.yml | 10 +++++++++- .../linux/docker/scripts/install_centos.sh | 6 ++++++ 4 files changed, 43 insertions(+), 6 deletions(-) diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest-docker.sh b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest-docker.sh index ee5404839a..72ec50b5ea 100755 --- a/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest-docker.sh +++ b/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest-docker.sh @@ -10,7 +10,8 @@ SOURCE_ROOT=$1 BUILD_DIR=$2 NUGET_REPO_DIRNAME=$3 # path relative to BUILD_DIR CurrentOnnxRuntimeVersion=$4 -Arch=${5:-x64} # x32, x64 +UseCentos7=${5:-false} +Arch=${6:-x64} # x32, x64 PackageName=${PACKAGENAME:-Microsoft.ML.OnnxRuntime} RunTestCsharp=${RunTestCsharp:-true} RunTestNative=${RunTestNative:-true} @@ -20,10 +21,20 @@ IMAGE="ubuntu16.04_$Arch" OldDir=$(pwd) cd $SOURCE_ROOT/tools/ci_build/github/linux/docker -if [ $Arch = "x86" ]; then - docker build -t "onnxruntime-$IMAGE" --build-arg OS_VERSION=16.04 --build-arg PYTHON_VERSION=${PYTHON_VER} -f Dockerfile.ubuntu_x86 . + +if [ $UseCentos7 = "false" ]; then + echo "Image used for testing is onnxruntime-$IMAGE" + if [ $Arch = "x86" ]; then + docker build -t "onnxruntime-$IMAGE" --build-arg OS_VERSION=16.04 --build-arg PYTHON_VERSION=${PYTHON_VER} -f Dockerfile.ubuntu_x86 . + else + docker build -t "onnxruntime-$IMAGE" --build-arg OS_VERSION=16.04 --build-arg PYTHON_VERSION=${PYTHON_VER} -f Dockerfile.ubuntu . + fi else - docker build -t "onnxruntime-$IMAGE" --build-arg OS_VERSION=16.04 --build-arg PYTHON_VERSION=${PYTHON_VER} -f Dockerfile.ubuntu . + IMAGE="centos7" + PYTHON_VER=3.6 + echo "Image used for testing is onnxruntime-$IMAGE" + + docker build -t "onnxruntime-$IMAGE" --build-arg BUILD_USER=onnxruntimedev --build-arg BUILD_UID=$(id -u) --build-arg PYTHON_VERSION=${PYTHON_VER} -f Dockerfile.centos . fi docker rm -f "onnxruntime-cpu" || true diff --git a/csharp/test/Microsoft.ML.OnnxRuntime.Tests/InferenceTest.cs b/csharp/test/Microsoft.ML.OnnxRuntime.Tests/InferenceTest.cs index b65fc130e2..462ed9660b 100644 --- a/csharp/test/Microsoft.ML.OnnxRuntime.Tests/InferenceTest.cs +++ b/csharp/test/Microsoft.ML.OnnxRuntime.Tests/InferenceTest.cs @@ -594,7 +594,19 @@ namespace Microsoft.ML.OnnxRuntime.Tests libName = "libcustom_op_library.dylib"; } - option.RegisterCustomOpLibrary(libName); + string libFullPath = Path.Combine(Directory.GetCurrentDirectory(), libName); + Assert.True(File.Exists(libFullPath), $"Expected lib {libFullPath} does not exist."); + + try + { + option.RegisterCustomOpLibrary(libFullPath); + } + catch(Exception ex) + { + var msg = $"Failed to load custom op library {libFullPath}, error = {ex.Message}"; + throw new Exception(msg + "\n" + ex.StackTrace); + } + using (var session = new InferenceSession(modelPath, option)) { diff --git a/tools/ci_build/github/azure-pipelines/nuget/templates/test_linux.yml b/tools/ci_build/github/azure-pipelines/nuget/templates/test_linux.yml index 5ca82e06a4..78606546ce 100644 --- a/tools/ci_build/github/azure-pipelines/nuget/templates/test_linux.yml +++ b/tools/ci_build/github/azure-pipelines/nuget/templates/test_linux.yml @@ -34,11 +34,19 @@ jobs: parameters: packageFolder: '$(Build.BinariesDirectory)/nuget-artifact' + - ${{ if eq(parameters['TestGPU'], 'false') }}: + - script: | + set -e -x + $(Build.SourcesDirectory)/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest-docker.sh $(Build.SourcesDirectory) $(Build.BinariesDirectory) nuget-artifact $(NuGetPackageVersionNumber) true + displayName: 'Run Package Test (x64) on CentOS7' + env: + OnnxRuntimeBuildDirectory: $(Build.BinariesDirectory) + - ${{ if eq(parameters['TestGPU'], 'false') }}: - script: | set -e -x $(Build.SourcesDirectory)/csharp/test/Microsoft.ML.OnnxRuntime.EndToEndTests/runtest-docker.sh $(Build.SourcesDirectory) $(Build.BinariesDirectory) nuget-artifact $(NuGetPackageVersionNumber) - displayName: 'Run Package Test (x64)' + displayName: 'Run Package Test (x64) on Ubuntu' env: OnnxRuntimeBuildDirectory: $(Build.BinariesDirectory) diff --git a/tools/ci_build/github/linux/docker/scripts/install_centos.sh b/tools/ci_build/github/linux/docker/scripts/install_centos.sh index 4eaceefc91..948c55f173 100755 --- a/tools/ci_build/github/linux/docker/scripts/install_centos.sh +++ b/tools/ci_build/github/linux/docker/scripts/install_centos.sh @@ -21,6 +21,12 @@ elif [ "$os_major_version" == "6" ] && [ ! -d "/opt/python/cp35-cp35m" ]; then /usr/bin/python3.6 -m pip install --upgrade pip else yum install -y redhat-lsb-core expat-devel libcurl-devel tar unzip curl zlib-devel make libunwind icu aria2 rsync bzip2 git bzip2-devel + # install dotnet core dependencies + yum install -y lttng-ust openssl-libs krb5-libs libicu libuuid + # install dotnet runtimes + yum install -y https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm + yum install -y dotnet-sdk-2.2 + fi