TheLastBen / fast-stable-diffusion

fast-stable-diffusion + DreamBooth
MIT License
7.52k stars 1.31k forks source link

OSError: [Errno 107] Transport endpoint is not connected #2008

Open NissanSUTUTU opened 1 year ago

NissanSUTUTU commented 1 year ago

@markdown # Start Stable-Diffusion

from IPython.utils import capture import time import sys import fileinput from pyngrok import ngrok, conf

Use_Cloudflare_Tunnel = False #@param {type:"boolean"}

@markdown - Offers better gradio responsivity

Ngrok_token = "" #@param {type:"string"}

@markdown - Input your ngrok token if you want to use ngrok server

User = "" #@param {type:"string"} Password= "" #@param {type:"string"}

@markdown - Add credentials to your Gradio interface (optional)

auth=f"--gradio-auth {User}:{Password}" if User =="" or Password=="": auth=""

with capture.capture_output() as cap: %cd /content/gdrive/$mainpth/sd/stable-diffusion-webui/modules/

if Use_Latest_Working_Commit: !wget -q -O paths.py https://github.com/TheLastBen/fast-stable-diffusion/raw/5632d2ef7fffd940976538d270854ec4faf26855/AUTOMATIC1111_files/paths.py !wget -q -O extras.py https://github.com/AUTOMATIC1111/stable-diffusion-webui/raw/a9eab236d7e8afa4d6205127904a385b2c43bb24/modules/extras.py !wget -q -O sd_models.py https://github.com/AUTOMATIC1111/stable-diffusion-webui/raw/a9eab236d7e8afa4d6205127904a385b2c43bb24/modules/sd_models.py !wget -q -O /usr/local/lib/python3.9/dist-packages/gradio/blocks.py https://github.com/TheLastBen/fast-stable-diffusion/raw/7ff88eaa1fb4997bacd9845bd487f9a14335d625/AUTOMATIC1111_files/blocks.py else: !wget -q -O paths.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/AUTOMATIC1111_files/paths.py !wget -q -O extras.py https://raw.githubusercontent.com/AUTOMATIC1111/stable-diffusion-webui/master/modules/extras.py !wget -q -O sd_models.py https://raw.githubusercontent.com/AUTOMATIC1111/stable-diffusion-webui/master/modules/sd_models.py !wget -q -O /usr/local/lib/python3.9/dist-packages/gradio/blocks.py https://raw.githubusercontent.com/TheLastBen/fast-stable-diffusion/main/AUTOMATIC1111_files/blocks.py %cd /content/gdrive/$mainpth/sd/stable-diffusion-webui/

!sed -i "s@os.path.splitext(checkpoint_file)@os.path.splitext(checkpoint_file); map_location='cuda'@" /content/gdrive/$mainpth/sd/stable-diffusion-webui/modules/sd_models.py !sed -i 's@ui.create_ui().@ui.create_ui();shared.demo.queue(concurrency_count=999999,status_update_rate=0.1)@' /content/gdrive/$mainpth/sd/stable-diffusion-webui/webui.py !sed -i "s@map_location='cpu'@map_location='cuda'@" /content/gdrive/$mainpth/sd/stable-diffusion-webui/modules/extras.py !sed -i 's@/content/gdrive/MyDrive/sd/stablediffusion@/content/gdrive/{mainpth}/sd/stablediffusion@' /content/gdrive/$mainpth/sd/stable-diffusion-webui/modules/paths.py !sed -i 's@print(\"No module.@@' /content/gdrive/$mainpth/sd/stablediffusion/ldm/modules/diffusionmodules/model.py !sed -i 's@\"quicksettings\": OptionInfo(.*@"quicksettings": OptionInfo("sd_model_checkpoint, sd_vae, CLIP_stop_at_last_layers, inpainting_mask_weight, initial_noise_multiplier", "Quicksettings list"),@' /content/gdrive/$mainpth/sd/stable-diffusion-webui/modules/shared.py

share='' if Ngrok_token!="": ngrok.kill() srv=ngrok.connect(7860, pyngrok_config=conf.PyngrokConfig(auth_token=Ngrok_token) , bind_tls=True).public_url

for line in fileinput.input('/usr/local/lib/python3.9/dist-packages/gradio/blocks.py', inplace=True): if line.strip().startswith('self.server_name ='): line = f' self.server_name = "{srv[8:]}"\n' if line.strip().startswith('self.protocol = "https"'): line = ' self.protocol = "https"\n' if line.strip().startswith('if self.local_url.startswith("https") or self.is_colab'): line = '' if line.strip().startswith('else "http"'): line = '' sys.stdout.write(line)

elif Use_Cloudflare_Tunnel: with capture.capture_output() as cap: !pkill cloudflared time.sleep(4) !nohup cloudflared tunnel --url http://localhost:7860 > /content/srv.txt 2>&1 & time.sleep(4) !grep -o 'https[^[:space:]]*.trycloudflare.com' /content/srv.txt >/content/srvr.txt time.sleep(2) srv= getoutput('cat /content/srvr.txt')

for line in fileinput.input('/usr/local/lib/python3.9/dist-packages/gradio/blocks.py', inplace=True):
  if line.strip().startswith('self.server_name ='):
      line = f'            self.server_name = "{srv[8:]}"\n'
  if line.strip().startswith('self.protocol = "https"'):
      line = '            self.protocol = "https"\n'
  if line.strip().startswith('if self.local_url.startswith("https") or self.is_colab'):
      line = ''
  if line.strip().startswith('else "http"'):
      line = ''
  sys.stdout.write(line)

!rm /content/srv.txt /content/srvr.txt

else: share='--share'

try: model if os.path.isfile(model): !python /content/gdrive/$mainpth/sd/stable-diffusion-webui/webui.py $share --api --disable-safe-unpickle --enable-insecure-extension-access --no-download-sd-model --no-half-vae --ckpt "$model" --opt-sdp-attention $auth --disable-console-progressbars else: !python /content/gdrive/$mainpth/sd/stable-diffusion-webui/webui.py $share --api --disable-safe-unpickle --enable-insecure-extension-access --no-download-sd-model --no-half-vae --ckpt-dir "$model" --opt-sdp-attention $auth --disable-console-progressbars except: !python /content/gdrive/$mainpth/sd/stable-diffusion-webui/webui.py $share --api --disable-safe-unpickle --enable-insecure-extension-access --no-download-sd-model --no-half-vae --opt-sdp-attention $auth --disable-console-progressbars

TheLastBen commented 1 year ago

using ngrok usually fixes this issue

starwolf27 commented 1 year ago

I'm having this problem too, and using ngrok didn't fix it. What should I do?

TheLastBen commented 1 year ago

use a fresh sd folder

wordbrew commented 1 year ago

I continually run into this issue with a brand new, fresh SD install. I haven't been able to get a working SD install from using this repo since you updated it 3 days ago. It will 100% fail with some sort of error if I do anything with it beyond just generating images. That includes trying to load loras, installing extensions, or anything else. It has become very burdensome and frustrating because I can't figure out why it is suddenly no longer working.

TheLastBen commented 1 year ago

that's an issue related to Colab itself, not the notebooks, I have no control over that

wordbrew commented 1 year ago

I'm not trying to shit on your work or anything. I've been using your repo for a while and am quite appreciative of everything you're doing. But there is some sort of stabilization issue going on with it that probably shouldn't be ignored. I'm still trying to troubleshoot what the cause is, but it is there and has been since the blasphemy update.

Beyond the slower than usual startup with duplicate process readouts and other smaller issues I've been having (lycoris extension no longer working and throwing errors 50% of time, lora extension throwing errors 80% of the time), there is a degrading functionality in the gradio ui for me that occurs randomly, often ~15 to 20 generations into booting up SD where the "generate" button will no longer function/respond and I have to start using "shift enter" to trigger gens. That too will stop functioning roughly 10 to 12 gens after, forcing me to do a ui reboot.

Reason I don't see it as "just a colab issue" is, I put together my own colab for a repo clone of Vladmanics SD install and it runs fine. As does my comfy colab install. And further, vlad starts up faster and runs smoother compared to Fast A1111. That's even when including installing of all the dependencies via the ARGS command vs. ahead of time.

If the "OSError: [Errno 107] Transport endpoint is not connected" error is truly a colab issue, then fine, but it appears explicitly tied to your repo running on colab. That issue doesn't happen for any of the other repos I've got setup to test. It will happen randomly when trying to boot up a new session. I literally just finished an exceptionally long SD session with Fast A1111 only to come back 20 minutes later and try to boot up, same connection, same setup, and it threw the error. And now I'm back to reinstalling Fast A1111 for the 11th time this week because of it.

I can't imagine the encoding/decoding function you put in for the blasphemy update is the cause. But that's when shit started hitting the fan for me. Just wanting to share what's happening.

edit: fresh install: Startup time: 592.7s (import torch: 10.1s, import gradio: 1.7s, import ldm: 0.5s, other imports: 8.8s, list SD models: 0.5s, setup codeformer: 0.5s, list builtin upscalers: 0.2s, load scripts: 394.0s, load SD checkpoint: 125.2s, create ui: 41.4s, gradio launch: 9.8s). O_o

TheLastBen commented 1 year ago

I use exactly the same code for Runpod and Paperspace notebook and they work just fine, that means it's an issue with colab

if you really want to make sure, run the colab notebook without the first cell.