lollms-webui/scripts/linux/linux_install.sh

171 lines
5.1 KiB
Bash
Raw Normal View History

2023-07-12 13:01:20 +00:00
#!/bin/bash
# This script will install miniconda and git with all dependencies for this project
# This enables a user to install this project without manually installing conda and git.
2024-01-04 02:57:42 +00:00
echo " ___ ___ ___ ___ ___ ___ "
echo " /\__\ /\ \ /\__\ /\__\ /\__\ /\ \ "
echo " /:/ / /::\ \ /:/ / /:/ / /::| | /::\ \ "
echo " /:/ / /:/\:\ \ /:/ / /:/ / /:|:| | /:/\ \ \ "
echo " /:/ / /:/ \:\ \ /:/ / /:/ / /:/|:|__|__ _\:\~\ \ \ "
echo " /:/__/ /:/__/ \:\__\ /:/__/ /:/__/ /:/ |::::\__\ /\ \:\ \ \__\ "
echo " \:\ \ \:\ \ /:/ / \:\ \ \:\ \ \/__/~~/:/ / \:\ \:\ \/__/ "
echo " \:\ \ \:\ /:/ / \:\ \ \:\ \ /:/ / \:\ \:\__\ "
echo " \:\ \ \:\/:/ / \:\ \ \:\ \ /:/ / \:\/:/ / "
echo " \:\__\ \::/ / \:\__\ \:\__\ /:/ / \::/ / "
echo " \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ "
2024-01-29 19:42:49 +00:00
echo "V9.5"
2024-01-04 02:57:42 +00:00
echo "-----------------"
echo "By ParisNeo"
echo "-----------------"
2023-07-12 13:01:20 +00:00
cd "$(dirname "$0")"
if [[ "$PWD" == *" "* ]]; then
echo "This script relies on Miniconda which cannot be silently installed under a path with spaces."
exit 1
fi
echo "WARNING: This script relies on Miniconda which will fail to install if the path is too long."
if [[ "$PWD" =~ [^#\$\%\&\(\)\*\+\] ]]; then
echo "WARNING: Special characters were detected in the installation path!"
echo " This can cause the installation to fail!"
fi
2024-01-04 13:17:41 +00:00
export PACKAGES_TO_INSTALL=python=3.11 git pip
2023-07-12 13:01:20 +00:00
read -rp "Press Enter to continue..."
clear
2024-01-04 02:57:42 +00:00
2023-07-12 13:01:20 +00:00
# Better isolation for virtual environment
unset CONDA_SHLVL
export PYTHONNOUSERSITE=1
unset PYTHONPATH
unset PYTHONHOME
export TEMP="$PWD/installer_files/temp"
export TMP="$PWD/installer_files/temp"
MINICONDA_DIR="$PWD/installer_files/miniconda3"
2023-07-12 15:02:35 +00:00
INSTALL_ENV_DIR="$PWD/installer_files/lollms_env"
2023-07-12 13:01:20 +00:00
MINICONDA_DOWNLOAD_URL="https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh"
REPO_URL="https://github.com/ParisNeo/lollms-webui.git"
if [ ! -f "$MINICONDA_DIR/Scripts/conda" ]; then
# Download miniconda
echo "Downloading Miniconda installer from $MINICONDA_DOWNLOAD_URL"
2024-02-19 08:06:25 +00:00
curl -LO "$MINICONDA_DOWNLOAD_URL"
2023-07-12 13:01:20 +00:00
# Install miniconda
echo
echo "Installing Miniconda to $MINICONDA_DIR"
echo "Please wait..."
echo
bash "Miniconda3-latest-Linux-x86_64.sh" -b -p "$MINICONDA_DIR" || ( echo && echo "Miniconda installer not found." && exit 1 )
rm -f "Miniconda3-latest-Linux-x86_64.sh"
if [ ! -f "$MINICONDA_DIR/bin/activate" ]; then
echo && echo "Miniconda install failed." && exit 1
fi
fi
# Activate miniconda
source "$MINICONDA_DIR/bin/activate" || ( echo "Miniconda hook not found." && exit 1 )
# Create the installer environment
if [ ! -d "$INSTALL_ENV_DIR" ]; then
echo "Packages to install: $PACKAGES_TO_INSTALL"
2023-07-12 15:02:35 +00:00
conda create -y -k -p "$INSTALL_ENV_DIR" $CHANNEL $PACKAGES_TO_INSTALL || ( echo && echo "Conda environment creation failed." && exit 1 )
2023-07-12 13:01:20 +00:00
fi
# Check if conda environment was actually created
if [ ! -x "$INSTALL_ENV_DIR/bin/python" ]; then
echo && echo "Conda environment is empty." && exit 1
fi
# Activate installer environment
source activate "$INSTALL_ENV_DIR" || ( echo && echo "Conda environment activation failed." && exit 1 )
2024-02-01 22:30:31 +00:00
# install conda
conda install conda -y
2023-07-12 13:01:20 +00:00
# Set default cuda toolkit to the one in the environment
export CUDA_PATH="$INSTALL_ENV_DIR"
2024-01-06 10:05:02 +00:00
2023-07-12 13:01:20 +00:00
# Clone the repository
if [ -d "lollms-webui" ]; then
cd lollms-webui || exit 1
git pull
2024-01-04 02:57:42 +00:00
git submodule update --init --recursive
2024-01-10 20:22:17 +00:00
cd lollms_core
2024-01-04 02:57:42 +00:00
pip install -e .
cd ..
2024-01-04 13:17:41 +00:00
cd utilities/safe_store
2024-01-04 02:57:42 +00:00
pip install -e .
2024-01-04 13:17:41 +00:00
cd ../..
2024-04-21 17:11:06 +00:00
cd utilities/pipmaster
pip install -e .
cd ../..
2024-01-04 02:57:42 +00:00
2023-07-12 13:01:20 +00:00
else
2024-01-04 02:57:42 +00:00
git clone --depth 1 --recurse-submodules "$REPO_URL"
git submodule update --init --recursive
2024-01-04 13:17:41 +00:00
cd lollms-webui/lollms_core
2024-01-04 02:57:42 +00:00
pip install -e .
cd ..
2024-01-04 13:17:41 +00:00
cd utilities/safe_store
2024-01-04 02:57:42 +00:00
pip install -e .
2024-01-04 13:17:41 +00:00
cd ../..
2023-07-12 13:01:20 +00:00
fi
2023-07-12 13:01:20 +00:00
# Loop through each "git+" requirement and uninstall it (workaround for inconsistent git package updating)
while IFS= read -r requirement; do
if echo "$requirement" | grep -q "git+"; then
package_name=$(echo "$requirement" | awk -F'/' '{ print $4 }' | awk -F'@' '{ print $1 }')
python -m pip uninstall -y "$package_name"
fi
done < requirements.txt
# Install the pip requirements
python -m pip install -r requirements.txt --upgrade
2023-07-12 13:01:20 +00:00
2023-07-12 15:02:35 +00:00
if [[ -e "../linux_run.sh" ]]; then
echo "Linux run found"
else
2023-10-17 19:40:52 +00:00
cp scripts/linux/linux_run.sh ../
2023-07-12 15:02:35 +00:00
fi
2023-07-15 21:08:19 +00:00
2023-08-31 06:42:13 +00:00
if [[ -e "../linux_conda_session.sh" ]]; then
echo "Linux update found"
else
2023-10-17 19:40:52 +00:00
cp scripts/linux/linux_conda_session.sh ../
2023-08-31 06:42:13 +00:00
fi
2024-01-04 02:57:42 +00:00
2024-01-08 00:08:47 +00:00
# cd scripts/python/lollms_installer
# python main.py
# cd ..
2024-01-09 00:15:51 +00:00
echo "Creating a bin dir (required for llamacpp binding)"
2024-03-23 19:14:26 +00:00
mkdir -p $INSTALL_ENV_DIR/bin
2024-01-09 00:15:51 +00:00
2023-07-20 15:28:58 +00:00
2023-07-12 13:01:20 +00:00
PrintBigMessage() {
echo
echo "*******************************************************************"
for message in "$@"; do
echo "* $message"
done
echo "*******************************************************************"
echo
}
PrintBigMessage "$@"
2023-08-31 01:05:38 +00:00
exit 0