lollms-webui/scripts/windows/lollms_installer.bat

205 lines
6.7 KiB
Batchfile
Raw Permalink Normal View History

2024-09-20 20:45:45 +00:00
@echo off
echo "L🌟LLMS: Lord of Large Language and Multimodal Systems"
2024-11-11 23:43:51 +00:00
echo V14 SaÏf
2024-09-20 20:45:45 +00:00
echo -----------------
echo By ParisNeo
echo -----------------
2024-10-05 23:37:15 +00:00
REM Store the current path
set "ORIGINAL_PATH=%CD%"
2024-09-20 20:45:45 +00:00
2024-10-05 23:37:15 +00:00
cd /D "%~dp0"
2024-09-20 20:45:45 +00:00
2024-10-05 23:37:15 +00:00
echo %CD%
2024-09-20 20:45:45 +00:00
2024-10-07 22:33:55 +00:00
REM Check if Git is installed
where git >nul 2>nul
if %errorlevel% neq 0 (
echo Git is not installed. Downloading and installing Git...
REM Download Git for Windows
powershell -Command "Invoke-WebRequest -Uri 'https://github.com/git-for-windows/git/releases/download/v2.37.1.windows.1/Git-2.37.1-64-bit.exe' -OutFile 'GitInstaller.exe'"
REM Install Git silently
start /wait GitInstaller.exe /VERYSILENT /NORESTART
REM Clean up the installer
del GitInstaller.exe
echo Git has been installed.
) else (
echo Git is already installed.
)
2024-10-06 20:59:17 +00:00
set LOLLMSENV_DIR=%CD%\lollmsenv
2024-10-05 23:37:15 +00:00
set REPO_URL=https://github.com/ParisNeo/lollms-webui.git
2024-09-20 20:45:45 +00:00
2024-10-06 23:41:41 +00:00
set USE_MASTER=0
if "%1"=="--use-master" set USE_MASTER=1
if %USE_MASTER%==1 (
2024-10-07 21:20:14 +00:00
echo --- Using current master repo for LollmsEnv...
2024-10-06 23:41:41 +00:00
git clone https://github.com/ParisNeo/LollmsEnv.git "%LOLLMSENV_DIR%"
cd "%LOLLMSENV_DIR%"
call install.bat --dir "%LOLLMSENV_DIR%" -y
cd ..
) else (
REM Download LollmsEnv installer
echo Downloading LollmsEnv installer...
2024-11-11 23:43:51 +00:00
powershell -Command "Invoke-WebRequest -Uri 'https://github.com/ParisNeo/LollmsEnv/releases/download/V1.4.2/lollmsenv_installer.bat' -OutFile 'lollmsenv_installer.bat'"
2024-10-06 23:41:41 +00:00
REM Install LollmsEnv
2024-10-07 21:51:35 +00:00
echo --- Installing lollmsenv
2024-10-06 23:41:41 +00:00
call lollmsenv_installer.bat --dir "%LOLLMSENV_DIR%" -y
)
2024-09-20 20:45:45 +00:00
2024-10-05 23:37:15 +00:00
REM Check for NVIDIA GPU and CUDA
2024-10-07 21:20:14 +00:00
echo --- Checking for NVIDIA GPU and CUDA...
2024-10-05 23:37:15 +00:00
nvidia-smi >nul 2>&1
if %errorlevel% equ 0 (
echo NVIDIA GPU detected.
echo Querying GPU information...
REM Use a temporary file to store nvidia-smi output
nvidia-smi --query-gpu=name,driver_version,memory.total,utilization.gpu,temperature.gpu --format=csv,noheader,nounits
nvidia-smi --query-gpu=name,driver_version,memory.total,utilization.gpu,temperature.gpu --format=csv,noheader,nounits > gpu_info.txt
REM Read from the temporary file
for /f "tokens=1-5 delims=," %%a in (gpu_info.txt) do (
set "GPU_NAME=%%a"
set "DRIVER_VERSION=%%b"
set "TOTAL_MEMORY=%%c"
set "GPU_UTILIZATION=%%d"
set "GPU_TEMPERATURE=%%e"
)
echo GPU Name: %GPU_NAME%
echo Driver Version: %DRIVER_VERSION%
echo Total Memory: %TOTAL_MEMORY% MiB
echo GPU Utilization: %GPU_UTILIZATION% %%
echo GPU Temperature: %GPU_TEMPERATURE% C
echo Extracting CUDA version...
for /f "tokens=* delims=" %%a in ('nvidia-smi ^| findstr "CUDA Version"') do (
set "CUDA_LINE=%%a"
)
for /f "tokens=3 delims=:" %%a in ("%CUDA_LINE%") do (
set "CUDA_VERSION=%%a"
)
set "CUDA_VERSION=%CUDA_VERSION:~1%"
echo CUDA Version:%CUDA_VERSION%
echo For optimal performance, ensure you have CUDA version 12.1 or higher.
echo If you need to update, visit https://developer.nvidia.com/cuda-downloads
REM Clean up temporary files
del gpu_info.txt
del cuda_version.txt
) else (
echo No NVIDIA GPU detected or nvidia-smi is not available.
2024-09-20 20:45:45 +00:00
)
2024-10-05 23:37:15 +00:00
REM Ask user about CUDA installation
set /p INSTALL_CUDA="Do you want to install CUDA? (Only for NVIDIA GPUs if your version is lower than 12.1 or if it wasn't already installed, recommended for local AI) [Y/N]: "
if /i "%INSTALL_CUDA%"=="Y" (
echo Please visit https://developer.nvidia.com/cuda-downloads to download and install CUDA.
pause
)
2024-09-20 20:45:45 +00:00
2024-10-05 23:37:15 +00:00
REM Ask about Visual Studio Code installation
set /p INSTALL_VSCODE="Do you want to install Visual Studio Code? (Recommended for local AI development) [Y/N]: "
if /i "%INSTALL_VSCODE%"=="Y" (
echo Please visit https://code.visualstudio.com/download to download and install Visual Studio Code.
pause
)
2024-09-20 20:45:45 +00:00
2024-10-07 21:20:14 +00:00
cd %ORIGINAL_PATH%
2024-10-05 23:37:15 +00:00
echo %CD%
2024-09-20 20:45:45 +00:00
2024-10-05 23:37:15 +00:00
REM Install Python and create environment
2024-10-07 21:20:14 +00:00
echo --- creating environment
call "%LOLLMSENV_DIR%\bin\lollmsenv.bat" create-env lollms_env
echo --- activating environment
2024-10-05 23:37:15 +00:00
REM Activate environment
2024-10-07 21:20:14 +00:00
call "%LOLLMSENV_DIR%\envs\lollms_env\Scripts\activate.bat"
echo %ORIGINAL_PATH%
2024-10-06 20:59:17 +00:00
cd "%ORIGINAL_PATH%"
2024-10-07 22:33:55 +00:00
echo --- cloning lollmw_webui
2024-10-07 21:20:14 +00:00
2024-10-05 23:37:15 +00:00
REM Clone or update repository
2024-09-20 20:45:45 +00:00
if exist lollms-webui\ (
2024-10-05 23:37:15 +00:00
cd lollms-webui
git pull
git submodule update --init --recursive
cd ..
2024-09-20 20:45:45 +00:00
) else (
2024-10-05 23:37:15 +00:00
git clone --depth 1 --recurse-submodules %REPO_URL%
cd lollms-webui
git submodule update --init --recursive
cd ..
2024-09-20 20:45:45 +00:00
)
REM Install requirements
2024-10-07 21:20:14 +00:00
echo --- Install requirements
2024-10-05 23:37:15 +00:00
cd lollms-webui
2024-10-07 21:20:14 +00:00
call "%LOLLMSENV_DIR%\envs\lollms_env\Scripts\python.exe" -m pip install -r requirements.txt
call "%LOLLMSENV_DIR%\envs\lollms_env\Scripts\python.exe" -m pip install -e lollms_core
2024-10-05 23:37:15 +00:00
cd ..
2024-09-20 20:45:45 +00:00
REM Create launcher scripts
2024-10-07 21:20:14 +00:00
echo @echo off > lollms.bat
2024-11-03 01:22:10 +00:00
echo call ".\lollmsenv\envs\lollms_env\Scripts\activate.bat" >> lollms.bat
2024-10-07 21:20:14 +00:00
echo cd lollms-webui >> lollms.bat
echo python app.py %%* >> lollms.bat
echo pause >> lollms.bat
echo @echo off > lollms_cmd.bat
2024-11-03 01:22:10 +00:00
echo call ".\lollmsenv\envs\lollms_env\Scripts\activate.bat" >> lollms_cmd.bat
2024-10-07 21:20:14 +00:00
echo cd lollms-webui >> lollms_cmd.bat
echo cmd /k >> lollms_cmd.bat
2024-10-07 22:33:55 +00:00
cd lollms-webui
echo --- current folder !cd!
2024-09-20 20:45:45 +00:00
REM Binding selection menu
echo Select the default binding to be installed:
echo 1) None (install the binding later)
echo 2) Local binding - ollama
echo 3) Local binding - python_llama_cpp
echo 4) Local binding - bs_exllamav2
echo 5) Remote binding - groq
echo 6) Remote binding - open_router
echo 7) Remote binding - open_ai
echo 8) Remote binding - mistral_ai
echo 9) Remote binding - gemini
echo 10) Remote binding - vllm
echo 11) Remote binding - xAI
echo 12) Remote binding - elf
echo 13) Remote binding - remote lollms
set /p choice="Type the number of your choice and press Enter: "
2024-10-05 23:37:15 +00:00
REM Binding installation logic
if "%choice%"=="1" goto :end
if "%choice%"=="2" call python zoos/bindings_zoo/ollama/__init__.py
if "%choice%"=="3" call python zoos/bindings_zoo/python_llama_cpp/__init__.py
if "%choice%"=="4" call python zoos/bindings_zoo/bs_exllamav2/__init__.py
if "%choice%"=="5" call python zoos/bindings_zoo/groq/__init__.py
if "%choice%"=="6" call python zoos/bindings_zoo/open_router/__init__.py
if "%choice%"=="7" call python zoos/bindings_zoo/open_ai/__init__.py
if "%choice%"=="8" call python zoos/bindings_zoo/mistral_ai/__init__.py
if "%choice%"=="9" call python zoos/bindings_zoo/gemini/__init__.py
if "%choice%"=="10" call python zoos/bindings_zoo/vllm/__init__.py
if "%choice%"=="11" call python zoos/bindings_zoo/xAI/__init__.py
if "%choice%"=="12" call python zoos/bindings_zoo/elf/__init__.py
if "%choice%"=="13" call python zoos/bindings_zoo/remote_lollms/__init__.py
2024-09-20 20:45:45 +00:00
:end
echo Installation complete.
2024-10-05 23:37:15 +00:00
REM Restore the original path
cd /D "%ORIGINAL_PATH%"
echo Restored to original path: %CD%
2024-09-20 20:45:45 +00:00
pause