[CmdletBinding()] param( [Parameter(Mandatory = $true)] [string]$SourceRoot, [Parameter(Mandatory = $true)] [string]$OutputRoot, [string]$LogPath = '' ) $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' $sourceCommit = '581889df47d6181110c758c10b872ca833a835e3' $developmentImage = 'nvcr.io/nvidia/deepstream:9.1-triton-multiarch@sha256:fd31f5b44ababdbdee8cd397a375e888191b49e402ac237254a4cdc239130f5b' $runtimeImage = 'nvcr.io/nvidia/deepstream:9.1-samples-multiarch@sha256:10eca409b3894e91c1bac915c9f1346307e56695e552487cbe8cf2f58a3f998f' $libraryName = 'libnvds_infercustomparser_tao.so' $expectedSources = [ordered]@{ 'Makefile' = '0265f470354e60c6d719bde68c7b74b1879eed9b4552b8fe7b39416af5ce6835' 'debug_logger_raii.cpp' = '1d388509e1ff9008de6ccd6451db9c6433273ed78a94e95a1df84585b8dc2915' 'debug_logger_raii.hpp' = '6efdce1874468848664a18ceb613f2384b8c079cb12baa888a433d6c0f81b7ec' 'debug_logger_tensor.hpp' = 'c9999fcf92536bbb36498ddd4485f213fc2f5ddc70d24f8d408195a48680b94f' 'nvdsinfer_custombboxparser_tao.cpp' = '1794e3ee5152f25eff31454c6181368676f6659c68fc25b4b1933f6cbb63158b' } function Get-Sha256([string]$Path) { return (Get-FileHash -LiteralPath $Path -Algorithm SHA256).Hash.ToLowerInvariant() } function Invoke-Docker([string[]]$Arguments, [string]$Label) { $previousErrorActionPreference = $ErrorActionPreference $ErrorActionPreference = 'Continue' try { & docker @Arguments $dockerExitCode = $LASTEXITCODE } finally { $ErrorActionPreference = $previousErrorActionPreference } if ($dockerExitCode -ne 0) { throw "$Label failed with exit code $dockerExitCode" } } $source = (Resolve-Path -LiteralPath $SourceRoot).Path New-Item -ItemType Directory -Force -Path $OutputRoot | Out-Null $output = (Resolve-Path -LiteralPath $OutputRoot).Path if ($LogPath) { $logParent = Split-Path -Parent $LogPath if ($logParent) { New-Item -ItemType Directory -Force -Path $logParent | Out-Null } Start-Transcript -LiteralPath $LogPath -Append | Out-Null } try { $sourceLibrary = Join-Path $source $libraryName if (Test-Path -LiteralPath $sourceLibrary -PathType Leaf) { Remove-Item -LiteralPath $sourceLibrary -Force } $actualSourceFiles = @(Get-ChildItem -LiteralPath $source -File | ForEach-Object { $_.Name }) if (@($actualSourceFiles | Where-Object { -not $expectedSources.Contains($_) }).Count -ne 0 -or @($expectedSources.Keys | Where-Object { $actualSourceFiles -notcontains $_ }).Count -ne 0) { throw 'NVIDIA TAO parser source inventory changed.' } foreach ($entry in $expectedSources.GetEnumerator()) { $path = Join-Path $source $entry.Key $actualSha = Get-Sha256 $path if ($actualSha -ne $entry.Value) { throw "NVIDIA TAO parser source changed: $($entry.Key)" } } $previousErrorActionPreference = $ErrorActionPreference $ErrorActionPreference = 'Continue' try { & docker image inspect $developmentImage *> $null $developmentImageCached = $LASTEXITCODE -eq 0 } finally { $ErrorActionPreference = $previousErrorActionPreference } if (-not $developmentImageCached) { Write-Host 'Pulling exact NVIDIA DeepStream 9.1 Triton development image...' Invoke-Docker @('pull', $developmentImage) 'DeepStream development image pull' } $containerSource = '/opt/nvidia/deepstream/deepstream/sources/apps/sample_apps/deepstream_tao_apps/post_processor' Invoke-Docker @( 'run', '--rm', '--gpus', 'all', '--network', 'none', '--cap-drop', 'ALL', '--security-opt', 'no-new-privileges', '--mount', "type=bind,src=$source,dst=$containerSource", '--workdir', $containerSource, '--entrypoint', 'make', $developmentImage, 'CUDA_VER=13.2' ) 'official NVIDIA TAO parser build' if (-not (Test-Path -LiteralPath $sourceLibrary -PathType Leaf) -or (Get-Item -LiteralPath $sourceLibrary).Length -eq 0) { throw 'NVIDIA TAO parser build did not produce a library.' } $destination = Join-Path $output $libraryName $temporary = "$destination.$([Guid]::NewGuid().ToString('N')).tmp" Copy-Item -LiteralPath $sourceLibrary -Destination $temporary Move-Item -LiteralPath $temporary -Destination $destination -Force $librarySha = Get-Sha256 $destination Invoke-Docker @( 'run', '--rm', '--gpus', 'all', '--network', 'none', '--read-only', '--cap-drop', 'ALL', '--security-opt', 'no-new-privileges', '--mount', "type=bind,src=$output,dst=/workspace/parser,readonly", '--entrypoint', '/bin/bash', $runtimeImage, '-lc', "ldd /workspace/parser/$libraryName && nm -D /workspace/parser/$libraryName | grep -q NvDsInferParseCustomDDETRTAO" ) 'NVIDIA TAO parser runtime verification' $manifest = [ordered]@{ schema_version = 'missioncore.e46e-nvidia-tao-parser/v1' status = 'completed' source_repository = 'https://github.com/NVIDIA/DeepStream.git' source_commit = $sourceCommit source_files = @($expectedSources.GetEnumerator() | ForEach-Object { [ordered]@{ path = $_.Key; sha256 = $_.Value } }) development_image = $developmentImage runtime_image = $runtimeImage cuda_version = '13.2' symbol = 'NvDsInferParseCustomDDETRTAO' library_file = $libraryName library_sha256 = $librarySha completed_at_utc = (Get-Date).ToUniversalTime().ToString('o') } $manifest | ConvertTo-Json -Depth 8 | Set-Content -LiteralPath (Join-Path $output 'parser-runtime.json') -Encoding UTF8 Write-Host "E46E_NVIDIA_TAO_PARSER_COMPLETED sha256=$librarySha output=$output" } finally { if ($LogPath) { Stop-Transcript | Out-Null } }