Remove the WSL installation scripts

They were useful in 2023 but now everything runs natively on Windows.
This commit is contained in:
oobabooga 2025-04-26 05:00:37 -07:00
parent 763a7011c0
commit b976112539
8 changed files with 3 additions and 297 deletions

View file

@ -101,7 +101,7 @@ jobs:
- name: Build Package
shell: bash
run: |
rm -rf .git cmd* update_wizard* start_wsl.bat wsl.sh Colab-TextGen-GPU.ipynb docker
rm -rf .git cmd* update_wizard* Colab-TextGen-GPU.ipynb docker
# Define common variables
CUDA_VERSION="${{ matrix.cuda }}"

View file

@ -100,7 +100,7 @@ jobs:
- name: Build Package
shell: bash
run: |
rm -rf .git cmd* update_wizard* start_wsl.bat wsl.sh Colab-TextGen-GPU.ipynb docker
rm -rf .git cmd* update_wizard* Colab-TextGen-GPU.ipynb docker
# Define common variables
AVX_SUPPORT="${{ matrix.avx }}"

View file

@ -100,7 +100,7 @@ jobs:
- name: Build Package
shell: bash
run: |
rm -rf .git cmd* update_wizard* start_wsl.bat wsl.sh Colab-TextGen-GPU.ipynb docker
rm -rf .git cmd* update_wizard* Colab-TextGen-GPU.ipynb docker
# Define common variables
AVX_SUPPORT="${{ matrix.avx }}"

View file

@ -1,11 +0,0 @@
@echo off
cd /D "%~dp0"
set PATH=%PATH%;%SystemRoot%\system32
@rem sed -i 's/\x0D$//' ./wsl.sh converts newlines to unix format in the wsl script
call wsl -e bash -lic "sed -i 's/\x0D$//' ./wsl.sh; source ./wsl.sh cmd"
:end
pause

View file

@ -1,146 +0,0 @@
## WSL instructions
If you do not have WSL installed, follow the [instructions below](https://github.com/oobabooga/text-generation-webui/wiki/10-%E2%80%90-WSL#wsl-installation) first.
### Additional WSL setup info
If you want to install Linux to a drive other than C, open powershell and enter these commands:
```
cd D:\Path\To\Linux
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri <LinuxDistroURL> -OutFile Linux.appx -UseBasicParsing
mv Linux.appx Linux.zip
```
Then open Linux.zip and you should see several .appx files inside.
The one with _x64.appx contains the exe installer that you need.
Extract the contents of that _x64.appx file and run <distro>.exe to install.
Linux Distro URLs: https://learn.microsoft.com/en-us/windows/wsl/install-manual#downloading-distributions
**ENSURE THAT THE WSL LINUX DISTRO THAT YOU WISH TO USE IS SET AS THE DEFAULT!**
Do this by using these commands:
```
wsl -l
wsl -s <DistroName>
```
### Web UI Installation
Run the "start" script. By default it will install the web UI in WSL:
/home/{username}/text-gen-install
To launch the web UI in the future after it is already installed, run
the same "start" script. Ensure that one_click.py and wsl.sh are next to it!
### Updating the web UI
As an alternative to running the "update" script, you can also run "wsl.sh update" in WSL.
### Running an interactive shell
As an alternative to running the "cmd" script, you can also run "wsl.sh cmd" in WSL.
### Changing the default install location
To change this, you will need to edit the scripts as follows:
wsl.sh: line ~22 INSTALL_DIR="/path/to/install/dir"
Keep in mind that there is a long-standing bug in WSL that significantly
slows drive read/write speeds when using a physical drive as opposed to
the virtual one that Linux is installed in.
## WSL installation
Guide created by [@jfryton](https://github.com/jfryton). Thank you jfryton.
-----
Here's an easy-to-follow, step-by-step guide for installing Windows Subsystem for Linux (WSL) with Ubuntu on Windows 10/11:
### Step 1: Enable WSL
1. Press the Windows key + X and click on "Windows PowerShell (Admin)" or "Windows Terminal (Admin)" to open PowerShell or Terminal with administrator privileges.
2. In the PowerShell window, type the following command and press Enter:
```
wsl --install
```
If this command doesn't work, you can enable WSL with the following command for Windows 10:
```
wsl --set-default-version 1
```
For Windows 11, you can use:
```
wsl --set-default-version 2
```
You may be prompted to restart your computer. If so, save your work and restart.
### Step 2: Install Ubuntu
1. Open the Microsoft Store.
2. Search for "Ubuntu" in the search bar.
3. Choose the desired Ubuntu version (e.g., Ubuntu 20.04 LTS) and click "Get" or "Install" to download and install the Ubuntu app.
4. Once the installation is complete, click "Launch" or search for "Ubuntu" in the Start menu and open the app.
### Step 3: Set up Ubuntu
1. When you first launch the Ubuntu app, it will take a few minutes to set up. Be patient as it installs the necessary files and sets up your environment.
2. Once the setup is complete, you will be prompted to create a new UNIX username and password. Choose a username and password, and make sure to remember them, as you will need them for future administrative tasks within the Ubuntu environment.
### Step 4: Update and upgrade packages
1. After setting up your username and password, it's a good idea to update and upgrade your Ubuntu system. Run the following commands in the Ubuntu terminal:
```
sudo apt update
sudo apt upgrade
```
2. Enter your password when prompted. This will update the package list and upgrade any outdated packages.
Congratulations! You have now installed WSL with Ubuntu on your Windows 10/11 system. You can use the Ubuntu terminal for various tasks, like running Linux commands, installing packages, or managing files.
You can launch your WSL Ubuntu installation by selecting the Ubuntu app (like any other program installed on your computer) or typing 'ubuntu' into Powershell or Terminal.
### Step 5: Proceed with Linux instructions
1. You can now follow the Linux setup instructions. If you receive any error messages about a missing tool or package, just install them using apt:
```
sudo apt install [missing package]
```
You will probably need to install build-essential
```
sudo apt install build-essential
```
If you face any issues or need to troubleshoot, you can always refer to the official Microsoft documentation for WSL: https://docs.microsoft.com/en-us/windows/wsl/
### WSL2 performance using /mnt:
When you git clone a repository, put it inside WSL and not outside. To understand more, take a look at this [issue](https://github.com/microsoft/WSL/issues/4197#issuecomment-604592340)
### Bonus: Port Forwarding
By default, you won't be able to access the webui from another device on your local network. You will need to setup the appropriate port forwarding using the following steps:
1. First, get the IP address of the WSL by typing `wsl hostname -I`. This will output the IP address, for example `172.20.134.111`.
2. Then, use the following command (using PowerShell or Terminal with administrator privileges) to set up port forwarding, replacing `172.20.134.111` with the IP address you obtained in step 1:
```
netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=7860 connectaddress=172.20.134.111 connectport=7860
```

View file

@ -1,11 +0,0 @@
@echo off
cd /D "%~dp0"
set PATH=%PATH%;%SystemRoot%\system32
@rem sed -i 's/\x0D$//' ./wsl.sh converts newlines to unix format in the wsl script
call wsl -e bash -lic "sed -i 's/\x0D$//' ./wsl.sh; source ./wsl.sh %*"
:end
pause

View file

@ -1,11 +0,0 @@
@echo off
cd /D "%~dp0"
set PATH=%PATH%;%SystemRoot%\system32
@rem sed -i 's/\x0D$//' ./wsl.sh converts newlines to unix format in the wsl script calling wsl.sh with 'update' will run updater
call wsl -e bash -lic "sed -i 's/\x0D$//' ./wsl.sh; source ./wsl.sh update-wizard"
:end
pause

115
wsl.sh
View file

@ -1,115 +0,0 @@
#!/bin/bash
# detect if build-essential is missing or broken
if ! dpkg-query -W -f'${Status}' "build-essential" 2>/dev/null | grep -q "ok installed"; then
echo "build-essential not found or broken!
A C++ compiler is required to build needed Python packages!
To install one, run cmd_wsl.bat and enter these commands:
sudo apt-get update
sudo apt-get install build-essential
"
read -n1 -p "Continue the installer anyway? [y,n]" EXIT_PROMPT
# only continue if user inputs 'y' else exit
if ! [[ $EXIT_PROMPT == "Y" || $EXIT_PROMPT == "y" ]]; then exit; fi
fi
# deactivate existing conda envs as needed to avoid conflicts
{ conda deactivate && conda deactivate && conda deactivate; } 2> /dev/null
# config unlike other scripts, can't use current directory due to file IO bug in WSL, needs to be in virtual drive
INSTALL_DIR_PREFIX="$HOME/text-gen-install"
if [[ ! $(realpath "$(pwd)/..") = /mnt/* ]]; then
INSTALL_DIR_PREFIX="$(realpath "$(pwd)/..")" && INSTALL_INPLACE=1
fi
INSTALL_DIR="$INSTALL_DIR_PREFIX/text-generation-webui"
CONDA_ROOT_PREFIX="$INSTALL_DIR/installer_files/conda"
INSTALL_ENV_DIR="$INSTALL_DIR/installer_files/env"
MINICONDA_DOWNLOAD_URL="https://repo.anaconda.com/miniconda/Miniconda3-py311_24.11.1-0-Linux-x86_64.sh"
conda_exists="F"
# environment isolation
export PYTHONNOUSERSITE=1
unset PYTHONPATH
unset PYTHONHOME
export CUDA_PATH="$INSTALL_ENV_DIR"
export CUDA_HOME="$CUDA_PATH"
# /usr/lib/wsl/lib needs to be added to LD_LIBRARY_PATH to fix years-old bug in WSL where GPU drivers aren't linked properly
export LD_LIBRARY_PATH="$CUDA_HOME/lib:/usr/lib/wsl/lib:$LD_LIBRARY_PATH"
# open bash cli if called with 'wsl.sh cmd' with workarounds for existing conda
if [ "$1" == "cmd" ]; then
exec bash --init-file <(echo ". ~/.bashrc; conda deactivate 2> /dev/null; cd $INSTALL_DIR || cd $HOME; source $CONDA_ROOT_PREFIX/etc/profile.d/conda.sh; conda activate $INSTALL_ENV_DIR")
exit
fi
if [[ "$INSTALL_DIR" =~ " " ]]; then echo This script relies on Miniconda which can not be silently installed under a path with spaces. && exit; fi
# create install dir if missing
if [ ! -d "$INSTALL_DIR" ]; then mkdir -p "$INSTALL_DIR" || exit; fi
# figure out whether git and conda needs to be installed
if "$CONDA_ROOT_PREFIX/bin/conda" --version &>/dev/null; then conda_exists="T"; fi
# (if necessary) install git and conda into a contained environment
# download miniconda
if [ "$conda_exists" == "F" ]; then
echo "Downloading Miniconda from $MINICONDA_DOWNLOAD_URL to $INSTALL_DIR/miniconda_installer.sh"
curl -L "$MINICONDA_DOWNLOAD_URL" > "$INSTALL_DIR/miniconda_installer.sh"
chmod u+x "$INSTALL_DIR/miniconda_installer.sh"
bash "$INSTALL_DIR/miniconda_installer.sh" -b -p $CONDA_ROOT_PREFIX
# test the conda binary
echo "Miniconda version:"
"$CONDA_ROOT_PREFIX/bin/conda" --version
# delete the Miniconda installer
rm "$INSTALL_DIR/miniconda_installer.sh"
fi
# create the installer env
if [ ! -e "$INSTALL_ENV_DIR" ]; then
"$CONDA_ROOT_PREFIX/bin/conda" create -y -k --prefix "$INSTALL_ENV_DIR" python=3.11 git
fi
# check if conda environment was actually created
if [ ! -e "$INSTALL_ENV_DIR/bin/python" ]; then
echo "Conda environment is empty."
exit
fi
# activate installer env
source "$CONDA_ROOT_PREFIX/etc/profile.d/conda.sh" # otherwise conda complains about 'shell not initialized' (needed when running in a script)
conda activate "$INSTALL_ENV_DIR"
pushd $INSTALL_DIR 1> /dev/null || exit
if [ ! -f "./server.py" ]; then
git init -b main
git remote add origin https://github.com/oobabooga/text-generation-webui
git fetch
git remote set-head origin -a
git reset origin/HEAD --hard
git branch --set-upstream-to=origin/HEAD
git restore -- . :!./CMD_FLAGS.txt
fi
# copy CMD_FLAGS.txt to install dir to allow edits within Windows
if [[ $INSTALL_INPLACE != 1 ]]; then
# workaround for old install migration
if [ ! -f "./wsl.sh" ]; then
git pull || exit
[ -f "../webui.py" ] && mv "../webui.py" "../webui-old.py"
fi
if [ -f "$(dirs +1)/CMD_FLAGS.txt" ] && [ -f "./CMD_FLAGS.txt" ]; then cp -u "$(dirs +1)/CMD_FLAGS.txt" "$INSTALL_DIR"; fi
fi
# setup installer env update env if called with 'wsl.sh update'
case "$1" in
("update-wizard") python one_click.py --update-wizard;;
(*) python one_click.py $@;;
esac