This repository is a PowerShell project for monitoring GPU temperature and putting a Windows system to sleep once the GPU has cooled to a defined target.
The project started from a real personal need: after GPU-intensive work ends, the system may still be too warm to sleep immediately. Rather than manually watching temperatures and waiting, the goal is to automate that handoff safely.
Quick navigation:
- Portfolio Context
- Engineering Principles in Practice
- Validation And Maintenance
- Repository Structure
This repository is part of a PowerShell portfolio built from pwsh-dev-template, and it is centered on a real operational need rather than a generic sample. It demonstrates safe automation around system power state, provider-aware hardware polling, and the discipline required to turn a narrow utility into a maintainable PowerShell module.
A reviewer should pay attention first to the end-to-end cooldown workflow, the safety posture around system sleep, and how provider-specific concerns are being isolated so the NVIDIA-first implementation can grow into a cleaner multi-provider design over time.
- Deterministic Development Runtime: PowerShell 7.4 is the maintained baseline, and real module execution stays on a Windows host because the workload is Windows-specific
- Safe Power-State Control: System sleep orchestration should be explicit, observable, and guarded by clear result contracts
- Provider-Aware Design: Device discovery, telemetry, and cooldown logic should stay structured so the NVIDIA-first implementation can expand without collapsing into vendor-specific sprawl
- Timeout-Bounded Automation: Cooldown waiting should remain explicitly bounded so the module never blocks indefinitely while waiting for thermal conditions to change
- Observability During Cooldown: Operators should be able to understand what the cooldown loop is doing without reverse-engineering internal state
- Disciplined Module Structure: Public commands, private helpers, and provider-specific behavior should stay cleanly separated
- Testable Orchestration: The cooldown and sleep handoff should remain structured around behavior that can be validated through unit tests
For the deeper operating model behind that approach, see docs/powershell-ai-operating-model.md. For repository-specific design direction, provider modeling, and module architecture, see docs/project-direction.md, docs/observability-and-provider-model.md, and docs/module-architecture-overview.md.
- Import the module from
./GpuCooldownSleepduring development and useTest-GpuCooldownSupportto confirm the local environment is ready. - Start with
Get-GpuCooldownDeviceandGet-GpuCooldownTemperatureto understand provider discovery and normalized telemetry. - Use
Wait-GpuCooldownwhen you want to validate cooldown behavior without changing system power state. - Use
Start-GpuCooldownSleep -WhatIfbefore attempting a real sleep workflow so you can review the orchestration path safely. - Refer to the
Current Commands,Usage, and linked architecture documents below for the full command walkthrough and design rationale.
- Runtime: PowerShell 7.4.x on Windows for module development and execution
- Host Requirement: Windows is required because the module ultimately coordinates system sleep on a Windows system
- Current Provider Baseline: The implemented provider path is NVIDIA-first and expects
nvidia-smito be available - Development Modes: Local VS Code, Docker Dev Containers, and GitHub Codespaces
- Isolation Strategy: Use the container to reduce host tooling and credential exposure during development work
- Pester 6.0.0: For unit and integration testing
- PSScriptAnalyzer 1.25.0: To enforce PowerShell best practices and security rules
- Azure CLI: Pre-installed for cloud resource management
- PSReadLine 2.4.5: Configured for a more efficient terminal experience
Unit tests run in GitHub Actions and can also be run locally through the repository validation and test entrypoints.
GpuCooldownSleep/: module rootGpuCooldownSleep/src/Public/: exported commands and public entrypointsGpuCooldownSleep/src/Private/: shared helpers and internal orchestration logicTests/: Pester tests and test entrypointsdocs/: design notes, operating model guidance, and supporting documentationscripts/: validation, README alignment, and downstream maintenance entrypoints
Run the standard repository checks before committing meaningful changes:
pwsh -NoProfile -File ./scripts/Invoke-RepoChecks.ps1Run the focused unit-test entrypoint directly when you want the repository's dedicated Pester workflow:
pwsh -File .\Tests\Invoke-UnitTests.ps1If this repository keeps the template-managed generated Markdown blocks, refresh or validate them through:
pwsh -NoProfile -File ./scripts/Update-GeneratedMarkdown.ps1 -CheckUse .codex/skills/downstream-guidance-sync/SKILL.md with scripts/Invoke-TemplateGuidanceSync.ps1 when you want to adopt newer pwsh-dev-template guidance, README workflow assets, or guardrails without overwriting repository-owned implementation.
- Install PowerShell 7.4 or use the repository Dev Container / Codespace baseline.
- Ensure an NVIDIA GPU is present and
nvidia-smiis available for the current provider implementation. - Import the module from the repository root during development with
Import-Module .\GpuCooldownSleep -Force. - For normal imports, copy
./GpuCooldownSleep/into a path on$env:PSModulePath, then runImport-Module GpuCooldownSleep -Force. - Review
docs/agent-workflows.md,AGENTS.md, and.github/copilot-instructions.mdbefore using agent-driven repository changes.
This repository versions the GPU Cooldown Sleep project itself using Semantic Versioning.
- Current project version: see
VERSION - Version history: see
CHANGELOG.md
The project version is separate from the template-version badge at the top of this README. That badge records the synced pwsh-dev-template guidance and workflow baseline used by this repository.
The module is functional and actively evolving.
The core workflow is implemented end-to-end (device discovery, temperature polling, cooldown waiting, and safe sleep orchestration), and unit tests run in CI via GitHub Actions.
For the original design intent and the next-stage direction, see:
docs/project-direction.mddocs/observability-and-provider-model.mddocs/module-architecture-overview.md
The initial problem this project is trying to solve is narrow and practical:
- poll GPU temperature from a supported provider
- wait until the temperature reaches a target threshold
- avoid running indefinitely by enforcing a timeout
- provide useful progress feedback while waiting
- put the system to sleep safely once the target condition is met
The current implementation is NVIDIA-first because that is the hardware currently available for testing, but the repository is intentionally being shaped so that additional GPU providers can be added later.
The module currently exports these commands:
Get-GpuCooldownDeviceGet-GpuCooldownTemperatureWait-GpuCooldownStart-GpuCooldownSleepTest-GpuCooldownSupport
These commands provide the first end-to-end slice of the workflow:
- discover supported GPU devices
- retrieve normalized temperature data
- wait for cooldown using a timeout-aware loop
- initiate sleep with
ShouldProcesssupport and an explicit result contract
The current provider implementation is NVIDIA-based and uses nvidia-smi.
Discover the supported GPU device:
Get-GpuCooldownDeviceReview the current environment and dependency readiness:
Test-GpuCooldownSupportGet the current temperature for the default supported device:
Get-GpuCooldownTemperatureTarget a GPU by module-stable device id:
Get-GpuCooldownTemperature -DeviceId 'nvidia:00000000:01:00.0'Target a GPU by friendly name:
Get-GpuCooldownTemperature -Name 'NVIDIA GeForce RTX 2070 SUPER'Wait for the GPU to cool to a target temperature without changing system power state:
Wait-GpuCooldown -TargetTemperature 40 -PollIntervalSeconds 10 -TimeoutMinutes 15 -ShowProgressShow structured diagnostics while monitoring:
Start-GpuCooldownSleep -TargetTemperature 40 -ShowProgress -VerboseExercise the full sleep command safely with -WhatIf:
Start-GpuCooldownSleep -TargetTemperature 40 -PreventSystemSleep -ShowProgress -WhatIfThe -Name parameter is intended to be the friendlier interactive selection path, while -DeviceId remains the more stable automation-oriented selector.
This module uses Write-Verbose for structured, event-style diagnostics.
Get-GpuCooldownDevice -VerboseemitsDeviceDiscoveredevents as it enumerates supported GPUs.- Commands that need to select a single GPU emit a single
DeviceSelectedevent to confirm which device will be monitored.
Verbose output is intended for operator confidence and troubleshooting. The structured objects returned from the commands remain the source of truth for automation.
The initial version of this project is not intended to be:
- a full hardware monitoring suite
- a fan-control or overclocking tool
- a general thermal-management framework
- a polished multi-vendor implementation from day one