From 3ff9cb19b25ae052ba29ac0b04441c2f7c4ead12 Mon Sep 17 00:00:00 2001 From: Juste-Leo Date: Fri, 3 Oct 2025 16:14:02 +0200 Subject: [PATCH 1/2] installation scripts with CPU Signed-off-by: Juste-Leo --- run_localAI.bat | 50 +++++++++++++++++++++++++++++++ setup_localAI_win.bat | 69 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 run_localAI.bat create mode 100644 setup_localAI_win.bat diff --git a/run_localAI.bat b/run_localAI.bat new file mode 100644 index 000000000000..79c54c8b68a6 --- /dev/null +++ b/run_localAI.bat @@ -0,0 +1,50 @@ +@echo off +setlocal +chcp 65001 > nul + +set "DISTRO_NAME=Ubuntu" +set "PORT=8080" + +echo [INFO] Starting LocalAI server via WSL +echo. + +:: ================================================================== +:: STEP 1/2 : PREPARING LAUNCH +:: ================================================================== +echo [STEP 1/2] Preparing to launch + +:: Get WSL username to build the path +for /f %%i in ('wsl -d %DISTRO_NAME% -- whoami') do set "WSL_USER=%%i" + +set "MODELS_DIR_WSL_NATIVE=/home/%WSL_USER%/models" + +echo [INFO] Models will be loaded from the WSL folder: %MODELS_DIR_WSL_NATIVE% +echo [INFO] To manage your models use the '_Access_Models_Folder' shortcut +echo. + +:: Get WSL IP address for connection +for /f "tokens=2 delims=/ " %%i in ('wsl -d %DISTRO_NAME% -- ip addr show eth0 ^| findstr /r /c:"^ *inet "') do ( + set "WSL_IP=%%i" +) + +echo [IMPORTANT] Once started the server will be accessible at this address +echo. +echo http://%WSL_IP%:%PORT% +echo. +echo [INFO] To stop the server press CTRL + C in this window +echo. +pause + +:: ================================================================== +:: STEP 2/2 : LAUNCHING THE SERVER +:: ================================================================== +echo [STEP 2/2] Launching the LocalAI server + +set "CMD_TO_RUN=local-ai --models-path "%MODELS_DIR_WSL_NATIVE%" --address 0.0.0.0:%PORT% --context-size 700" + +wsl -d %DISTRO_NAME% -- bash -c "%CMD_TO_RUN%" + +echo. +echo [INFO] The LocalAI server has been stopped +pause +exit /b 0 \ No newline at end of file diff --git a/setup_localAI_win.bat b/setup_localAI_win.bat new file mode 100644 index 000000000000..9dc2f150d45e --- /dev/null +++ b/setup_localAI_win.bat @@ -0,0 +1,69 @@ +@echo off +setlocal +chcp 65001 > nul + +set "DISTRO_NAME=Ubuntu" + +echo [INFO] Starting LocalAI environment setup +echo. + +:: ================================================================== +:: STEP 1/3 : WSL/UBUNTU INSTALLATION +:: ================================================================== +echo [STEP 1/3] Attempting to install WSL distribution '%DISTRO_NAME%' +echo [INFO] If '%DISTRO_NAME%' is already installed this step will be skipped +echo [IMPORTANT] THIS STEP MAY REQUIRE ADMINISTRATOR PRIVILEGES +pause + +wsl --install -d %DISTRO_NAME% + +echo [INFO] Assuming installation was successful continuing + +:: ================================================================== +:: STEP 2/3 : INSTALLING TOOLS IN WSL +:: ================================================================== +echo. +echo [STEP 2/3] Installing LocalAI and required tools in WSL + +echo [INFO] Updating packages and installing 'curl' +wsl -d %DISTRO_NAME% -- bash -c "sudo apt-get update && sudo apt-get install -y curl" + +echo [INFO] Running the official LocalAI installation script +set "INSTALL_COMMAND=curl -L https://localai.io/install.sh -o /tmp/install.sh && DOCKER_INSTALL="false" bash /tmp/install.sh" +wsl -d %DISTRO_NAME% -- bash -c "%INSTALL_COMMAND%" + +if %ERRORLEVEL% neq 0 ( + echo [ERROR] LocalAI installation failed + pause + exit /b 1 +) + +echo [INFO] Disabling background service for manual control +wsl -d %DISTRO_NAME% -u root -- bash -c "systemctl stop local-ai.service && systemctl disable local-ai.service" >nul 2>nul + +:: ================================================================== +:: STEP 3/3 : CREATING FOLDERS AND SHORTCUT +:: ================================================================== +echo. +echo [STEP 3/3] Creating folder structure and access shortcut + +for /f %%i in ('wsl -d %DISTRO_NAME% -- whoami') do set "WSL_USER=%%i" + +echo [INFO] Creating 'models' folder in the WSL environment +wsl -d %DISTRO_NAME% -- bash -c "mkdir -p '/home/%WSL_USER%/models'" + +set "TARGET_FOLDER=\\wsl$\%DISTRO_NAME%\home\%WSL_USER%\models" +set "SHORTCUT_PATH=%~dp0_Access_Models_Folder.lnk" + +echo [INFO] Creating a shortcut for easy access to the models folder +:: This new method creates a shortcut that opens the folder path with explorer.exe +:: It is more reliable than pointing directly to a WSL path +powershell -Command "$ws = New-Object -ComObject WScript.Shell; $s = $ws.CreateShortcut('%SHORTCUT_PATH%'); $s.TargetPath = 'explorer.exe'; $s.Arguments = '%TARGET_FOLDER%'; $s.Save()" + +echo. +echo [SUCCESS] Installation finished +echo [IMPORTANT] A shortcut '_Access_Models_Folder' has been created in this directory +echo [IMPORTANT] Use this shortcut to add and manage your model files +echo [IMPORTANT] You can now run 'run_localAI.bat' +echo. +pause \ No newline at end of file From a6f5d19717b166d63c07adcabe79a56c23c88fb7 Mon Sep 17 00:00:00 2001 From: Juste-Leo Date: Fri, 3 Oct 2025 16:15:22 +0200 Subject: [PATCH 2/2] installation scripts with CPU Signed-off-by: Juste-Leo --- run_localAI.bat => run_localAI_win.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename run_localAI.bat => run_localAI_win.bat (96%) diff --git a/run_localAI.bat b/run_localAI_win.bat similarity index 96% rename from run_localAI.bat rename to run_localAI_win.bat index 79c54c8b68a6..3ff711f1e6f7 100644 --- a/run_localAI.bat +++ b/run_localAI_win.bat @@ -47,4 +47,4 @@ wsl -d %DISTRO_NAME% -- bash -c "%CMD_TO_RUN%" echo. echo [INFO] The LocalAI server has been stopped pause -exit /b 0 \ No newline at end of file +exit /b 0