Closed oobabooga closed 1 year ago
I can't repoduce this on the latest main
(I use windows), it may be platform specific
That's possible. The problem happens to me on Linux.
I reproduce this on ubuntu frequently. When the app I'm using (text-generation-webui) sometimes crashes, if I attempt to restart it, I get an error:
Loading settings from settings.json...
Loading llama-30b-4bit-128g...
Loading model ...
Done.
Loaded the model in 7.33 seconds.
Loading the extension "gallery"... Ok.
/home/j/miniconda3/lib/python3.10/site-packages/gradio/deprecation.py:40: UserWarning: The 'type' parameter has been deprecated. Use the Number component instead.
warnings.warn(value)
Traceback (most recent call last):
File "/home/j/miniconda3/lib/python3.10/site-packages/gradio/networking.py", line 119, in start_server
s.bind((LOCALHOST_NAME, server_port))
OSError: [Errno 98] Address already in use
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/mnt/local/machine-learning-proxmox/apps/textgen-latest/server.py", line 458, in <module>
create_interface()
File "/mnt/local/machine-learning-proxmox/apps/textgen-latest/server.py", line 454, in create_interface
shared.gradio['interface'].launch(prevent_thread_lock=True, share=shared.args.share, server_name='0.0.0.0', server_port=shared.args.listen_port, inbrowser=shared.args.auto_launch)
File "/home/j/miniconda3/lib/python3.10/site-packages/gradio/blocks.py", line 1381, in launch
server_name, server_port, local_url, app, server = networking.start_server(
File "/home/j/miniconda3/lib/python3.10/site-packages/gradio/networking.py", line 122, in start_server
raise OSError(
OSError: Port 8003 is in use. If a gradio.Blocks is running on the port, you can close() it or gradio.close_all().
Is there some way that a consumer of Gradio can trap this and either manually free the port or ... something?
@space-nuko if I can provide any additional debugging information, please let me know!
@oobabooga Could this be related?
demo.launch(prevent_thread_lock=False, inbrowser=True) # prevent main thread from exiting
Same problem. Even if I run fuser -k 7860/tcp & python launch.py --listen --port 7860
, I still get this annoying error: OSError: Port 7860 is in use. If a gradio.Blocks is running on the port, you can close() it or gradio.close_all().
It looks like invoking load()
inside the Blocks context manager causes gradio to not release the port. I was able to repro in this branch of text-generation-webui on linux (ubuntu):
https://github.com/tensiondriven/text-generation-webui/blob/graceful-shutdown-demo/server.py#L21
Note that the sleep() calls are necessary to give load() time to allocate memory or whatever; if you remove the sleeps and just open/close gradio quickly, it will work.
This might not be an easy thing to reproduce on your system since text-generation-webui has a bunch of language model dependencies.
Describe the bug
If I initialize a a
gr.Blocks()
interface with a customserver_port
, the port is not released afterdemo.close()
.Is there an existing issue for this?
Reproduction
http://127.0.0.1:9441/?__theme=dark
Screenshot
No response
Logs
System Info
Severity
annoying