Download code/scripts/start_cpu_preview.ps1 from CollinMa/nextgpt-chapter6-report: direct link, hf CLI and curl.
- Browser
- Download file 1.7 kB
-
https://huggingface.co/spaces/CollinMa/nextgpt-chapter6-report/resolve/main/code/scripts/start_cpu_preview.ps1
- Command line
-
hf download hf://spaces/CollinMa/nextgpt-chapter6-report/code/scripts/start_cpu_preview.ps1
-
curl -L -o start_cpu_preview.ps1 https://huggingface.co/spaces/CollinMa/nextgpt-chapter6-report/resolve/main/code/scripts/start_cpu_preview.ps1
1.7 kB
| param( | |
| [switch]$Install, | |
| [switch]$CheckOnly | |
| ) | |
| $ErrorActionPreference = 'Stop' | |
| $projectRoot = Split-Path -Parent $PSScriptRoot | |
| $runtimePath = Join-Path $projectRoot '.runtime' | |
| $pythonPath = Join-Path $runtimePath 'python.exe' | |
| Push-Location $projectRoot | |
| try { | |
| if (-not (Test-Path -LiteralPath $pythonPath)) { | |
| if (-not $Install) { throw 'Runtime missing. Run this script with -Install first.' } | |
| $condaCommand = Get-Command conda -ErrorAction Stop | |
| & $condaCommand create --prefix $runtimePath python=3.10 pip -y | |
| if ($LASTEXITCODE -ne 0) { throw 'Conda environment creation failed.' } | |
| } | |
| if ($Install) { | |
| & $pythonPath -m pip install pip==24.3.1 setuptools==69.5.1 wheel==0.44.0 | |
| if ($LASTEXITCODE -ne 0) { throw 'Build tools installation failed.' } | |
| & $pythonPath -m pip install torch==1.13.1+cpu torchvision==0.14.1+cpu torchaudio==0.13.1+cpu --extra-index-url https://download.pytorch.org/whl/cpu | |
| if ($LASTEXITCODE -ne 0) { throw 'CPU PyTorch installation failed.' } | |
| & $pythonPath -m pip install -r requirements.txt | |
| if ($LASTEXITCODE -ne 0) { throw 'Runtime dependencies installation failed.' } | |
| & $pythonPath -m pip check | |
| if ($LASTEXITCODE -ne 0) { throw 'Dependency validation failed.' } | |
| } | |
| if ($CheckOnly) { | |
| & $pythonPath -X utf8 scripts/check_environment.py | |
| if ($LASTEXITCODE -ne 0) { throw 'Environment check failed.' } | |
| } else { | |
| # start-preview.cmd scopes these environment settings with setlocal. | |
| & (Join-Path $projectRoot 'start-preview.cmd') | |
| if ($LASTEXITCODE -ne 0) { throw 'CPU preview failed.' } | |
| } | |
| } finally { | |
| Pop-Location | |
| } | |