Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Try ningyuan win gpu build #17947

Closed
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ if(MSVC)
add_definitions(-DDMLC_STRICT_CXX11)
add_definitions(-DNOMINMAX)
set(CMAKE_C_FLAGS "/MP")
set(CMAKE_CXX_FLAGS "/Zc:__cplusplus")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} /bigobj")
else()
include(CheckCXXCompilerFlag)
Expand Down
94 changes: 61 additions & 33 deletions ci/build_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,20 @@
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 *


# 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\vcvars64.bat',
'VS 2019': r'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat'
}


Expand All @@ -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 '
Expand All @@ -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 '
Expand All @@ -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 '
Expand All @@ -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 '
Expand All @@ -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 '
Expand All @@ -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 '
Expand All @@ -140,38 +171,40 @@ def windows_build(args):
logging.info("Using vcvars environment:\n{}".format(args.vcvars))

path = args.output
os.makedirs(path, exist_ok=True)

# cuda thrust + VS is flaky so try multiple times if fail
MAXIMUM_TRY = 5
build_try = 0

mxnet_root = get_mxnet_root()
logging.info("Found MXNet root: {}".format(mxnet_root))
while build_try < MAXIMUM_TRY:
if os.path.exists(path):
shutil.rmtree(path)
os.makedirs(path, exist_ok=True)

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)
mxnet_root = get_mxnet_root()
logging.info("Found MXNet root: {}".format(mxnet_root))

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)
cmd = "\"{}\" && cmake -G Ninja {} {}".format(args.vcvars,
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))
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))))
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)


Expand All @@ -193,13 +226,15 @@ def windows_package(args):
for dll in dlls:
logging.info("packing dll: %s", dll)
shutil.copy(dll, pkgdir_lib)

os.chdir(get_mxnet_root())
logging.info('packing python bindings')
copy_tree('python', j(pkgdir, 'python'))
logging.info('packing headers')
copy_tree('include', j(pkgdir, 'include'))
logging.info("Compressing package: %s", pkgfile)
check_call(['7z', 'a', pkgfile, pkgdir])
check_call('refreshenv', shell=True)


def nix_build(args):
Expand All @@ -221,9 +256,6 @@ def main():
logging.getLogger().setLevel(logging.INFO)
logging.basicConfig(format='%(asctime)-15s %(message)s')
logging.info("MXNet Windows build helper")
instance_info = ec2_instance_info()
if instance_info:
logging.info("EC2: %s", instance_info)

parser = argparse.ArgumentParser()
parser.add_argument("-o", "--output",
Expand All @@ -233,7 +265,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",
Expand All @@ -253,12 +285,8 @@ def main():
system = platform.system()
if system == 'Windows':
logging.info("Detected Windows platform")
if 'OpenBLAS_HOME' not in os.environ:
os.environ["OpenBLAS_HOME"] = "C:\\Program Files\\OpenBLAS-v0.2.19"
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)
Expand Down
12 changes: 7 additions & 5 deletions ci/jenkins/Jenkins_steps.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def python3_gpu_ut_cython(docker_container_name) {
}

//------------------------------------------------------------------------------------------

/*
def compile_unix_cpu_openblas() {
return ['CPU: Openblas': {
node(NODE_LINUX_CPU) {
Expand Down Expand Up @@ -651,6 +651,7 @@ def compile_unix_amalgamation() {
}
}]
}
*/

def compile_windows_cpu() {
return ['Build CPU windows':{
Expand Down Expand Up @@ -708,6 +709,7 @@ def compile_windows_cpu_mkl() {
}]
}


def compile_windows_gpu() {
return ['Build GPU windows':{
node(NODE_WINDOWS_CPU) {
Expand Down Expand Up @@ -735,7 +737,7 @@ def compile_windows_gpu_mkldnn() {
}
}]
}

/*
def test_static_scala_cpu() {
return ['Static build CPU 14.04 Scala' : {
node(NODE_LINUX_CPU) {
Expand Down Expand Up @@ -1343,7 +1345,7 @@ def test_centos7_scala_cpu() {
}
}]
}

*/
def test_windows_python3_gpu() {
return ['Python 3: GPU Win':{
node(NODE_WINDOWS_GPU) {
Expand Down Expand Up @@ -1427,7 +1429,7 @@ def test_windows_julia10_cpu() {
}
}]
}

/*
def test_qemu_armv7_cpu() {
return ['ARMv7 QEMU': {
node(NODE_LINUX_CPU) {
Expand Down Expand Up @@ -1794,5 +1796,5 @@ def test_artifact_repository() {
}
}]
}

*/
return this
7 changes: 4 additions & 3 deletions ci/safe_docker_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@

from util import config_logging

DOCKER_STOP_TIMEOUT_SECONDS = 3
DOCKER_STOP_TIMEOUT_SECONDS = 10
CONTAINER_WAIT_SECONDS = 600
DOCKER_CLIENT_TIMEOUT = 600


class SafeDockerClient:
Expand All @@ -54,7 +55,7 @@ def _trim_container_id(cid):
return cid[:12]

def __init__(self):
self._docker_client = docker.from_env()
self._docker_client = docker.from_env(timeout=DOCKER_CLIENT_TIMEOUT)
self._containers = set()
self._docker_stop_timeout = DOCKER_STOP_TIMEOUT_SECONDS
self._container_wait_seconds = CONTAINER_WAIT_SECONDS
Expand Down Expand Up @@ -245,4 +246,4 @@ def main(command_line_arguments):


if __name__ == "__main__":
exit(main(sys.argv[1:]))
exit(main(sys.argv[1:]))
62 changes: 62 additions & 0 deletions ci/windows_dev_env/setup.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.


$ErrorActionPreference = "Stop"
Set-StrictMode -Version Latest
function Check-Call {
param (
[scriptblock]$ScriptBlock
)
Write-Host "Executing $ScriptBlock"
& @ScriptBlock
if (($lastexitcode -ne 0)) {
Write-Error "Execution failed with $lastexitcode"
exit $lastexitcode
}
}
Check-Call { setx PATH "$($env:path);c:\Program Files\CMake\bin;C:\Program Files\opencv\x64\vc15\bin;" /m }
Set-ExecutionPolicy Bypass -Scope Process -Force
$progressPreference = 'silentlyContinue'
Invoke-WebRequest -Uri https://github.com/notepad-plus-plus/notepad-plus-plus/releases/download/v7.8.4/npp.7.8.4.Installer.exe -OutFile npp.7.8.4.Installer.exe
Check-Call { .\npp.7.8.4.Installer.exe /S }
Invoke-WebRequest -Uri https://chocolatey.org/install.ps1 -OutFile install.ps1
./install.ps1
#Check-Call { C:\ProgramData\chocolatey\choco install python2 -y --no-progress }
Check-Call { C:\ProgramData\chocolatey\choco install python --version=3.7.0 --force -y --no-progress -r}
Check-Call { C:\Python37\python -m pip install --upgrade pip }
Check-Call { C:\Python37\python -m pip install -r requirements.txt }
#Check-Call { C:\Python27\python -m pip install --upgrade pip }
#Check-Call { C:\Python27\python -m pip install -r requirements.txt }

Check-Call { C:\ProgramData\chocolatey\choco install git -y -r --no-progress }
Check-Call { C:\ProgramData\chocolatey\choco install 7zip -y -r --no-progress }
Check-Call { C:\ProgramData\chocolatey\choco install cmake -y -r --no-progress }
Check-Call { C:\ProgramData\chocolatey\choco install ninja -y -r --no-progress }

# Deps
Check-Call { C:\Python37\python windows_deps_headless_installer.py }

# Other software
#Check-Call { C:\ProgramData\chocolatey\choco install jom -y }
#Check-Call { C:\ProgramData\chocolatey\choco install mingw -y -r --no-progress }
Check-Call { C:\ProgramData\chocolatey\choco install javaruntime -y -r --no-progress }

# update path after all software is installed
refreshenv

Write-Output "End"
Loading