install_windows.ps1 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # Installing Aphrodite engine on Windows
  2. # Copyright (c) 2024 PygmalionAI
  3. $RequiredVer = "0.6.3.post1"
  4. # Check if Python is installed and version >= 3.8
  5. try {
  6. $pythonVersion = (python --version 2>&1).ToString().Split(" ")[1]
  7. $major, $minor = $pythonVersion.Split(".")[0,1]
  8. if ([int]$major -lt 3 -or ([int]$major -eq 3 -and [int]$minor -lt 8)) {
  9. Write-Error "Python version must be 3.8 or above."
  10. exit 1
  11. }
  12. } catch {
  13. Write-Error "Python is not installed. Please install Python 3.8 or above."
  14. exit 1
  15. }
  16. # Get Python version for wheel files
  17. $pyVer = python -c "import sys; print(f'cp{sys.version_info.major}{sys.version_info.minor}-cp{sys.version_info.major}{sys.version_info.minor}')"
  18. # Check if running in venv
  19. $venvStatus = python -c "import sys; print('INVENV' if (hasattr(sys, 'real_prefix') or (hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix)) else 'NOVENV')"
  20. if ($venvStatus -eq "NOVENV") {
  21. Write-Host "Creating new virtual environment..."
  22. python -m venv venv
  23. . .\venv\Scripts\Activate.ps1
  24. Write-Host "Virtual environment created and activated."
  25. } elseif ($venvStatus -eq "INVENV") {
  26. Write-Host "Already running in virtual environment, continuing..."
  27. } else {
  28. Write-Error "Failed to check virtual environment status."
  29. exit 1
  30. }
  31. # Check for -Reinstall parameter
  32. $forceReinstall = $args -contains "-Reinstall"
  33. # Check current aphrodite version if installed
  34. if (-not $forceReinstall) {
  35. try {
  36. $installedVer = (pip show aphrodite-engine | Select-String "Version").ToString().Split(" ")[1]
  37. if ($installedVer -eq $RequiredVer) {
  38. Write-Host "Aphrodite engine is already at required version $RequiredVer"
  39. exit 0
  40. }
  41. } catch {}
  42. }
  43. # Install/Reinstall packages
  44. Write-Host "Installing PyTorch and xformers..."
  45. pip install "https://download.pytorch.org/whl/cu124/torch-2.4.1%2Bcu124-$pyVer-win_amd64.whl"
  46. pip install "https://downloads.pygmalion.chat/whl/windows/xformers/xformers-0.0.28-$pyVer-win_amd64.whl" --no-deps
  47. Write-Host "Installing Aphrodite engine..."
  48. pip install "https://github.com/PygmalionAI/aphrodite-engine/releases/download/v$RequiredVer/aphrodite_engine-$RequiredVer-cp38-abi3-win_amd64.whl"
  49. Write-Host "Installation complete!"