{ "nbformat": 4, "nbformat_minor": 0, "metadata": { "colab": { "provenance": [] }, "kernelspec": { "name": "python3", "display_name": "Python 3" }, "language_info": { "name": "python" }, "accelerator": "GPU", "gpuClass": "standard" }, "cells": [ { "cell_type": "markdown", "source": [ "https://colab.research.google.com/github/TavernAI/TavernAI/blob/main/colab/GPU.ipynb
\n", "\n", "Works with:
\n", "KoboldAI https://github.com/KoboldAI/KoboldAI-Client
\n", "Pygmalion https://huggingface.co/PygmalionAI/
\n", "
\n", "**Links**
\n", "TavernAI Github https://github.com/TavernAI/TavernAI
\n", "TavernAI Discord https://discord.gg/zmK2gmr45t
\n", "TavernAI Boosty https://boosty.to/tavernai\n", "
\n",
        " Tavern.AI/ \\ /  ^   ^ ^ ^    ~~~~ ^ \\     /  ^ ^   ^ ^/ ^  ^ \\/^  ^    \\\n",
        "         /^ ^\\ ^  ^ ^   ^ ^  ~~   ^   \\   /  ^  ^ ^   / ^ ^  ^/   ^ ^    \\\n",
        "        /^ ^ ^\\^   ^ ^ ^   _||____   ^ \\ /  ^  ^ ^   /       /  ^  ^  ^   \\\n",
        " /\\ /\\ /\\   ^  \\  /\\ /\\   /\\\\\\\\\\\\\\\\   ^ \\  ^ /\\ /\\ /\\   /\\ /\\ /\\  ^ ^  ^/\\\n",
        "//\\\\/\\\\/\\\\   ^  \\//\\\\/\\\\ /__\\\\\\\\\\\\\\\\  _, \\  //\\\\/\\\\/\\\\ //\\\\/\\\\/\\\\  ^ ^ //\\\\\n",
        "//\\\\/\\\\/\\\\       //\\\\/\\\\ |__|_|_|__|   \\__, //\\\\/\\\\/\\\\ //\\\\/\\\\/\\\\     ///\\\\\\\n",
        " || || (@^◡^)(≖ ‸ ≖*) ( ←_← )\\| /|   /\\ \\ヽ(°ㅂ°╬) |( Ψ▼ー▼)∈ (O_O; )  |||\n",
        "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~ ~~~~~ ~~~~~ ~~~~~  ~~~~~ ~~ \n",
        "
\n", "**Launch Instructions**
\n", "1. Click the launch button.\n", "2. Wait for the environment and model to load\n", "3. After initialization, a TavernAI link will appear\n", "\n", "**Faq**
\n", "* Q: I do not get a TavernAI link\n", "* A: It seems the localtunnel service is currently down, so the TavernAI link is unavailable. Need to wait for it to become available again." ], "metadata": { "id": "d-Yihz3hAb2E" } }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "hps3qtPLFNBb", "cellView": "form" }, "outputs": [], "source": [ "#@title TavernAI\n", "#@markdown <- Click For Start (≖ ‸ ≖ ✿)\n", "\n", "Model = \"Pygmalion 6B\" #@param [ \"Pygmalion 6B\", \"Pygmalion 6B Dev\"] {allow-input: true}\n", "Version = \"Official\" \n", "Provider = \"Cloudflare\" \n", "use_google_drive = False #@param {type:\"boolean\"}\n", "\n", "!nvidia-smi\n", "import subprocess\n", "import time\n", "import sys\n", "import os\n", "from google.colab import drive\n", "def sync_files():\n", " while True:\n", " source_files = os.listdir(\"/taicolabtest/public/chats/\")\n", " destination_files = os.listdir(\"/content/drive/MyDrive/TavernAI/chats\")\n", "\n", " new_files = set(source_files) - set(destination_files)\n", " deleted_files = set(destination_files) - set(source_files)\n", "\n", " if new_files:\n", " for file in new_files:\n", " !cp /taicolabtest/public/chats/{file} /content/drive/MyDrive/TavernAI/chats\n", "\n", " if deleted_files:\n", " for file in deleted_files:\n", " !rm /content/drive/MyDrive/TavernAI/chats/{file}\n", "\n", " time.sleep(3) # Wait\n", "\n", "if use_google_drive:\n", " drive.mount('/content/drive/')\n", " if not os.path.exists(\"/content/drive/MyDrive/TavernAI/\"):\n", " os.mkdir(\"/content/drive/MyDrive/TavernAI/\")\n", " if not os.path.exists(\"/content/drive/MyDrive/TavernAI/characters/\"):\n", " os.mkdir(\"/content/drive/MyDrive/TavernAI/characters/\")\n", " if not os.path.exists(\"/content/drive/MyDrive/TavernAI/chats/\"):\n", " os.mkdir(\"/content/drive/MyDrive/TavernAI/chats/\")\n", "else:\n", " if not os.path.exists(\"/content/drive\"):\n", " os.mkdir(\"/content/drive\")\n", " if not os.path.exists(\"/content/drive/MyDrive/\"):\n", " os.mkdir(\"/content/drive/MyDrive/\")\n", "\n", "Revision = \"\"\n", "\n", "if Model == \"Pygmalion 6B\":\n", " Model = \"PygmalionAI/pygmalion-6b\"\n", " path = \"\"\n", " download = \"\"\n", " Version = \"United\"\n", "elif Model == \"Pygmalion 6B Dev\":\n", " Model = \"PygmalionAI/pygmalion-6b\"\n", " Revision = \"--revision dev\"\n", " path = \"\"\n", " Version = \"United\"\n", " download = \"\"\n", "\n", "if Provider == \"Localtunnel\":\n", " tunnel = \"--localtunnel yes\"\n", "else:\n", " tunnel = \"\"\n", "\n", "#Henk's KoboldAI script\n", "!wget https://koboldai.org/ckds && chmod +x ckds\n", "!./ckds --init only\n", "p = subprocess.Popen(['/content/ckds', '--model', Model], stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n", "\n", "#Tricks\n", "url = ''\n", "while True:\n", " line = p.stdout.readline().decode().strip()\n", " if \"KoboldAI has finished loading and is available at the following link: \" in line:\n", " print(line)\n", " url = line.split(\"KoboldAI has finished loading and is available at the following link: \")[1]\n", " print(url)\n", " break\n", " if \"KoboldAI has finished loading and is available at the following link for UI 1: \" in line:\n", " print(line)\n", " url = line.split(\"KoboldAI has finished loading and is available at the following link for UI 1: \")[1]\n", " print(url)\n", " break\n", " if not line:\n", " break\n", " print(line)\n", " if \"INIT\" in line and \"Transformers\" in line:\n", " print(\"Model loading... (It will take 2 - 5 minutes)\")\n", "\n", "#TavernAI\n", "%cd /\n", "!curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash\n", "!nvm install 19.1.0\n", "!nvm use 19.1.0\n", "!node -v\n", "!git clone https://github.com/TavernAI/taicolabtest\n", "%cd taicolabtest\n", "!npm install\n", "time.sleep(1)\n", "%env colab=2\n", "%env colaburl=$url\n", "!nohup node server.js &\n", "time.sleep(3)\n", "\n", "print('KoboldAI LINK:')\n", "print(url)\n", "print('')\n", "print('###TavernAI LINK###')\n", "!lt --port 8000\n" ] } ] }