From 8fb3563e1749021502022ab4fde0ddc6f8606e66 Mon Sep 17 00:00:00 2001 From: vexilligera Date: Wed, 11 Mar 2020 03:02:30 +0000 Subject: [PATCH 1/4] vs 2019 and cuda 10.2 --- ci/build_windows.py | 83 +++++++++++++++++++++++++++++---------------- 1 file changed, 53 insertions(+), 30 deletions(-) diff --git a/ci/build_windows.py b/ci/build_windows.py index 2590d211c671..5b04b2c43262 100755 --- a/ci/build_windows.py +++ b/ci/build_windows.py @@ -37,9 +37,16 @@ from util import * + +# Fix for broken PATH with newline inserted presumably by VS studio installation of SQL server or +# other component which makes visual studio stop working. +os.environ['PATH']=os.environ.get('PATH').replace('\n','') + KNOWN_VCVARS = { + # https://gitlab.kitware.com/cmake/cmake/issues/18920 'VS 2015': r'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\vcvarsx86_amd64.bat', - 'VS 2017': r'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsx86_amd64.bat' + 'VS 2017': r'C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsx86_amd64.bat', + 'VS 2019': r'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat', } @@ -54,10 +61,14 @@ class BuildFlavour(Enum): CMAKE_FLAGS = { 'WIN_CPU': ( + '-DCMAKE_C_COMPILER=cl ' + '-DCMAKE_CXX_COMPILER=cl ' '-DUSE_CUDA=OFF ' '-DUSE_CUDNN=OFF ' '-DENABLE_CUDA_RTC=OFF ' '-DUSE_OPENCV=ON ' + '-DOpenCV_RUNTIME=vc15 ' + '-DOpenCV_ARCH=x64 ' '-DUSE_OPENMP=ON ' '-DUSE_BLAS=open ' '-DUSE_LAPACK=ON ' @@ -67,10 +78,14 @@ class BuildFlavour(Enum): '-DCMAKE_BUILD_TYPE=Release') , 'WIN_CPU_MKLDNN': ( + '-DCMAKE_C_COMPILER=cl ' + '-DCMAKE_CXX_COMPILER=cl ' '-DUSE_CUDA=OFF ' '-DUSE_CUDNN=OFF ' '-DENABLE_CUDA_RTC=OFF ' '-DUSE_OPENCV=ON ' + '-DOpenCV_RUNTIME=vc15 ' + '-DOpenCV_ARCH=x64 ' '-DUSE_OPENMP=ON ' '-DUSE_BLAS=open ' '-DUSE_LAPACK=ON ' @@ -80,10 +95,14 @@ class BuildFlavour(Enum): '-DCMAKE_BUILD_TYPE=Release') , 'WIN_CPU_MKLDNN_MKL': ( + '-DCMAKE_C_COMPILER=cl ' + '-DCMAKE_CXX_COMPILER=cl ' '-DUSE_CUDA=OFF ' '-DUSE_CUDNN=OFF ' '-DENABLE_CUDA_RTC=OFF ' '-DUSE_OPENCV=ON ' + '-DOpenCV_RUNTIME=vc15 ' + '-DOpenCV_ARCH=x64 ' '-DUSE_OPENMP=ON ' '-DUSE_BLAS=mkl ' '-DUSE_LAPACK=ON ' @@ -93,10 +112,14 @@ class BuildFlavour(Enum): '-DCMAKE_BUILD_TYPE=Release') , 'WIN_CPU_MKL': ( + '-DCMAKE_C_COMPILER=cl ' + '-DCMAKE_CXX_COMPILER=cl ' '-DUSE_CUDA=OFF ' '-DUSE_CUDNN=OFF ' '-DENABLE_CUDA_RTC=OFF ' '-DUSE_OPENCV=ON ' + '-DOpenCV_RUNTIME=vc15 ' + '-DOpenCV_ARCH=x64 ' '-DUSE_OPENMP=ON ' '-DUSE_BLAS=mkl ' '-DUSE_LAPACK=ON ' @@ -106,10 +129,14 @@ class BuildFlavour(Enum): '-DCMAKE_BUILD_TYPE=Release') , 'WIN_GPU': ( + '-DCMAKE_C_COMPILER=cl ' + '-DCMAKE_CXX_COMPILER=cl ' '-DUSE_CUDA=ON ' '-DUSE_CUDNN=ON ' '-DENABLE_CUDA_RTC=ON ' '-DUSE_OPENCV=ON ' + '-DOpenCV_RUNTIME=vc15 ' + '-DOpenCV_ARCH=x64 ' '-DUSE_OPENMP=ON ' '-DUSE_BLAS=open ' '-DUSE_LAPACK=ON ' @@ -120,10 +147,14 @@ class BuildFlavour(Enum): '-DCMAKE_BUILD_TYPE=Release') , 'WIN_GPU_MKLDNN': ( + '-DCMAKE_C_COMPILER=cl ' + '-DCMAKE_CXX_COMPILER=cl ' '-DUSE_CUDA=ON ' '-DUSE_CUDNN=ON ' '-DENABLE_CUDA_RTC=ON ' '-DUSE_OPENCV=ON ' + '-DOpenCV_RUNTIME=vc15 ' + '-DOpenCV_ARCH=x64 ' '-DUSE_OPENMP=ON ' '-DUSE_BLAS=open ' '-DUSE_LAPACK=ON ' @@ -145,33 +176,25 @@ def windows_build(args): mxnet_root = get_mxnet_root() logging.info("Found MXNet root: {}".format(mxnet_root)) - url = 'https://github.com/Kitware/CMake/releases/download/v3.16.1/cmake-3.16.1-win64-x64.zip' - with tempfile.TemporaryDirectory() as tmpdir: - cmake_file_path = download_file(url, tmpdir) - with zipfile.ZipFile(cmake_file_path, 'r') as zip_ref: - # Create $tmpdir\cmake-3.16.1-win64-x64\bin\cmake.exe - zip_ref.extractall(tmpdir) - - with remember_cwd(): - os.chdir(path) - cmd = "\"{}\" && {} -G \"NMake Makefiles JOM\" {} {}".format( - args.vcvars, - os.path.join(tmpdir, 'cmake-3.16.1-win64-x64', 'bin', 'cmake.exe'), - CMAKE_FLAGS[args.flavour], mxnet_root) - logging.info("Generating project with CMake:\n{}".format(cmd)) - check_call(cmd, shell=True) - - cmd = "\"{}\" && jom".format(args.vcvars) - logging.info("Building with jom:\n{}".format(cmd)) - - t0 = int(time.time()) - check_call(cmd, shell=True) - - logging.info( - "Build flavour: {} complete in directory: \"{}\"".format( - args.flavour, os.path.abspath(path))) - logging.info("Build took {}".format( - datetime.timedelta(seconds=int(time.time() - t0)))) + with remember_cwd(): + os.chdir(path) + cmd = "\"{}\" && cmake -GNinja {} {}".format( + args.vcvars, + CMAKE_FLAGS[args.flavour], mxnet_root) + logging.info("Generating project with CMake:\n{}".format(cmd)) + check_call(cmd, shell=True) + + cmd = "\"{}\" && ninja".format(args.vcvars) + logging.info("Building:\n{}".format(cmd)) + + t0 = int(time.time()) + check_call(cmd, shell=True) + + logging.info( + "Build flavour: {} complete in directory: \"{}\"".format( + args.flavour, os.path.abspath(path))) + logging.info("Build took {}".format( + datetime.timedelta(seconds=int(time.time() - t0)))) windows_package(args) @@ -233,7 +256,7 @@ def main(): parser.add_argument("--vcvars", help="vcvars batch file location, typically inside vs studio install dir", - default=KNOWN_VCVARS['VS 2015'], + default=KNOWN_VCVARS['VS 2019'], type=str) parser.add_argument("--arch", @@ -258,7 +281,7 @@ def main(): if 'OpenCV_DIR' not in os.environ: os.environ["OpenCV_DIR"] = "C:\\Program Files\\OpenCV-v3.4.1\\build" if 'CUDA_PATH' not in os.environ: - os.environ["CUDA_PATH"] = "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v9.2" + os.environ["CUDA_PATH"] = "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v10.2" if 'MKL_ROOT' not in os.environ: os.environ["MKL_ROOT"] = "C:\\Program Files (x86)\\IntelSWTools\\compilers_and_libraries\\windows\\mkl" windows_build(args) From 3fd7f4a0feec1829b8fad94497bbc591606bf9a9 Mon Sep 17 00:00:00 2001 From: vexilligera Date: Sat, 28 Mar 2020 15:59:13 +0000 Subject: [PATCH 2/4] update dmlc-core --- 3rdparty/dmlc-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/3rdparty/dmlc-core b/3rdparty/dmlc-core index c8f7f9c81dfc..14bf7e884328 160000 --- a/3rdparty/dmlc-core +++ b/3rdparty/dmlc-core @@ -1 +1 @@ -Subproject commit c8f7f9c81dfcf2489d3bbc6d3b2a9200a20fbcde +Subproject commit 14bf7e884328eb97bfde160ec6f64c20f5337459 From 4d647b7b5ebbbebc955eec7284eff747885bf6f7 Mon Sep 17 00:00:00 2001 From: Leonard Lausen Date: Fri, 3 Apr 2020 16:13:34 +0000 Subject: [PATCH 3/4] Remove OpenCV_RUNTIME and OpenCV_ARCH based on fixed autodetection --- ci/build_windows.py | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/ci/build_windows.py b/ci/build_windows.py index 5b04b2c43262..d01e117faeec 100755 --- a/ci/build_windows.py +++ b/ci/build_windows.py @@ -37,11 +37,6 @@ from util import * - -# Fix for broken PATH with newline inserted presumably by VS studio installation of SQL server or -# other component which makes visual studio stop working. -os.environ['PATH']=os.environ.get('PATH').replace('\n','') - KNOWN_VCVARS = { # https://gitlab.kitware.com/cmake/cmake/issues/18920 'VS 2015': r'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64\vcvarsx86_amd64.bat', @@ -67,8 +62,6 @@ class BuildFlavour(Enum): '-DUSE_CUDNN=OFF ' '-DENABLE_CUDA_RTC=OFF ' '-DUSE_OPENCV=ON ' - '-DOpenCV_RUNTIME=vc15 ' - '-DOpenCV_ARCH=x64 ' '-DUSE_OPENMP=ON ' '-DUSE_BLAS=open ' '-DUSE_LAPACK=ON ' @@ -84,8 +77,6 @@ class BuildFlavour(Enum): '-DUSE_CUDNN=OFF ' '-DENABLE_CUDA_RTC=OFF ' '-DUSE_OPENCV=ON ' - '-DOpenCV_RUNTIME=vc15 ' - '-DOpenCV_ARCH=x64 ' '-DUSE_OPENMP=ON ' '-DUSE_BLAS=open ' '-DUSE_LAPACK=ON ' @@ -101,8 +92,6 @@ class BuildFlavour(Enum): '-DUSE_CUDNN=OFF ' '-DENABLE_CUDA_RTC=OFF ' '-DUSE_OPENCV=ON ' - '-DOpenCV_RUNTIME=vc15 ' - '-DOpenCV_ARCH=x64 ' '-DUSE_OPENMP=ON ' '-DUSE_BLAS=mkl ' '-DUSE_LAPACK=ON ' @@ -118,8 +107,6 @@ class BuildFlavour(Enum): '-DUSE_CUDNN=OFF ' '-DENABLE_CUDA_RTC=OFF ' '-DUSE_OPENCV=ON ' - '-DOpenCV_RUNTIME=vc15 ' - '-DOpenCV_ARCH=x64 ' '-DUSE_OPENMP=ON ' '-DUSE_BLAS=mkl ' '-DUSE_LAPACK=ON ' @@ -135,8 +122,6 @@ class BuildFlavour(Enum): '-DUSE_CUDNN=ON ' '-DENABLE_CUDA_RTC=ON ' '-DUSE_OPENCV=ON ' - '-DOpenCV_RUNTIME=vc15 ' - '-DOpenCV_ARCH=x64 ' '-DUSE_OPENMP=ON ' '-DUSE_BLAS=open ' '-DUSE_LAPACK=ON ' @@ -153,8 +138,6 @@ class BuildFlavour(Enum): '-DUSE_CUDNN=ON ' '-DENABLE_CUDA_RTC=ON ' '-DUSE_OPENCV=ON ' - '-DOpenCV_RUNTIME=vc15 ' - '-DOpenCV_ARCH=x64 ' '-DUSE_OPENMP=ON ' '-DUSE_BLAS=open ' '-DUSE_LAPACK=ON ' From 7536ce4490bc485e67ecdbb188e53f845d54bbb2 Mon Sep 17 00:00:00 2001 From: Leonard Lausen Date: Fri, 3 Apr 2020 17:20:02 +0000 Subject: [PATCH 4/4] Add build retrials due to cuda thrust + VS2019 flakyness --- ci/build_windows.py | 58 ++++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 24 deletions(-) diff --git a/ci/build_windows.py b/ci/build_windows.py index d01e117faeec..b9c17a855954 100755 --- a/ci/build_windows.py +++ b/ci/build_windows.py @@ -33,7 +33,7 @@ import zipfile from distutils.dir_util import copy_tree from enum import Enum -from subprocess import check_call +from subprocess import check_call, call from util import * @@ -154,30 +154,40 @@ def windows_build(args): logging.info("Using vcvars environment:\n{}".format(args.vcvars)) path = args.output - os.makedirs(path, exist_ok=True) - - mxnet_root = get_mxnet_root() - logging.info("Found MXNet root: {}".format(mxnet_root)) - with remember_cwd(): - os.chdir(path) - cmd = "\"{}\" && cmake -GNinja {} {}".format( - args.vcvars, - CMAKE_FLAGS[args.flavour], mxnet_root) - logging.info("Generating project with CMake:\n{}".format(cmd)) - check_call(cmd, shell=True) - - cmd = "\"{}\" && ninja".format(args.vcvars) - logging.info("Building:\n{}".format(cmd)) - - t0 = int(time.time()) - check_call(cmd, shell=True) - - logging.info( - "Build flavour: {} complete in directory: \"{}\"".format( - args.flavour, os.path.abspath(path))) - logging.info("Build took {}".format( - datetime.timedelta(seconds=int(time.time() - t0)))) + # cuda thrust + VS 2019 is flaky: try multiple times if fail + MAXIMUM_TRY = 5 + build_try = 0 + + while build_try < MAXIMUM_TRY: + if os.path.exists(path): + shutil.rmtree(path) + os.makedirs(path, exist_ok=True) + + mxnet_root = get_mxnet_root() + logging.info("Found MXNet root: {}".format(mxnet_root)) + + with remember_cwd(): + os.chdir(path) + cmd = "\"{}\" && cmake -GNinja {} {}".format(args.vcvars, + CMAKE_FLAGS[args.flavour], + mxnet_root) + logging.info("Generating project with CMake:\n{}".format(cmd)) + check_call(cmd, shell=True) + + cmd = "\"{}\" && ninja".format(args.vcvars) + logging.info("Building:\n{}".format(cmd)) + + t0 = int(time.time()) + ret = call(cmd, shell=True) + + if ret != 0: + build_try += 1 + logging.info("{} build(s) have failed".format(build_try)) + else: + logging.info("Build flavour: {} complete in directory: \"{}\"".format(args.flavour, os.path.abspath(path))) + logging.info("Build took {}".format(datetime.timedelta(seconds=int(time.time() - t0)))) + break windows_package(args)