-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-local-embeddings.bat
More file actions
143 lines (116 loc) · 4.77 KB
/
setup-local-embeddings.bat
File metadata and controls
143 lines (116 loc) · 4.77 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
142
143
@echo off
setlocal
echo ===== PSADT Pro UI Local Embeddings Setup =====
echo.
REM Check if Python is installed
python --version >nul 2>&1
if %ERRORLEVEL% NEQ 0 (
echo Python is not installed or not in PATH.
echo Please install Python from https://www.python.org/downloads/
echo Make sure to check "Add Python to PATH" during installation.
exit /b 1
)
echo Python is installed.
echo.
REM Create virtual environment
if not exist .venv (
echo Creating virtual environment...
python -m venv .venv
) else (
echo Virtual environment already exists.
)
REM Activate virtual environment
echo Activating virtual environment...
call .venv\Scripts\activate.bat
REM Install required packages
echo Installing required packages...
pip install -r python-requirements.txt
REM Check for CUDA
echo Checking for CUDA support...
python -c "import torch; print('CUDA available:', torch.cuda.is_available())" > cuda_check.txt
set /p CUDA_AVAILABLE=<cuda_check.txt
del cuda_check.txt
if "%CUDA_AVAILABLE%"=="CUDA available: True" (
echo CUDA is available. Would you like to install PyTorch with CUDA support?
echo This will provide better performance for embedding generation.
choice /C YN /M "Install PyTorch with CUDA support"
if %ERRORLEVEL% EQU 1 (
echo.
echo Detecting CUDA version...
REM Try to detect CUDA version using nvidia-smi
nvidia-smi --query-gpu=driver_version --format=csv,noheader > cuda_version.txt
for /f "delims=" %%a in (cuda_version.txt) do (
set DRIVER_VERSION=%%a
)
del cuda_version.txt
echo NVIDIA Driver Version: %DRIVER_VERSION%
echo.
echo Select CUDA version to install:
echo 1. CUDA 11.7 (For driver version 450.80.02 or higher)
echo 2. CUDA 11.8 (For driver version 450.80.02 or higher)
echo 3. CUDA 12.1 (For driver version 530.30.02 or higher)
choice /C 123 /M "Select CUDA version"
if %ERRORLEVEL% EQU 1 (
echo Installing PyTorch with CUDA 11.7 support...
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117
) else if %ERRORLEVEL% EQU 2 (
echo Installing PyTorch with CUDA 11.8 support...
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
) else if %ERRORLEVEL% EQU 3 (
echo Installing PyTorch with CUDA 12.1 support...
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
)
) else (
echo Skipping CUDA-enabled PyTorch installation.
)
) else (
echo CUDA is not available. Using CPU-only version.
)
echo.
echo Verifying installation...
python -c "import sentence_transformers; import torch; print('All packages installed successfully')"
if %ERRORLEVEL% EQU 0 (
echo.
echo Setting environment variables...
REM Get the full path to the Python executable in the virtual environment
set VENV_PYTHON=%CD%\.venv\Scripts\python.exe
echo Python path: %VENV_PYTHON%
REM Ask if user wants to set system-wide environment variables
echo Would you like to set the PSADT_PYTHON_PATH environment variable?
echo This will help the application find your Python installation.
choice /C YN /M "Set environment variable"
if %ERRORLEVEL% EQU 1 (
choice /C SU /M "Set for [S]ystem (requires admin) or [U]ser only"
if %ERRORLEVEL% EQU 1 (
echo Setting system-wide environment variable (requires admin)...
setx PSADT_PYTHON_PATH "%VENV_PYTHON%" /M
echo Environment variable set for all users.
) else (
echo Setting user environment variable...
setx PSADT_PYTHON_PATH "%VENV_PYTHON%"
echo Environment variable set for current user only.
)
echo To apply this change, you'll need to restart any command prompts or applications.
) else (
echo Skipping environment variable setup.
echo.
echo You can manually set PSADT_PYTHON_PATH to: %VENV_PYTHON%
)
echo.
echo ===== Setup Complete =====
echo The local embedding service is now ready to use.
echo.
echo Next steps:
echo 1. Start the PSADT Pro UI application
echo 2. The application will automatically use the local embedding service
echo.
echo For troubleshooting, refer to LOCAL-EMBEDDINGS-README.md
) else (
echo.
echo ===== Setup Failed =====
echo There was an error installing the required packages.
echo Please check the error messages above and refer to LOCAL-EMBEDDINGS-README.md for troubleshooting.
)
REM Deactivate virtual environment
call .venv\Scripts\deactivate.bat
endlocal