Skip to content

Commit

Permalink
add windows build to jenkins, #0
Browse files Browse the repository at this point in the history
  • Loading branch information
carsonswope committed Aug 28, 2024
1 parent 0523cdd commit 32b3d99
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 54 deletions.
File renamed without changes.
File renamed without changes.
91 changes: 91 additions & 0 deletions bfx/build_win.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# run inside a MSVC shell w/ python interpreter present
# tested using MSVC 2022 because it comes w/ a new enough version of cmake
$ErrorActionPreference = 'Stop'; # quit on error..
Set-StrictMode -Version Latest;
$PSDefaultParameterValues['*:ErrorAction']='Stop';
function CheckForErrors { if (-not $?) { throw 'Failure!'; } }

$DIST_NAME = $args[0]

Write-Output "starting onnxruntime build: ${DIST_NAME}"

# clear any previous build..
if (Test-Path build) { Remove-Item -r -Force build }
mkdir build

Push-Location build
# fetch CUDA dependencies from BinaryArtifacts
$BINARY_ARTIFACTS = 'mescola:Boris FX/Engineering/BinaryArtifacts'

$CUDA_SDK_NAME='cuda-sdk-win-v11.8'
rclone copy ($BINARY_ARTIFACTS + '/' + $CUDA_SDK_NAME + '.zip') .
tar -xzf ($CUDA_SDK_NAME + '.zip')
$CUDA_HOME = "$(Get-Location)\build\${CUDA_SDK_NAME}"

$CUDNN_NAME='cudnn-windows-x86_64-8.9.1.23_cuda11-archive'
rclone copy ($BINARY_ARTIFACTS + '/' + $CUDNN_NAME + '.zip') .
tar -xzf ($CUDNN_NAME + '.zip')
$CUDNN_HOME = "$(Get-Location)\build\${CUDNN_NAME}"
Pop-Location

conda activate base; CheckForErrors;

'-- MSVC compiler info --';
cl; CheckForErrors;

# cmake on path
'-- cmake info --';
cmake --version; CheckForErrors;

# conda environment available
'-- conda info --';
conda --version; CheckForErrors;

'-- python info --';
python --version; CheckForErrors;
where.exe python

'-- running build --';
# now run onnxruntime build script
.\build.bat `
--config Release `
--cmake_generator "Visual Studio 17 2022" `
--build_shared_lib `
--parallel `
--use_dml `
--use_cuda `
--cuda_home $CUDA_HOME `
--cudnn_home $CUDNN_HOME `
--skip_tests `
--cmake_extra_defines onnxruntime_BUILD_UNIT_TESTS=OFF

# can incremental build too after initial call to .\build.bat
# cmake --build .\build\Windows\Release -j12 --config Release

# rm -r -Force .\build\dist_release
$DIST_DIR=".\build\${DIST_NAME}"
mkdir $DIST_DIR
$DIST_LIB_DIR="${DIST_DIR}\lib"
mkdir $DIST_LIB_DIR
Copy-Item .\build\Windows\Release\Release\onnxruntime.dll $DIST_LIB_DIR
Copy-Item .\build\Windows\Release\Release\onnxruntime.lib $DIST_LIB_DIR
Copy-Item .\build\Windows\Release\Release\onnxruntime_providers_cuda.dll $DIST_LIB_DIR
Copy-Item .\build\Windows\Release\Release\onnxruntime_providers_cuda.lib $DIST_LIB_DIR
Copy-Item .\build\Windows\Release\Release\onnxruntime_providers_shared.dll $DIST_LIB_DIR
Copy-Item .\build\Windows\Release\Release\onnxruntime_providers_shared.lib $DIST_LIB_DIR
Copy-Item .\build\Windows\Release\Release\DirectML.dll $DIST_LIB_DIR
Copy-Item .\build\Windows\Release\Release\DirectML.Debug.dll $DIST_LIB_DIR
Copy-Item -r .\include $DIST_DIR

# generate manifest for libraries with DLL hashes
Copy-Item bfx/bfx_ml.ort_dml_deps.runtime.manifest.in $DIST_LIB_DIR
Push-Location $DIST_LIB_DIR
mt.exe -manifest bfx_ml.ort_dml_deps.runtime.manifest.in -hashupdate -out:bfx_ml.ort_dml_deps.runtime.manifest
Remove-Item bfx_ml.ort_dml_deps.runtime.manifest.in
Pop-Location

# make zip archive!
$DIST_PATH = "$(Get-Location)\${DIST_DIR}"
Compress-Archive -Path $DIST_PATH -DestinationPath "${DIST_PATH}.zip" -Force

Write-Output "onnxruntime build completed, artifact generated: build\${DIST_NAME}.zip"
25 changes: 25 additions & 0 deletions bfx/build_win_jenkins.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@echo off

cd %WORKSPACE%

CALL "C:\Program Files (x86)\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build\vcvars64.bat"

REM jenkins adds a path to jre that is wrapped by double quotes to PATH and __VSCMD_PREINIT_PATH. remove the double quotes to make msvc & nvcc happy!
SET PATH=%PATH:"=%
SET __VSCMD_PREINIT_PATH=%__VSCMD_PREINIT_PATH:"=%

set ORT_VERSION=1.18.1

REM is this really the best way to do this in CMD???
>temp.txt ( git rev-parse --short HEAD )
set /p GIT_HASH=<temp.txt
del temp.txt
set GIT_HASH=%GIT_HASH:~0,7%

set DIST_NAME=libonnxruntime-%ORT_VERSION%_win_cu118-dml-1.14.1_%GIT_HASH%_%BUILD_NUMBER%

Powershell.exe -File bfx/build_win.ps1 %DIST_NAME%

rclone copy build\%DIST_NAME%.zip "mescola:Boris FX/Engineering/BinaryArtifacts"

EXIT 0
31 changes: 0 additions & 31 deletions bfx_build_win.ps1

This file was deleted.

23 changes: 0 additions & 23 deletions bfx_build_win_debug.ps1

This file was deleted.

0 comments on commit 32b3d99

Please sign in to comment.