2023-07-21 13:38:45 +00:00
#!/bin/bash
2024-05-05 22:22:40 +00:00
# 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-05-10 01:21:55 +00:00
#
# Introdusing Versions so can troubleshoot problems with script faster
# Version: 2.2
2023-07-21 13:38:45 +00:00
2024-01-04 02:57:42 +00:00
echo " ___ ___ ___ ___ ___ ___ "
echo " /\__\ /\ \ /\__\ /\__\ /\__\ /\ \ "
echo " /:/ / /::\ \ /:/ / /:/ / /::| | /::\ \ "
echo " /:/ / /:/\:\ \ /:/ / /:/ / /:|:| | /:/\ \ \ "
echo " /:/ / /:/ \:\ \ /:/ / /:/ / /:/|:|__|__ _\:\~\ \ \ "
echo " /:/__/ /:/__/ \:\__\ /:/__/ /:/__/ /:/ |::::\__\ /\ \:\ \ \__\ "
echo " \:\ \ \:\ \ /:/ / \:\ \ \:\ \ \/__/~~/:/ / \:\ \:\ \/__/ "
echo " \:\ \ \:\ /:/ / \:\ \ \:\ \ /:/ / \:\ \:\__\ "
echo " \:\ \ \:\/:/ / \:\ \ \:\ \ /:/ / \:\/:/ / "
echo " \:\__\ \::/ / \:\__\ \:\__\ /:/ / \::/ / "
echo " \/__/ \/__/ \/__/ \/__/ \/__/ \/__/ "
2024-09-01 01:37:49 +00:00
echo "V12"
2024-01-04 02:57:42 +00:00
echo "-----------------"
echo "By ParisNeo"
echo "-----------------"
2023-07-21 13:38:45 +00:00
cd " $( dirname " $0 " ) "
if [ [ " $PWD " = = *" " * ] ] ; then
2024-05-05 22:22:40 +00:00
echo ""
2023-07-21 13:38:45 +00:00
echo "This script relies on Miniconda, which cannot be silently installed under a path with spaces."
exit 1
fi
2024-05-05 22:22:40 +00:00
echo ""
2023-07-21 13:38:45 +00:00
echo "WARNING: This script relies on Miniconda, which will fail to install if the path is too long."
if [ [ " $PWD " = ~ [ ^#\$ \% \& \( \) \* \+ \] ] ] ; then
2024-05-05 22:22:40 +00:00
echo ""
2023-07-21 13:38:45 +00:00
echo "WARNING: Special characters were detected in the installation path!"
echo " This can cause the installation to fail!"
fi
read -rp "Press Enter to continue..."
clear
2024-01-04 02:57:42 +00:00
2024-01-04 13:17:41 +00:00
export PACKAGES_TO_INSTALL = python = 3.11 git pip
2023-07-21 13:38:45 +00:00
2024-05-05 22:22:40 +00:00
# This will test if homebrew is installed on the mac.
# If not installed it will install homebrew.
echo "*****************************************************"
echo "*** Homebriew is required for LoLLMs Install ***"
echo "*** Checking if Homebrew is installed ***"
echo "*** ***"
which -s brew
if [ [ $? != 0 ] ] ; then
# Install Homebrew
echo "*** Please Install Homebrew - See https://brew.sh ***"
echo "*****************************************************"
exit 1
else
echo "*** Homebrew is installed - Continuing ***"
echo "*** ***"
fi
# This will test if GCC is installed.
# If GCC is installed it will attempt an upgrade
# if it is not installed it will install gcc using homebrew
echo "*** Checking if GCC is installed ***"
echo "*** ***"
if brew list gcc & >/dev/null; then
echo "*** GCC is already installed - Upgrading ***"
echo "*****************************************************"
else
echo "*** GCC Not Installed - Installing ***"
echo "*****************************************************"
brew install gcc
fi
2023-10-19 21:30:18 +00:00
2023-07-21 13:38:45 +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 "
2024-05-05 22:22:40 +00:00
INSTALL_DIR = " $PWD "
2023-07-21 13:38:45 +00:00
INSTALL_ENV_DIR = " $PWD /installer_files/lollms_env "
2023-10-19 21:30:18 +00:00
ENV_NAME = "lollms"
2024-01-04 02:57:42 +00:00
arch = $( uname -m)
if [ " $arch " = = "arm64" ] ; then
MINICONDA_DOWNLOAD_URL = "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-arm64.sh"
else
MINICONDA_DOWNLOAD_URL = "https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh"
fi
2023-07-21 13:38:45 +00:00
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:44 +00:00
curl -LO " $MINICONDA_DOWNLOAD_URL "
2023-07-21 13:38:45 +00:00
# Install Miniconda
echo
echo " Installing Miniconda to $MINICONDA_DIR "
echo "Please wait..."
echo
2024-01-04 21:33:43 +00:00
if [ " $arch " = = "arm64" ] ; then
bash "Miniforge3-MacOSX-arm64.sh" -b -p " $MINICONDA_DIR " || ( echo && echo "Miniconda installer not found." && exit 1 )
rm -f "Miniforge3-MacOSX-arm64.sh"
if [ ! -f " $MINICONDA_DIR /bin/activate " ] ; then
echo && echo "Miniconda install failed." && exit 1
fi
else
bash "Miniconda3-latest-MacOSX-x86_64.sh" -b -p " $MINICONDA_DIR " || ( echo && echo "Miniconda installer not found." && exit 1 )
rm -f "Miniconda3-latest-MacOSX-x86_64.sh"
if [ ! -f " $MINICONDA_DIR /bin/activate " ] ; then
echo && echo "Miniconda install failed." && exit 1
fi
2023-07-21 13:38:45 +00:00
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-10-19 21:30:18 +00:00
conda create -y -k -n " $ENV_NAME " $CHANNEL $PACKAGES_TO_INSTALL || ( echo && echo "Conda environment creation failed." && exit 1 )
echo " Conda created and using packages: $PACKAGES_TO_INSTALL "
2023-07-21 13:38:45 +00:00
fi
# Activate installer environment
2023-10-19 21:30:18 +00:00
source activate " $ENV_NAME " || ( echo && echo "Conda environment activation failed." && exit 1 )
2023-07-21 13:38:45 +00:00
2024-02-01 22:30:31 +00:00
# install conda
conda install conda -y
2024-09-14 23:37:41 +00:00
#Install pytorch (required for RAG)
echo "Installing pytorch (required for RAG)"
pip install torch torchvision torchaudio
2023-10-19 21:30:18 +00:00
echo " $ENV_NAME Activated "
2023-07-21 13:38:45 +00:00
# Set default CUDA toolkit to the one in the environment
export CUDA_PATH = " $INSTALL_ENV_DIR "
# Clone the repository
2024-05-05 22:22:40 +00:00
cd $INSTALL_DIR
2023-07-21 13:38:45 +00:00
if [ -d "lollms-webui" ] ; then
2024-05-05 22:22:40 +00:00
cd $INSTALL_DIR /lollms-webui || exit 1
2023-07-21 13:38:45 +00:00
git pull
2024-01-04 02:57:42 +00:00
git submodule update --init --recursive
2024-05-05 22:22:40 +00:00
cd $INSTALL_DIR /lollms-webui/lollms_core
2024-01-04 02:57:42 +00:00
pip install -e .
2023-07-21 13:38:45 +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-05-05 22:22:40 +00:00
cd $INSTALL_DIR /lollms-webui/lollms_core
2024-01-04 02:57:42 +00:00
pip install -e .
2023-07-21 13:38:45 +00:00
fi
2024-09-05 20:24:33 +00:00
cd $INSTALL_DIR /lollms-webui || exit 1
2023-07-21 13:38:45 +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
2024-05-10 01:21:55 +00:00
# The Following section creates the links to the install directory
# scripts vs copying the scripts.
2023-07-21 13:38:45 +00:00
2024-05-10 01:21:55 +00:00
# Linking to the macos_run.sh script
cd $INSTALL_DIR
ln -s lollms-webui/scripts/macos/macos_run.sh macos_run.sh
2023-07-21 13:38:45 +00:00
2024-05-10 01:21:55 +00:00
# Linking to the macos_conda_sessions.sh
ln -s lollms-webui/scripts/macos/macos_conda_session.sh macos_conda_session.sh
2023-07-21 13:38:45 +00:00
2024-04-21 21:36:08 +00:00
echo "Select the default binding to be installed:"
2024-09-01 01:37:49 +00:00
options = ( "None (install the binding later)" "Local binding - ollama" "Local binding - python_llama_cpp" "Local binding - bs_exllamav2" "Remote binding - open_router" "Remote binding - open_ai" "Remote binding - mistral_ai" "Remote binding - gemini" "Remote binding - xAI" "Remote binding - groq" )
2024-04-21 21:36:08 +00:00
select opt in " ${ options [@] } "
do
case $opt in
"None (install the binding later)" )
echo "You selected None. No binding will be installed now."
break
; ;
"Local binding - ollama" )
2024-09-01 01:37:49 +00:00
python zoos/bindings_zoo/ollama/__init__.py
2024-04-21 21:36:08 +00:00
break
; ;
"Local binding - python_llama_cpp" )
2024-09-01 01:37:49 +00:00
python zoos/bindings_zoo/python_llama_cpp/__init__.py
2024-04-21 21:36:08 +00:00
break
; ;
"Local binding - bs_exllamav2" )
2024-09-01 01:37:49 +00:00
python zoos/bindings_zoo/bs_exllamav2/__init__.py
2024-04-21 21:36:08 +00:00
break
; ;
"Remote binding - open_router" )
2024-09-01 01:37:49 +00:00
python zoos/bindings_zoo/open_router/__init__.py
2024-04-21 21:36:08 +00:00
break
; ;
"Remote binding - open_ai" )
2024-09-01 01:37:49 +00:00
python zoos/bindings_zoo/open_ai/__init__.py
2024-04-21 21:36:08 +00:00
break
; ;
"Remote binding - mistral_ai" )
2024-09-01 01:37:49 +00:00
python zoos/bindings_zoo/mistral_ai/__init__.py
break
; ;
"Remote binding - gemini" )
python zoos/bindings_zoo/gemini/__init__.py
break
; ;
"Remote binding - xAI" )
python zoos/bindings_zoo/xAI/__init__.py
break
; ;
"Remote binding - groq" )
python zoos/bindings_zoo/xAI/__init__.py
2024-04-21 21:36:08 +00:00
break
; ;
*) echo " Invalid option $REPLY " ; ;
esac
done
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-04 02:57:42 +00:00
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
2024-02-29 09:39:22 +00:00
echo "Don't forget to select Apple silicon (if you are using M1, M2, M3) or apple intel (if you use old intel mac) in the settings before installing any binding"
2024-01-09 00:15:51 +00:00
2023-07-21 13:38:45 +00:00
PrintBigMessage( ) {
echo
echo "*******************************************************************"
for message in " $@ " ; do
echo " * $message "
done
echo "*******************************************************************"
echo
}
PrintBigMessage " $@ "
exit 0