diff options
| author | Billy O'Neal <bion@microsoft.com> | 2021-04-26 10:27:45 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-26 10:27:45 -0700 |
| commit | a9b27ed5dffbf70b135eddb0c4729f3ca87f106c (patch) | |
| tree | cc562b219c82e40567925a48248cbc17b2cc2b59 /scripts/azure-pipelines/windows/create-vmss.ps1 | |
| parent | 84e5852cfaa8e7875027e79a29a5534bb5d4a475 (diff) | |
| download | vcpkg-a9b27ed5dffbf70b135eddb0c4729f3ca87f106c.tar.gz vcpkg-a9b27ed5dffbf70b135eddb0c4729f3ca87f106c.zip | |
Update VMs, CMake to 3.20.1, CUDA to 11.3, and pwsh to 7.1.3 (#17331)
* Update to CUDA 11.3 on Windows.
* Update PowerShell to 7.1.3.
* Update CUDA to 11.3 on Linux.
* "Explode" VM provisioning scripts for more consistent feedback during deploy. This resolves the deployment script often hanging with no feedback as to why.
* [libdatachannel] Fix use of deprecated result_type typedef.
Submitted upstream as https://github.com/paullouisageneau/libdatachannel/pull/413
* [libvpx] Get the libvpx outputs from the correct place.
(Perhaps VS2019 version 16.10 moved where these are placed? I've been defensive and left an attempt to find from the old location in place.)
* [chromaprint] Support implementations where lrintf is an intrinsic.
* Add provision-entire-image script.
* [cudnn] Disable download-on-the-fly due to licensing concerns.
* Add libnccl to Linux VMs.
* [wangle] Disable x64-windows due to an ICE.
* [cmake] Update cmake to 3.20.1 to avoid https://gitlab.kitware.com/cmake/cmake/-/issues/21571 race
* [libudis86] Fix passing a bogus working directory which fails on CMake 3.20.x
* [dartsim] Disable unit tests, examples, and tutorials, some of which have CMake authoring errors rejected by 3.20.1.
* Add thrust to the cuda installees.
* [tensorflow] Put .bzl in CURRENT_BUILDTREES_DIR to avoid running out of disk space in CI and to respect --clean-after-build.
* [dimcli] Skip port broken by changes in VS2019 project system.
* [upb] Disable an additional warning.
* [libhv] Fix typo DISABLE_PARALLEL => DISABLE_PARALLEL_CONFIGURE
* Update pools
Diffstat (limited to 'scripts/azure-pipelines/windows/create-vmss.ps1')
| -rw-r--r-- | scripts/azure-pipelines/windows/create-vmss.ps1 | 247 |
1 files changed, 190 insertions, 57 deletions
diff --git a/scripts/azure-pipelines/windows/create-vmss.ps1 b/scripts/azure-pipelines/windows/create-vmss.ps1 index 608465100..fddba0eec 100644 --- a/scripts/azure-pipelines/windows/create-vmss.ps1 +++ b/scripts/azure-pipelines/windows/create-vmss.ps1 @@ -21,11 +21,18 @@ the compiler rather than for testing vcpkg. Differences: * The machine prefix is changed to VcpkgUnstable instead of PrWin.
* No storage account or "archives" share is provisioned.
* The firewall is not opened to allow communication with Azure Storage.
+
+.PARAMETER CudnnPath
+The path to a CUDNN zip file downloaded from NVidia official sources
+(e.g. https://developer.nvidia.com/compute/machine-learning/cudnn/secure/8.1.1.33/11.2_20210301/cudnn-11.2-windows-x64-v8.1.1.33.zip
+downloaded in a browser with an NVidia account logged in.)
#>
[CmdLetBinding()]
Param(
- [switch]$Unstable = $false
+ [switch]$Unstable = $false,
+ [parameter(Mandatory=$true)]
+ [string]$CudnnPath
)
$Location = 'westus2'
@@ -43,15 +50,16 @@ $WindowsServerSku = '2019-Datacenter' $ErrorActionPreference = 'Stop'
$ProgressActivity = 'Creating Scale Set'
-$TotalProgress = 12
-if ($Unstable) {
- $TotalProgress -= 1 # skipping the archives share part
-}
-
+$TotalProgress = 18
$CurrentProgress = 1
Import-Module "$PSScriptRoot/../create-vmss-helpers.psm1" -DisableNameChecking
+if (-Not $CudnnPath.EndsWith('.zip')) {
+ Write-Error 'Expected CudnnPath to be a zip file.'
+ return
+}
+
####################################################################################################
Write-Progress `
-Activity $ProgressActivity `
@@ -155,57 +163,84 @@ $VirtualNetwork = New-AzVirtualNetwork ` -Subnet $Subnet
####################################################################################################
-if (-Not $Unstable) {
- Write-Progress `
- -Activity $ProgressActivity `
- -Status 'Creating archives storage account' `
- -PercentComplete (100 / $TotalProgress * $CurrentProgress++)
+Write-Progress `
+ -Activity $ProgressActivity `
+ -Status 'Creating storage account' `
+ -CurrentOperation 'Initial setup' `
+ -PercentComplete (100 / $TotalProgress * $CurrentProgress++)
- $StorageAccountName = Sanitize-Name $ResourceGroupName
+$StorageAccountName = Sanitize-Name $ResourceGroupName
- New-AzStorageAccount `
- -ResourceGroupName $ResourceGroupName `
- -Location $Location `
- -Name $StorageAccountName `
- -SkuName 'Standard_LRS' `
- -Kind StorageV2
+New-AzStorageAccount `
+ -ResourceGroupName $ResourceGroupName `
+ -Location $Location `
+ -Name $StorageAccountName `
+ -SkuName 'Standard_LRS' `
+ -Kind StorageV2
- $StorageAccountKeys = Get-AzStorageAccountKey `
- -ResourceGroupName $ResourceGroupName `
- -Name $StorageAccountName
+$StorageAccountKeys = Get-AzStorageAccountKey `
+ -ResourceGroupName $ResourceGroupName `
+ -Name $StorageAccountName
- $StorageAccountKey = $StorageAccountKeys[0].Value
+$StorageAccountKey = $StorageAccountKeys[0].Value
- $StorageContext = New-AzStorageContext `
- -StorageAccountName $StorageAccountName `
- -StorageAccountKey $StorageAccountKey
+$StorageContext = New-AzStorageContext `
+ -StorageAccountName $StorageAccountName `
+ -StorageAccountKey $StorageAccountKey
- New-AzStorageContainer -Name archives -Context $StorageContext -Permission Off
- $StartTime = [DateTime]::Now
- $ExpiryTime = $StartTime.AddMonths(6)
+Write-Progress `
+ -Activity $ProgressActivity `
+ -Status 'Creating storage account' `
+ -CurrentOperation 'Uploading cudnn.zip' `
+ -PercentComplete (100 / $TotalProgress * $CurrentProgress) # note no ++
- $SasToken = New-AzStorageAccountSASToken `
- -Service Blob `
- -Permission "racwdlup" `
- -Context $StorageContext `
- -StartTime $StartTime `
- -ExpiryTime $ExpiryTime `
- -ResourceType Service,Container,Object `
- -Protocol HttpsOnly
+New-AzStorageContainer -Name setup -Context $storageContext -Permission blob
- $SasToken = $SasToken.Substring(1) # strip leading ?
+Set-AzStorageBlobContent -File $CudnnPath `
+ -Container 'setup' `
+ -Blob 'cudnn.zip' `
+ -Context $StorageContext
- # Note that we put the storage account into the firewall after creating the above SAS token or we
- # would be denied since the person running this script isn't one of the VMs we're creating here.
- Set-AzStorageAccount `
- -ResourceGroupName $ResourceGroupName `
- -AccountName $StorageAccountName `
- -NetworkRuleSet ( `
- @{bypass="AzureServices"; `
- virtualNetworkRules=( `
- @{VirtualNetworkResourceId=$VirtualNetwork.Subnets[0].Id;Action="allow"}); `
- defaultAction="Deny"})
-}
+$CudnnBlobUrl = "https://$StorageAccountName.blob.core.windows.net/setup/cudnn.zip"
+
+Write-Progress `
+ -Activity $ProgressActivity `
+ -Status 'Creating storage account' `
+ -CurrentOperation 'Creating archives container' `
+ -PercentComplete (100 / $TotalProgress * $CurrentProgress) # note no ++
+
+New-AzStorageContainer -Name archives -Context $StorageContext -Permission Off
+
+$StartTime = [DateTime]::Now
+$ExpiryTime = $StartTime.AddMonths(6)
+
+$SasToken = New-AzStorageAccountSASToken `
+ -Service Blob `
+ -Permission "racwdlup" `
+ -Context $StorageContext `
+ -StartTime $StartTime `
+ -ExpiryTime $ExpiryTime `
+ -ResourceType Service,Container,Object `
+ -Protocol HttpsOnly
+
+$SasToken = $SasToken.Substring(1) # strip leading ?
+
+Write-Progress `
+ -Activity $ProgressActivity `
+ -Status 'Creating storage account' `
+ -CurrentOperation 'Locking down network' `
+ -PercentComplete (100 / $TotalProgress * $CurrentProgress) # note no ++
+
+# Note that we put the storage account into the firewall after creating the above SAS token or we
+# would be denied since the person running this script isn't one of the VMs we're creating here.
+Set-AzStorageAccount `
+ -ResourceGroupName $ResourceGroupName `
+ -AccountName $StorageAccountName `
+ -NetworkRuleSet ( `
+ @{bypass="AzureServices"; `
+ virtualNetworkRules=( `
+ @{VirtualNetworkResourceId=$VirtualNetwork.Subnets[0].Id;Action="allow"}); `
+ defaultAction="Deny"})
####################################################################################################
Write-Progress `
@@ -245,30 +280,128 @@ New-AzVm ` ####################################################################################################
Write-Progress `
-Activity $ProgressActivity `
- -Status 'Running provisioning script provision-image.txt (as a .ps1) in VM' `
+ -Status 'Running provisioning script deploy-psexec.ps1 in VM' `
-PercentComplete (100 / $TotalProgress * $CurrentProgress++)
-$provisionParameters = @{AdminUserPassword = $AdminPW;}
-if (-Not $Unstable) {
- $provisionParameters['StorageAccountName'] = $StorageAccountName
- $provisionParameters['StorageAccountSasToken'] = $SasToken
+$DeployPsExecResult = Invoke-AzVMRunCommand `
+ -ResourceGroupName $ResourceGroupName `
+ -VMName $ProtoVMName `
+ -CommandId 'RunPowerShellScript' `
+ -ScriptPath "$PSScriptRoot\deploy-psexec.ps1"
+
+Write-Host "deploy-psexec.ps1 output: $($DeployPsExecResult.value.Message)"
+
+####################################################################################################
+function Invoke-ScriptWithPrefix {
+ param(
+ [string]$ScriptName,
+ [switch]$AddAdminPw,
+ [switch]$AddCudnnUrl
+ )
+
+ Write-Progress `
+ -Activity $ProgressActivity `
+ -Status "Running provisioning script $ScriptName in VM" `
+ -PercentComplete (100 / $TotalProgress * $CurrentProgress++)
+
+ $DropToAdminUserPrefix = Get-Content "$PSScriptRoot\drop-to-admin-user-prefix.ps1" -Encoding utf8NoBOM -Raw
+ $UtilityPrefixContent = Get-Content "$PSScriptRoot\utility-prefix.ps1" -Encoding utf8NoBOM -Raw
+
+ $tempScriptFilename = [System.IO.Path]::GetTempPath() + [System.IO.Path]::GetRandomFileName() + ".txt"
+ try {
+ $script = Get-Content "$PSScriptRoot\$ScriptName" -Encoding utf8NoBOM -Raw
+ if ($AddAdminPw) {
+ $script = $script.Replace('# REPLACE WITH DROP-TO-ADMIN-USER-PREFIX.ps1', $DropToAdminUserPrefix)
+ }
+
+ if ($AddCudnnUrl) {
+ $script = $script.Replace('# REPLACE WITH $CudnnUrl', "`$CudnnUrl = '$CudnnBlobUrl'")
+ }
+
+ $script = $script.Replace('# REPLACE WITH UTILITY-PREFIX.ps1', $UtilityPrefixContent);
+ Set-Content -Path $tempScriptFilename -Value $script -Encoding utf8NoBOM
+
+ $parameter = $null
+ if ($AddAdminPw) {
+ $parameter = @{AdminUserPassword = $AdminPW;}
+ }
+
+ $InvokeResult = Invoke-AzVMRunCommand `
+ -ResourceGroupName $ResourceGroupName `
+ -VMName $ProtoVMName `
+ -CommandId 'RunPowerShellScript' `
+ -ScriptPath $tempScriptFilename `
+ -Parameter $parameter
+
+ Write-Host "$ScriptName output: $($InvokeResult.value.Message)"
+ } finally {
+ Remove-Item $tempScriptFilename -Force
+ }
}
+Invoke-ScriptWithPrefix -ScriptName 'deploy-visual-studio.ps1' -AddAdminPw
+Restart-AzVM -ResourceGroupName $ResourceGroupName -Name $ProtoVMName
+
+####################################################################################################
+Invoke-ScriptWithPrefix -ScriptName 'deploy-windows-wdk.ps1' -AddAdminPw
+Restart-AzVM -ResourceGroupName $ResourceGroupName -Name $ProtoVMName
+
+####################################################################################################
+Invoke-ScriptWithPrefix -ScriptName 'deploy-mpi.ps1' -AddAdminPw
+Restart-AzVM -ResourceGroupName $ResourceGroupName -Name $ProtoVMName
+
+####################################################################################################
+Invoke-ScriptWithPrefix -ScriptName 'deploy-cuda.ps1' -AddAdminPw -AddCudnnUrl
+Restart-AzVM -ResourceGroupName $ResourceGroupName -Name $ProtoVMName
+
+####################################################################################################
+Invoke-ScriptWithPrefix -ScriptName 'deploy-pwsh.ps1' -AddAdminPw
+Restart-AzVM -ResourceGroupName $ResourceGroupName -Name $ProtoVMName
+
+####################################################################################################
+Write-Progress `
+ -Activity $ProgressActivity `
+ -Status 'Running provisioning script deploy-settings.txt (as a .ps1) in VM' `
+ -PercentComplete (100 / $TotalProgress * $CurrentProgress++)
+
$ProvisionImageResult = Invoke-AzVMRunCommand `
-ResourceGroupName $ResourceGroupName `
-VMName $ProtoVMName `
-CommandId 'RunPowerShellScript' `
- -ScriptPath "$PSScriptRoot\provision-image.txt" `
- -Parameter $provisionParameters
+ -ScriptPath "$PSScriptRoot\deploy-settings.txt"
-Write-Host "provision-image.ps1 output: $($ProvisionImageResult.value.Message)"
+Write-Host "deploy-settings.txt output: $($ProvisionImageResult.value.Message)"
####################################################################################################
Write-Progress `
-Activity $ProgressActivity `
- -Status 'Restarting VM' `
+ -Status 'Deploying SAS token into VM' `
-PercentComplete (100 / $TotalProgress * $CurrentProgress++)
+$tempScriptFilename = [System.IO.Path]::GetTempPath() + [System.IO.Path]::GetRandomFileName() + ".txt"
+try {
+ $script = "Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' " `
+ + "-Name PROVISIONED_AZURE_STORAGE_NAME " `
+ + "-Value '$StorageAccountName'`r`n" `
+ + "Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' " `
+ + "-Name PROVISIONED_AZURE_STORAGE_SAS_TOKEN " `
+ + "-Value '$SasToken'`r`n"
+
+ Write-Host "Script content is:"
+ Write-Host $script
+
+ Set-Content -Path $tempScriptFilename -Value $script -Encoding utf8NoBOM
+ $InvokeResult = Invoke-AzVMRunCommand `
+ -ResourceGroupName $ResourceGroupName `
+ -VMName $ProtoVMName `
+ -CommandId 'RunPowerShellScript' `
+ -ScriptPath $tempScriptFilename
+
+ Write-Host "Deploy SAS token output: $($InvokeResult.value.Message)"
+} finally {
+ Remove-Item $tempScriptFilename -Force
+}
+
Restart-AzVM -ResourceGroupName $ResourceGroupName -Name $ProtoVMName
####################################################################################################
|
