forked from PetertheRedCedar/ryfai
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfigure-cpu.bat
More file actions
141 lines (122 loc) · 4.31 KB
/
configure-cpu.bat
File metadata and controls
141 lines (122 loc) · 4.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
@echo off
setlocal enabledelayedexpansion
set script_path=%~dp0
cd /d "%script_path%"
set log_file="%~dp0cpu_installation_errors.log"
> %log_file% echo Script started at %date% %time%
call :log "Script starting."
:: Check if Winget is installed
winget --version >nul 2>>%log_file%
if errorlevel 1 (
call :log "Winget is not installed. Downloading and installing Winget..."
:: Download the Winget installer
curl -L -o "%~dp0AppInstaller.msixbundle" https://github.com/microsoft/winget-cli/releases/latest/download/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle >> %log_file% 2>&1
if not exist "%~dp0AppInstaller.msixbundle" (
call :log "Failed to download Winget installer. Exiting."
pause
exit /b 1
)
:: Install Winget
call :log "Installing Winget..."
powershell -Command "Start-Process -Wait powershell -ArgumentList 'Add-AppxPackage -Path \"%~dp0AppInstaller.msixbundle\"' -Verb RunAs" >> %log_file% 2>&1
winget --version >nul 2>>%log_file%
if errorlevel 1 (
call :log "Winget installation failed. Exiting."
pause
exit /b 1
)
) else (
call :log "Winget is already installed."
)
:: Install Rust using Winget
call :log "Checking if Rust is installed..."
rustc --version >nul 2>>%log_file%
if errorlevel 1 (
call :log "Rust is not installed. Installing Rust using Winget..."
echo Installing Rust...
winget install -e --id Rustlang.Rustup --interactive
rustc --version >nul 2>>%log_file%
if errorlevel 1 (
call :log "Failed to install Rust. Exiting."
pause
exit /b 1
)
) else (
call :log "Rust is already installed."
)
:: Install Ollama using Winget
call :log "Checking if Ollama is installed..."
ollama --version >nul 2>>%log_file%
if errorlevel 1 (
call :log "Ollama is not installed. Installing Ollama using Winget..."
echo Installing Ollama...
winget install -e --id Ollama.Ollama --interactive
ollama --version >nul 2>>%log_file%
if errorlevel 1 (
call :log "Failed to install Ollama. Exiting."
pause
exit /b 1
)
) else (
call :log "Ollama is already installed."
)
:: Check if Python is installed
python --version >nul 2>>%log_file%
if errorlevel 1 (
call :log "Python is not installed. Downloading Python installer..."
curl -L -o "%~dp0python-3.12.3-amd64.exe" https://www.python.org/ftp/python/3.12.3/python-3.12.3-amd64.exe >> %log_file% 2>&1
if not exist "%~dp0python-3.12.3-amd64.exe" (
call :log "Failed to download Python installer. Exiting."
pause
exit /b 1
)
call :log "Installing Python as administrator..."
powershell -Command "Start-Process '%~dp0python-3.12.3-amd64.exe' -ArgumentList '/quiet InstallAllUsers=1 PrependPath=1 Include_pip=1' -Verb RunAs" >> %log_file% 2>&1
python --version >nul 2>>%log_file%
if errorlevel 1 (
call :log "Python installation failed. Exiting."
pause
exit /b 1
)
)
python --version >nul 2>>%log_file%
if errorlevel 1 (
call :log "Python installation failed. Please install Python manually: https://www.python.org/"
pause
exit /b 1
)
:: Ensure pip is installed
pip --version >nul 2>>%log_file%
if errorlevel 1 (
call :log "pip not found. Installing pip..."
python -m ensurepip --upgrade >> %log_file% 2>&1
python -m pip install --upgrade pip >> %log_file% 2>&1
if errorlevel 1 (
call :log "Failed to install pip. Exiting."
pause
exit /b 1
)
)
:: Install Python dependencies
call :log "Installing Python dependencies (CPU-only PyTorch)..."
powershell -Command "Start-Process python -ArgumentList '-m pip install --upgrade torch torchvision transformers diffusers ollama streamlit easygui' -Verb RunAs" >> %log_file% 2>&1
if errorlevel 1 (
call :log "Failed to install Python dependencies. Exiting."
pause
exit /b 1
)
:: Launch RYFAI
call :log "Launching RYFAI..."
streamlit run "%~dp0ryfai.py" >> %log_file% 2>&1
if errorlevel 1 (
call :log "Failed to launch RYFAI. Exiting."
pause
exit /b 1
)
call :log "Script completed successfully."
pause
exit /b 0
:log
echo [%time%] %~1 >> %log_file%
echo %~1
goto :eof