Merge branch 'master' into add-insecure-extension-access

This commit is contained in:
Cyberes 2022-11-09 23:49:06 -07:00 committed by GitHub
commit bbbfa06769
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 28 additions and 40 deletions

View File

@ -42,9 +42,9 @@
"source": [ "source": [
"**Where to store the models**\n", "**Where to store the models**\n",
"\n", "\n",
"`/storage/` is persistent storage shared across all machines on your account.\n", "`/storage/` is persistent storage shared across all machines on your account. Mounted to your machine.\n",
"\n", "\n",
"`/notebooks/` is storage for this notebook only.\n", "`/notebooks/` is storage for this notebook only. This directory has to be copied into your machine which can increase start/stop times if the directory is very large. To avoid this, put large files in `/storage/`.\n",
"\n", "\n",
"`/tmp/` <mark style=\"background-color:lime\">is not a persistent directory, meaning your files there will be deleted when the machine turns off.</mark>\n", "`/tmp/` <mark style=\"background-color:lime\">is not a persistent directory, meaning your files there will be deleted when the machine turns off.</mark>\n",
"\n", "\n",
@ -68,22 +68,22 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# Free tier\n", "# Free tier\n",
"# free_tier = True # Enables the creation of symlinks back to /notebooks/\n", "# symlink_to_notebooks = True # Enables the creation of symlinks back to /notebooks/\n",
"# model_storage_dir = '/tmp/stable-diffusion/models' # Where the models will be downloaded to.\n", "# model_storage_dir = '/tmp/stable-diffusion/models' # Where the models will be downloaded to.\n",
"# repo_storage_dir = '/notebooks' # Where the repository will be downloaded to.\n", "# repo_storage_dir = '/notebooks' # Where the repository will be downloaded to.\n",
"\n", "\n",
"# Paid Tier\n", "# Paid Tier\n",
"# free_tier = False\n", "# symlink_to_notebooks = False\n",
"# model_storage_dir = '/storage/models'\n", "# model_storage_dir = '/storage/models'\n",
"# repo_storage_dir = '/notebooks'\n", "# repo_storage_dir = '/notebooks'\n",
"\n", "\n",
"\n", "\n",
"# Other optional settings\n",
"# You don't have to change these if you don't want to\n",
"\n",
"activate_xformers = False # Enables the xformers optimizations using pre-built wheels.\n", "activate_xformers = False # Enables the xformers optimizations using pre-built wheels.\n",
" # Setting to True will automatically set up your environment/machine for xformers. \n", " # Setting to True will automatically set up your environment/machine for xformers. \n",
"\n", "\n",
"xformers_leave_cuda = False # When installing xformers, skip installing cuda 11.3\n",
" # Useful if your're re-running the install block and already installed cuda 11.3\n",
"\n",
"link_novelai_anime_vae = False # Enables the linking of animevae.pt to each of the NovelAI models.\n", "link_novelai_anime_vae = False # Enables the linking of animevae.pt to each of the NovelAI models.\n",
" # Set to True if you've downloaded both the NovelAI models and hypernetworks.\n", " # Set to True if you've downloaded both the NovelAI models and hypernetworks.\n",
"\n", "\n",
@ -107,7 +107,7 @@
"\n", "\n",
"# ===============================================================\n", "# ===============================================================\n",
"# Save variables to Jupiter's temp storage so we can access it even if the kernel restarts.\n", "# Save variables to Jupiter's temp storage so we can access it even if the kernel restarts.\n",
"%store free_tier model_storage_dir repo_storage_dir activate_xformers link_novelai_anime_vae download_scripts activate_deepdanbooru activate_medvram disable_pickle_check gradio_port xformers_leave_cuda gradio_auth" "%store free_tier model_storage_dir repo_storage_dir activate_xformers link_novelai_anime_vae download_scripts activate_deepdanbooru activate_medvram disable_pickle_check gradio_port gradio_auth"
] ]
}, },
{ {
@ -138,7 +138,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"import os\n", "import os\n",
"%store -r free_tier model_storage_dir repo_storage_dir\n", "%store -r symlink_to_notebooks model_storage_dir repo_storage_dir\n",
"%cd /notebooks/\n", "%cd /notebooks/\n",
"\n", "\n",
"def delete_broken_symlinks(path):\n", "def delete_broken_symlinks(path):\n",
@ -158,7 +158,7 @@
" !cd \"{path}\" && git pull # no % so we don't interfere with the main process\n", " !cd \"{path}\" && git pull # no % so we don't interfere with the main process\n",
"\n", "\n",
"def init_free():\n", "def init_free():\n",
" if (free_tier and repo_storage_dir != '/notebooks'):\n", " if (symlink_to_notebooks and repo_storage_dir != '/notebooks'):\n",
" delete_broken_symlinks('/notebooks/') # remove broken symlinks since it might have been installed in a non-persistent directory\n", " delete_broken_symlinks('/notebooks/') # remove broken symlinks since it might have been installed in a non-persistent directory\n",
" if not os.path.exists(repo_storage_dir):\n", " if not os.path.exists(repo_storage_dir):\n",
" !mkdir -p \"{repo_storage_dir}\"\n", " !mkdir -p \"{repo_storage_dir}\"\n",
@ -187,7 +187,7 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"%store -r free_tier model_storage_dir repo_storage_dir activate_xformers download_scripts activate_deepdanbooru xformers_leave_cuda\n", "%store -r symlink_to_notebooks model_storage_dir repo_storage_dir activate_xformers download_scripts activate_deepdanbooru\n",
"%cd \"{repo_storage_dir}/stable-diffusion-webui\"\n", "%cd \"{repo_storage_dir}/stable-diffusion-webui\"\n",
"import os\n", "import os\n",
"\n", "\n",
@ -272,18 +272,6 @@
" !wget \"{url}\" -O \"{tmp_dir}/{binary}\"\n", " !wget \"{url}\" -O \"{tmp_dir}/{binary}\"\n",
" return os.path.join(tmp_dir, binary)\n", " return os.path.join(tmp_dir, binary)\n",
"\n", "\n",
" if not xformers_leave_cuda:\n",
" print('Skipping installing cuda')\n",
" # Completly remove cuda from your system\n",
" # The container comes with cuda 11.2 installed which is incompatable with pytorch\n",
" # We MUST install cuda 11.3\n",
" !apt update\n",
" !apt purge -y cuda*\n",
" !apt autoremove --purge -y\n",
" !wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004-keyring.gpg -O /usr/share/keyrings/cuda-archive-keyring.gpg\n",
" !echo \"deb [signed-by=/usr/share/keyrings/cuda-archive-keyring.gpg] https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /\" | sudo tee /etc/apt/sources.list.d/cuda-ubuntu2004-x86_64.list\n",
" # Reinstall the cuda packages we removed, but in version 11.3\n",
" !apt update && apt install -y cuda-command-line-tools-11-3 cuda-compat-11-3 cuda-minimal-build-11-3 cuda-compiler-11-3 cuda-libraries-dev-11-3 cuda-cupti-dev-11-3 cuda-cupti-11-3 cuda-nvcc-11-3 cuda-cudart-dev-11-3 cuda-libraries-11-3 cuda-cudart-11-3 cuda-gdb-11-3 cuda-cuobjdump-11-3 cuda-cuxxfilt-11-3 cuda-driver-dev-11-3 cuda-memcheck-11-3 cuda-nvdisasm-11-3 cuda-nvml-dev-11-3 cuda-nvprof-11-3 cuda-nvprune-11-3 cuda-nvrtc-dev-11-3 cuda-nvrtc-11-3 cuda-nvtx-11-3 cuda-sanitizer-11-3\n",
" # Set up pip packages\n", " # Set up pip packages\n",
" !pip uninstall -y torch torchvision torchaudio # Remove existing pytorch install.\n", " !pip uninstall -y torch torchvision torchaudio # Remove existing pytorch install.\n",
" !pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113 # Install pytorch for cuda 11.3\n", " !pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113 # Install pytorch for cuda 11.3\n",
@ -384,7 +372,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"%store -r free_tier model_storage_dir repo_storage_dir\n", "%store -r symlink_to_notebooks model_storage_dir repo_storage_dir\n",
"!apt update\n", "!apt update\n",
"!apt install -y aria2\n", "!apt install -y aria2\n",
"%cd \"{model_storage_dir}\"\n", "%cd \"{model_storage_dir}\"\n",
@ -404,7 +392,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"%store -r free_tier model_storage_dir repo_storage_dir\n", "%store -r symlink_to_notebooks model_storage_dir repo_storage_dir\n",
"!apt update\n", "!apt update\n",
"!apt install -y aria2\n", "!apt install -y aria2\n",
"%cd \"{model_storage_dir}\"\n", "%cd \"{model_storage_dir}\"\n",
@ -426,7 +414,7 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"%store -r free_tier model_storage_dir repo_storage_dir\n", "%store -r symlink_to_notebooks model_storage_dir repo_storage_dir\n",
"!apt update\n", "!apt update\n",
"!apt install -y aria2\n", "!apt install -y aria2\n",
"%cd \"{model_storage_dir}\"\n", "%cd \"{model_storage_dir}\"\n",
@ -455,7 +443,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"%store -r free_tier model_storage_dir repo_storage_dir\n", "%store -r symlink_to_notebooks model_storage_dir repo_storage_dir\n",
"!apt update\n", "!apt update\n",
"!apt install -y aria2\n", "!apt install -y aria2\n",
"%cd \"{model_storage_dir}\"\n", "%cd \"{model_storage_dir}\"\n",
@ -475,7 +463,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"%store -r free_tier model_storage_dir repo_storage_dir\n", "%store -r symlink_to_notebooks model_storage_dir repo_storage_dir\n",
"!apt update\n", "!apt update\n",
"!apt install -y aria2\n", "!apt install -y aria2\n",
"%cd \"{model_storage_dir}\"\n", "%cd \"{model_storage_dir}\"\n",
@ -515,7 +503,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"%store -r free_tier model_storage_dir repo_storage_dir\n", "%store -r symlink_to_notebooks model_storage_dir repo_storage_dir\n",
"!wget https://huggingface.co/naclbit/trinart_stable_diffusion_v2/resolve/main/trinart2_step60000.ckpt -O \"{model_storage_dir}/trinart2_step60000.ckpt\"" "!wget https://huggingface.co/naclbit/trinart_stable_diffusion_v2/resolve/main/trinart2_step60000.ckpt -O \"{model_storage_dir}/trinart2_step60000.ckpt\""
] ]
}, },
@ -532,7 +520,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"%store -r free_tier model_storage_dir repo_storage_dir\n", "%store -r symlink_to_notebooks model_storage_dir repo_storage_dir\n",
"!wget https://huggingface.co/naclbit/trinart_stable_diffusion_v2/resolve/main/trinart2_step95000.ckpt -O \"{model_storage_dir}/trinart2_step95000.ckpt\"" "!wget https://huggingface.co/naclbit/trinart_stable_diffusion_v2/resolve/main/trinart2_step95000.ckpt -O \"{model_storage_dir}/trinart2_step95000.ckpt\""
] ]
}, },
@ -549,7 +537,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"%store -r free_tier model_storage_dir repo_storage_dir\n", "%store -r symlink_to_notebooks model_storage_dir repo_storage_dir\n",
"!wget https://huggingface.co/naclbit/trinart_stable_diffusion_v2/resolve/main/trinart2_step115000.ckpt -O \"{model_storage_dir}/trinart2_step115000.ckpt\"" "!wget https://huggingface.co/naclbit/trinart_stable_diffusion_v2/resolve/main/trinart2_step115000.ckpt -O \"{model_storage_dir}/trinart2_step115000.ckpt\""
] ]
}, },
@ -568,7 +556,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"%store -r free_tier model_storage_dir repo_storage_dir\n", "%store -r symlink_to_notebooks model_storage_dir repo_storage_dir\n",
"!wget https://huggingface.co/naclbit/trinart_characters_19.2m_stable_diffusion_v1/resolve/main/trinart_characters_it4_v1.ckpt -O \"{model_storage_dir}/trinart_characters_it4_v1.ckpt\"" "!wget https://huggingface.co/naclbit/trinart_characters_19.2m_stable_diffusion_v1/resolve/main/trinart_characters_it4_v1.ckpt -O \"{model_storage_dir}/trinart_characters_it4_v1.ckpt\""
] ]
}, },
@ -592,7 +580,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"%store -r free_tier model_storage_dir repo_storage_dir\n", "%store -r symlink_to_notebooks model_storage_dir repo_storage_dir\n",
"!apt update\n", "!apt update\n",
"!apt install -y aria2\n", "!apt install -y aria2\n",
"metalink = 'magnet:?xt=urn:btih:5bde442da86265b670a3e5ea3163afad2c6f8ecc&dn=novelaileak&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2F9.rarbg.com%3A2810%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A6969%2Fannounce&tr=http%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&tr=udp%3A%2F%2Fopentracker.i2p.rocks%3A6969%2Fannounce'\n", "metalink = 'magnet:?xt=urn:btih:5bde442da86265b670a3e5ea3163afad2c6f8ecc&dn=novelaileak&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2F9.rarbg.com%3A2810%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A6969%2Fannounce&tr=http%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&tr=udp%3A%2F%2Fopentracker.i2p.rocks%3A6969%2Fannounce'\n",
@ -621,7 +609,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"%store -r free_tier model_storage_dir repo_storage_dir\n", "%store -r symlink_to_notebooks model_storage_dir repo_storage_dir\n",
"!apt update\n", "!apt update\n",
"!apt install -y aria2\n", "!apt install -y aria2\n",
"metalink = 'magnet:?xt=urn:btih:5bde442da86265b670a3e5ea3163afad2c6f8ecc&dn=novelaileak&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2F9.rarbg.com%3A2810%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A6969%2Fannounce&tr=http%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&tr=udp%3A%2F%2Fopentracker.i2p.rocks%3A6969%2Fannounce'\n", "metalink = 'magnet:?xt=urn:btih:5bde442da86265b670a3e5ea3163afad2c6f8ecc&dn=novelaileak&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2F9.rarbg.com%3A2810%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A6969%2Fannounce&tr=http%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&tr=udp%3A%2F%2Fopentracker.i2p.rocks%3A6969%2Fannounce'\n",
@ -652,7 +640,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"%store -r free_tier model_storage_dir repo_storage_dir\n", "%store -r symlink_to_notebooks model_storage_dir repo_storage_dir\n",
"!apt update\n", "!apt update\n",
"!apt install -y aria2\n", "!apt install -y aria2\n",
"metalink = 'magnet:?xt=urn:btih:5bde442da86265b670a3e5ea3163afad2c6f8ecc&dn=novelaileak&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2F9.rarbg.com%3A2810%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A6969%2Fannounce&tr=http%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&tr=udp%3A%2F%2Fopentracker.i2p.rocks%3A6969%2Fannounce'\n", "metalink = 'magnet:?xt=urn:btih:5bde442da86265b670a3e5ea3163afad2c6f8ecc&dn=novelaileak&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2F9.rarbg.com%3A2810%2Fannounce&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A6969%2Fannounce&tr=http%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&tr=udp%3A%2F%2Fopentracker.i2p.rocks%3A6969%2Fannounce'\n",
@ -686,7 +674,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"%store -r free_tier model_storage_dir repo_storage_dir\n", "%store -r symlink_to_notebooks model_storage_dir repo_storage_dir\n",
"\n", "\n",
"# Get some storage back\n", "# Get some storage back\n",
"!pip cache purge\n", "!pip cache purge\n",
@ -832,7 +820,7 @@
"auth = f'--gradio-auth {gradio_auth} --enable-insecure-extension-access' if gradio_auth else ''\n", "auth = f'--gradio-auth {gradio_auth} --enable-insecure-extension-access' if gradio_auth else ''\n",
"\n", "\n",
"# Launch args go below:\n", "# Launch args go below:\n",
"!python webui.py {x_arg} {dd_arg} {mvram_arg} {pickled} {port} --gradio-debug {auth}" "!python webui.py {x_arg} {dd_arg} {mvram_arg} {pickled} {port} {auth} --gradio-debug"
] ]
}, },
{ {
@ -861,7 +849,7 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"%store -r free_tier model_storage_dir repo_storage_dir activate_xformers link_novelai_anime_vae\n", "%store -r symlink_to_notebooks model_storage_dir repo_storage_dir activate_xformers link_novelai_anime_vae\n",
"!apt update\n", "!apt update\n",
"!apt install -y p7zip-full\n", "!apt install -y p7zip-full\n",
"from datetime import datetime\n", "from datetime import datetime\n",
@ -964,7 +952,7 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"%store -r free_tier model_storage_dir repo_storage_dir activate_xformers link_novelai_anime_vae\n", "%store -r symlink_to_notebooks model_storage_dir repo_storage_dir activate_xformers link_novelai_anime_vae\n",
"%cd \"{repo_storage_dir}/stable-diffusion-webui\"\n", "%cd \"{repo_storage_dir}/stable-diffusion-webui\"\n",
"!git reset --hard <commit>" "!git reset --hard <commit>"
] ]
@ -1005,7 +993,7 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"# Uncomment the lines below to run this block. You can highlight the lines and do ctrl + /\n", "# Uncomment the lines below to run this block. You can highlight the lines and do ctrl + /\n",
"# %store -r free_tier model_storage_dir repo_storage_dir activate_xformers link_novelai_anime_vae\n", "# %store -r symlink_to_notebooks model_storage_dir repo_storage_dir activate_xformers link_novelai_anime_vae\n",
"# !rm -rf /storage/*\n", "# !rm -rf /storage/*\n",
"# !mv /notebooks/*.ipynb / # move the notebook out of the directory before we nuke it\n", "# !mv /notebooks/*.ipynb / # move the notebook out of the directory before we nuke it\n",
"# !rm -rf /notebooks/*\n", "# !rm -rf /notebooks/*\n",