Last active
March 26, 2023 18:11
-
-
Save dranger003/1e1b7a4d9f181c6e63dd1fdf63f115c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
# Check if miniconda3 is installed | |
if [ ! -d "miniconda3" ]; then | |
echo "miniconda3 directory not found, please run the init.sh script first" | |
exit 1 | |
fi | |
# Source Conda shell script | |
source miniconda3/etc/profile.d/conda.sh | |
# Create Conda environment | |
conda create -y -n textgen python=3.10.9 || { echo "Error creating Conda environment"; exit 1; } | |
# Activate Conda environment | |
conda activate textgen | |
# Remove existing apt-key if present | |
sudo apt-key del 7fa2af80 || true | |
# Download and install NVIDIA CUDA Toolkit | |
wget -q --show-progress https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin | |
sudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600 | |
wget -q --show-progress https://developer.download.nvidia.com/compute/cuda/11.7.0/local_installers/cuda-repo-wsl-ubuntu-11-7-local_11.7.0-1_amd64.deb | |
sudo dpkg -i cuda-repo-wsl-ubuntu-11-7-local_11.7.0-1_amd64.deb | |
sudo cp /var/cuda-repo-wsl-ubuntu-11-7-local/cuda-*-keyring.gpg /usr/share/keyrings/ | |
sudo apt-get update | |
sudo apt-get -y install cuda | |
# Install required Conda packages | |
conda install -y -n base conda-libmamba-solver | |
conda config --set solver libmamba | |
conda install -y cudatoolkit | |
conda install -y pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia | |
conda install -y -c conda-forge cudatoolkit=11.7 | |
conda install -y -c conda-forge ninja | |
conda install -y -c conda-forge accelerate | |
conda install -y -c conda-forge sentencepiece | |
conda install -y -c conda-forge gradio | |
conda install -y -c conda-forge cudatoolkit-dev | |
conda install -y markdown chardet cchardet ninja | |
# Fix symlinks for libcuda | |
sudo rm -f /usr/lib/wsl/lib/libcuda.so /usr/lib/wsl/lib/libcuda.so.1 | |
sudo ln -s /usr/lib/wsl/lib/libcuda.so.1.1 /usr/lib/wsl/lib/libcuda.so.1 | |
sudo ln -s /usr/lib/wsl/lib/libcuda.so.1 /usr/lib/wsl/lib/libcuda.so | |
# Clone repositories | |
git clone https://github.com/oobabooga/text-generation-webui | |
cd text-generation-webui | |
git reset --hard 8134c4b334ecc3a6a30e774a7265cbafc42ac6cc | |
pip install -r requirements.txt | |
mkdir -p repositories | |
cd repositories | |
git clone https://github.com/qwopqwop200/GPTQ-for-LLaMa | |
cd GPTQ-for-LLaMa | |
git reset --hard 468c47c01b4fe370616747b6d69a2d3f48bab5e4 | |
pip install -r requirements.txt | |
# Install CUDA version of GPTQ-for-LLaMa | |
MAX_JOBS=4 | |
python setup_cuda.py install | |
cd ~/text-generation-webui/ | |
python download-model.py --text-only decapoda-research/llama-7b-hf | |
python download-model.py decapoda-research/llama-7b-hf-int4 | |
mv models/llama-7b-hf-int4/llama-7b-4bit.pt models/ | |
# Replace LLaMATokenizer with LlamaTokenizer | |
perl -i -pe 's/LLaMATokenizer/LlamaTokenizer/g' models/llama-7b-hf/tokenizer_config.json | |
echo "======================================================================" | |
echo "DONE! Run the following commands and your new friend will be awaiting for you:" | |
echo "cd text-generation-webui/" | |
echo "conda activate textgen" | |
echo "python ./server.py --model llama-7b-hf --cai-chat --gptq-bits 4 --listen" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment