Download scripts/bootstrap.ps1 from Allszn/aws-steam-gpu-launchkit: direct link, hf CLI and curl.
- Browser
- Download file 10.1 kB
-
https://huggingface.co/datasets/Allszn/aws-steam-gpu-launchkit/resolve/main/scripts/bootstrap.ps1
- Command line
-
hf download hf://datasets/Allszn/aws-steam-gpu-launchkit/scripts/bootstrap.ps1
-
curl -L -o bootstrap.ps1 https://huggingface.co/datasets/Allszn/aws-steam-gpu-launchkit/resolve/main/scripts/bootstrap.ps1
10.1 kB
| # bootstrap.ps1 - provision a Windows GPU cloud-gaming host | |
| # Run over SSM Run Command (AWS-RunPowerShellScript) or interactively as Administrator. | |
| # Idempotent enough to re-run: it skips work that is already done. | |
| $ErrorActionPreference = 'Stop' | |
| Start-Transcript -Path C:\bootstrap.log -Append | |
| function Section($t) { Write-Output ""; Write-Output "=== $t ===" } | |
| # --------------------------------------------------------------- | |
| # 0. Stop the box from sleeping out from under a stream | |
| # --------------------------------------------------------------- | |
| Section '0. Power settings' | |
| powercfg -change -monitor-timeout-ac 0 | |
| powercfg -change -standby-timeout-ac 0 | |
| powercfg -change -hibernate-timeout-ac 0 | |
| powercfg -h off | |
| Write-Output 'Monitor/standby/hibernate timeouts disabled; hibernation file off.' | |
| # --------------------------------------------------------------- | |
| # 1. Format and mount the game library volume (D:) | |
| # An attached EBS volume arrives "offline"/RAW on Windows and must | |
| # be initialised before Steam can use it. | |
| # --------------------------------------------------------------- | |
| Section '1. Game library volume' | |
| $raw = Get-Disk | Where-Object { $_.PartitionStyle -eq 'RAW' -and $_.Size -gt 50GB } | |
| if ($raw) { | |
| foreach ($d in $raw) { | |
| Initialize-Disk -Number $d.Number -PartitionStyle GPT | |
| New-Partition -DiskNumber $d.Number -UseMaximumSize -DriveLetter D | |
| Format-Volume -DriveLetter D -FileSystem NTFS -NewFileSystemLabel 'SteamLibrary' -Confirm:$false | |
| Write-Output "Initialised disk $($d.Number) as D:" | |
| } | |
| } else { | |
| Write-Output 'No RAW disk found - volume already initialised or not attached.' | |
| } | |
| if (-not (Get-PSDrive -Name D -ErrorAction SilentlyContinue)) { | |
| Write-Warning 'D: is not present. Check the EBS volume attachment before continuing.' | |
| } else { | |
| New-Item -ItemType Directory -Force -Path 'D:\SteamLibrary' | Out-Null | |
| New-Item -ItemType Directory -Force -Path 'D:\ShaderCache' | Out-Null | |
| } | |
| # --------------------------------------------------------------- | |
| # 2. NVIDIA gaming driver | |
| # These downloads are available to AWS customers only and are bound | |
| # by the NVIDIA GRID Cloud End User License Agreement. | |
| # --------------------------------------------------------------- | |
| Section '2. NVIDIA gaming driver' | |
| $Bucket = 'nvidia-gaming' | |
| $KeyPrefix = 'windows/latest' | |
| $LocalPath = 'C:\NVIDIA' | |
| New-Item -ItemType Directory -Force -Path $LocalPath | Out-Null | |
| $Objects = Get-S3Object -BucketName $Bucket -KeyPrefix $KeyPrefix -Region us-east-1 | |
| foreach ($Object in $Objects) { | |
| if ($Object.Key -ne '' -and $Object.Size -ne 0) { | |
| $dest = Join-Path $LocalPath (Split-Path $Object.Key -Leaf) | |
| Copy-S3Object -BucketName $Bucket -Key $Object.Key -LocalFile $dest -Region us-east-1 | |
| } | |
| } | |
| Get-ChildItem $LocalPath -Filter '*.exe' | Select-Object Name, Length | Format-Table | |
| # Match the installer to the OS build rather than blindly taking the newest file. | |
| $osVersion = (Get-CimInstance Win32_OperatingSystem).Caption | |
| $installer = Get-ChildItem $LocalPath -Filter '*.exe' | | |
| Where-Object { $_.Name -match 'server2022|server2025' } | | |
| Select-Object -First 1 | |
| $alreadyInstalled = Test-Path 'HKLM:\SYSTEM\CurrentControlSet\Services\nvlddmkm' | |
| if ($installer -and -not $alreadyInstalled) { | |
| Write-Output "Installing $($installer.Name) for '$osVersion' ..." | |
| Start-Process -FilePath $installer.FullName -ArgumentList '-s','-noreboot' -Wait | |
| } elseif ($alreadyInstalled) { | |
| Write-Output 'NVIDIA driver already present; skipping installer.' | |
| } else { | |
| Write-Warning "No installer matched '$osVersion'. Install manually from $LocalPath, then re-run." | |
| } | |
| # Register the driver for the vGaming marketplace (driver 527.27 and later path). | |
| reg add "HKLM\SYSTEM\CurrentControlSet\Services\nvlddmkm\Global" ` | |
| /v vGamingMarketplace /t REG_DWORD /d 2 /f | |
| # Licensing certificate. The cert family MUST match the driver version family: | |
| # 591.59+ -> GridSwCert_2026_03_02.cert | |
| # 576.80 - 581.80 -> GridSwCertWindows_2025_07_01.cert | |
| # 460.39 - 576.72 -> GridSwCertWindows_2024_02_22.cert | |
| $certUrl = 'https://nvidia-gaming.s3.amazonaws.com/GridSwCert-Archive/GridSwCert_2026_03_02.cert' | |
| try { | |
| Invoke-WebRequest -Uri $certUrl -OutFile "$Env:PUBLIC\Documents\GridSwCert.txt" | |
| Write-Output 'GridSwCert.txt written to Public Documents.' | |
| } catch { | |
| Write-Warning "Certificate download failed: $_" | |
| Write-Warning 'On Windows Server 2016 or earlier, enable TLS 1.2 first:' | |
| Write-Warning ' [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12' | |
| } | |
| # --------------------------------------------------------------- | |
| # 3. Amazon DCV server | |
| # Download the current MSI from the Amazon DCV website first | |
| # (C:\DCV). Unattended switches are documented by AWS. | |
| # --------------------------------------------------------------- | |
| Section '3. Amazon DCV server' | |
| # DCV requires the Microsoft Visual C++ Redistributable for VS 2022 on 2024.0+. | |
| $vcpp = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64' -ErrorAction SilentlyContinue).Version | |
| if (-not $vcpp) { Write-Warning 'Visual C++ 2022 redistributable not detected; the DCV installer will attempt it.' } | |
| $dcvMsi = Get-ChildItem 'C:\DCV' -Filter 'nice-dcv-server-x64-Release*.msi' -ErrorAction SilentlyContinue | | |
| Sort-Object LastWriteTime -Descending | Select-Object -First 1 | |
| if ($dcvMsi) { | |
| $msiArgs = @('/i', "`"$($dcvMsi.FullName)`"", '/qn', 'ADDLOCAL=ALL', | |
| 'AUTOMATIC_SESSION_OWNER=Administrator') | |
| Start-Process msiexec.exe -ArgumentList $msiArgs -Wait | |
| Write-Output "DCV installed from $($dcvMsi.Name)" | |
| } else { | |
| Write-Warning 'No DCV MSI found in C:\DCV - download it and re-run this section.' | |
| } | |
| # Confirm the service is actually up and listening before declaring victory. | |
| $svc = Get-Service dcvserver -ErrorAction SilentlyContinue | |
| if ($svc) { | |
| if ($svc.Status -ne 'Running') { Start-Service dcvserver } | |
| Write-Output "dcvserver status: $((Get-Service dcvserver).Status)" | |
| } | |
| # --------------------------------------------------------------- | |
| # 4. CloudWatch agent: host metrics + Windows error events | |
| # --------------------------------------------------------------- | |
| Section '4. CloudWatch agent' | |
| $agentPath = "$env:ProgramFiles\Amazon\AmazonCloudWatchAgent" | |
| if (-not (Test-Path $agentPath)) { | |
| $agentMsi = 'https://s3.amazonaws.com/amazoncloudwatch-agent/windows/amd64/latest/amazon-cloudwatch-agent.msi' | |
| $tmp = "$env:TEMP\amazon-cloudwatch-agent.msi" | |
| Invoke-WebRequest -Uri $agentMsi -OutFile $tmp | |
| Start-Process msiexec.exe -ArgumentList @('/i', "`"$tmp`"", '/qn') -Wait | |
| } | |
| $cwConfig = @' | |
| { | |
| "agent": { "metrics_collection_interval": 60, "run_as_user": "System" }, | |
| "metrics": { | |
| "namespace": "SteamGpuHost", | |
| "append_dimensions": { "InstanceId": "${aws:InstanceId}" }, | |
| "metrics_collected": { | |
| "LogicalDisk": { "measurement": ["% Free Space"], "resources": ["*"] }, | |
| "Memory": { "measurement": ["% Committed Bytes In Use"] }, | |
| "Processor": { "measurement": ["% Idle Time", "% Processor Time"], "resources": ["*"] }, | |
| "PhysicalDisk": { "measurement": ["% Disk Time", "Avg. Disk Queue Length"], "resources": ["*"] } | |
| } | |
| }, | |
| "logs": { | |
| "logs_collected": { | |
| "files": { | |
| "collect_list": [ | |
| { | |
| "file_path": "C:\\bootstrap.log", | |
| "log_group_name": "/steam-gpu/diagnostics", | |
| "log_stream_name": "{instance_id}/bootstrap" | |
| } | |
| ] | |
| }, | |
| "windows_events": { | |
| "collect_list": [ | |
| { | |
| "event_name": "System", | |
| "event_levels": ["ERROR", "CRITICAL"], | |
| "log_group_name": "/steam-gpu/diagnostics", | |
| "log_stream_name": "{instance_id}/system" | |
| } | |
| ] | |
| } | |
| } | |
| } | |
| } | |
| '@ | |
| $configPath = 'C:\ProgramData\Amazon\AmazonCloudWatchAgent\config.json' | |
| $cwConfig | Out-File -FilePath $configPath -Encoding ascii | |
| & "$agentPath\amazon-cloudwatch-agent-ctl.ps1" -a fetch-config -m ec2 -s -c "file:$configPath" | |
| Write-Output 'CloudWatch agent configured.' | |
| # --------------------------------------------------------------- | |
| # 5. GPU heartbeat metric (nvidia-smi based, so it works regardless | |
| # of whether the agent's GPU plugin is enabled on this OS build) | |
| # --------------------------------------------------------------- | |
| Section '5. GPU heartbeat' | |
| $hbDir = 'C:\ProgramData\SteamGpu' | |
| New-Item -ItemType Directory -Force -Path $hbDir | Out-Null | |
| $hbScript = @' | |
| param([string]$Region) | |
| $cache = 'C:\ProgramData\SteamGpu\nvidia-smi.path' | |
| $smi = $null | |
| if (Test-Path $cache) { $smi = (Get-Content $cache -Raw).Trim() } | |
| if (-not $smi -or -not (Test-Path $smi)) { | |
| $f = Get-ChildItem -Path C:\ -Recurse -Filter 'nvidia-smi.exe' -ErrorAction SilentlyContinue | Select-Object -First 1 | |
| if ($f) { $smi = $f.FullName; $smi | Out-File $cache -Encoding ascii } | |
| } | |
| $ok = 0 | |
| if ($smi) { & $smi --query-gpu=name --format=csv,noheader *> $null; if ($LASTEXITCODE -eq 0) { $ok = 1 } } | |
| aws cloudwatch put-metric-data --region $Region --namespace SteamGpu ` | |
| --metric-name GPUHeartbeat --value $ok --unit Count | |
| '@ | |
| $hbScript | Out-File -FilePath "$hbDir\gpu-heartbeat.ps1" -Encoding ascii | |
| # Scheduled task needs AWS credentials from the instance profile; the | |
| # CloudWatch agent's namespace is used for the heartbeat metric. | |
| $action = New-ScheduledTaskAction -Execute 'powershell.exe' ` | |
| -Argument "-NoProfile -ExecutionPolicy Bypass -File $hbDir\gpu-heartbeat.ps1 -Region $env:AWS_REGION" | |
| $trigger = New-ScheduledTaskTrigger -Once -At (Get-Date).AddMinutes(2) ` | |
| -RepetitionInterval (New-TimeSpan -Minutes 5) | |
| $principal = New-ScheduledTaskPrincipal -UserId 'SYSTEM' -LogonType ServiceAccount -RunLevel Highest | |
| Register-ScheduledTask -TaskName 'SteamGpu-GPUHeartbeat' -Action $action -Trigger $trigger ` | |
| -Principal $principal -Force | Out-Null | |
| Write-Output 'GPU heartbeat task registered (every 5 minutes).' | |
| Stop-Transcript | |
| Write-Output '' | |
| Write-Output 'Bootstrap complete. Reboot once so the GPU driver loads, then run diagnose.ps1.' | |
| Write-Output 'Expected after reboot: Product Name : NVIDIA Cloud Gaming / License Status : Licensed' | |