oobabooga / text-generation-webui

A Gradio web UI for Large Language Models.
GNU Affero General Public License v3.0
40.46k stars 5.3k forks source link

Cant start server, it gives cryptic error #5975

Open Bedoshady opened 6 months ago

Bedoshady commented 6 months ago

Describe the bug

I tried installing server and running it which worked at first, but couldnt load my llama 3 models, I typed this command conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia then it stopped working, I tried different solutions but it didnt work

Is there an existing issue for this?

Reproduction

Install web text ui normally via miniconda then do this command conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia

Screenshot

No response

Logs

(tg) H:\Downloads\text-generation-webui-main>python server.py
binary_path: H:\tools\MiniConda2\envs\tg\lib\site-packages\bitsandbytes\cuda_setup\libbitsandbytes_cuda116.dll
04:53:42-696449 INFO     Starting Text generation web UI

Running on local URL:  http://127.0.0.1:7860

ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\uvicorn\protocols\http\httptools_impl.py", line 411, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 69, in __call__
    return await self.app(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\fastapi\applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\applications.py", line 123, in __call__
    await self.middleware_stack(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\middleware\errors.py", line 186, in __call__
    raise exc
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\middleware\errors.py", line 164, in __call__
    await self.app(scope, receive, _send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\gradio\route_utils.py", line 689, in __call__
    await self.app(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\middleware\exceptions.py", line 65, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\routing.py", line 756, in __call__
    await self.middleware_stack(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\routing.py", line 776, in app
    await route.handle(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\routing.py", line 297, in handle
    await self.app(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\routing.py", line 77, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\routing.py", line 72, in app
    response = await func(request)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\fastapi\routing.py", line 278, in app
    raw_response = await run_endpoint_function(
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\fastapi\routing.py", line 193, in run_endpoint_function
    return await run_in_threadpool(dependant.call, **values)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\concurrency.py", line 42, in run_in_threadpool
    return await anyio.to_thread.run_sync(func, *args)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\anyio\to_thread.py", line 56, in run_sync
    return await get_async_backend().run_sync_in_worker_thread(
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\anyio\_backends\_asyncio.py", line 2144, in run_sync_in_worker_thread
    return await future
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\anyio\_backends\_asyncio.py", line 851, in run
    result = context.run(func, *args)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\gradio\routes.py", line 378, in main
    return templates.TemplateResponse(
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\templating.py", line 229, in TemplateResponse
    template = self.get_template(name)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\templating.py", line 143, in get_template
    return self.env.get_template(name)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\jinja2\environment.py", line 1010, in get_template
    return self._load_template(name, globals)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\jinja2\environment.py", line 969, in _load_template
    template = self.loader.load(self, name, self.make_globals(globals))
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\jinja2\loaders.py", line 125, in load
    source, filename, uptodate = self.get_source(environment, name)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\jinja2\loaders.py", line 206, in get_source
    with open(filename, encoding=self.encoding) as f:
  File "H:\Downloads\text-generation-webui-main\modules\block_requests.py", line 46, in my_open
    file_contents = file_contents.replace(b'\t\t<script\n\t\t\tsrc="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.9/iframeResizer.contentWindow.min.js"\n\t\t\tasync\n\t\t></script>', b'')
TypeError: replace() argument 1 must be str, not bytes
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\uvicorn\protocols\http\httptools_impl.py", line 411, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 69, in __call__
    return await self.app(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\fastapi\applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\applications.py", line 123, in __call__
    await self.middleware_stack(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\middleware\errors.py", line 186, in __call__
    raise exc
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\middleware\errors.py", line 164, in __call__
    await self.app(scope, receive, _send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\gradio\route_utils.py", line 689, in __call__
    await self.app(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\middleware\exceptions.py", line 65, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\routing.py", line 756, in __call__
    await self.middleware_stack(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\routing.py", line 776, in app
    await route.handle(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\routing.py", line 297, in handle
    await self.app(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\routing.py", line 77, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\routing.py", line 72, in app
    response = await func(request)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\fastapi\routing.py", line 278, in app
    raw_response = await run_endpoint_function(
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\fastapi\routing.py", line 193, in run_endpoint_function
    return await run_in_threadpool(dependant.call, **values)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\concurrency.py", line 42, in run_in_threadpool
    return await anyio.to_thread.run_sync(func, *args)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\anyio\to_thread.py", line 56, in run_sync
    return await get_async_backend().run_sync_in_worker_thread(
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\anyio\_backends\_asyncio.py", line 2144, in run_sync_in_worker_thread
    return await future
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\anyio\_backends\_asyncio.py", line 851, in run
    result = context.run(func, *args)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\gradio\routes.py", line 378, in main
    return templates.TemplateResponse(
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\templating.py", line 229, in TemplateResponse
    template = self.get_template(name)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\templating.py", line 143, in get_template
    return self.env.get_template(name)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\jinja2\environment.py", line 1010, in get_template
    return self._load_template(name, globals)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\jinja2\environment.py", line 969, in _load_template
    template = self.loader.load(self, name, self.make_globals(globals))
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\jinja2\loaders.py", line 125, in load
    source, filename, uptodate = self.get_source(environment, name)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\jinja2\loaders.py", line 206, in get_source
    with open(filename, encoding=self.encoding) as f:
  File "H:\Downloads\text-generation-webui-main\modules\block_requests.py", line 46, in my_open
    file_contents = file_contents.replace(b'\t\t<script\n\t\t\tsrc="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.9/iframeResizer.contentWindow.min.js"\n\t\t\tasync\n\t\t></script>', b'')
TypeError: replace() argument 1 must be str, not bytes
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\uvicorn\protocols\http\httptools_impl.py", line 411, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 69, in __call__
    return await self.app(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\fastapi\applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\applications.py", line 123, in __call__
    await self.middleware_stack(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\middleware\errors.py", line 186, in __call__
    raise exc
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\middleware\errors.py", line 164, in __call__
    await self.app(scope, receive, _send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\gradio\route_utils.py", line 689, in __call__
    await self.app(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\middleware\exceptions.py", line 65, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\routing.py", line 756, in __call__
    await self.middleware_stack(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\routing.py", line 776, in app
    await route.handle(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\routing.py", line 297, in handle
    await self.app(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\routing.py", line 77, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\routing.py", line 72, in app
    response = await func(request)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\fastapi\routing.py", line 278, in app
    raw_response = await run_endpoint_function(
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\fastapi\routing.py", line 193, in run_endpoint_function
    return await run_in_threadpool(dependant.call, **values)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\concurrency.py", line 42, in run_in_threadpool
    return await anyio.to_thread.run_sync(func, *args)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\anyio\to_thread.py", line 56, in run_sync
    return await get_async_backend().run_sync_in_worker_thread(
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\anyio\_backends\_asyncio.py", line 2144, in run_sync_in_worker_thread
    return await future
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\anyio\_backends\_asyncio.py", line 851, in run
    result = context.run(func, *args)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\gradio\routes.py", line 378, in main
    return templates.TemplateResponse(
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\templating.py", line 229, in TemplateResponse
    template = self.get_template(name)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\templating.py", line 143, in get_template
    return self.env.get_template(name)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\jinja2\environment.py", line 1010, in get_template
    return self._load_template(name, globals)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\jinja2\environment.py", line 969, in _load_template
    template = self.loader.load(self, name, self.make_globals(globals))
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\jinja2\loaders.py", line 125, in load
    source, filename, uptodate = self.get_source(environment, name)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\jinja2\loaders.py", line 206, in get_source
    with open(filename, encoding=self.encoding) as f:
  File "H:\Downloads\text-generation-webui-main\modules\block_requests.py", line 46, in my_open
    file_contents = file_contents.replace(b'\t\t<script\n\t\t\tsrc="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.9/iframeResizer.contentWindow.min.js"\n\t\t\tasync\n\t\t></script>', b'')
TypeError: replace() argument 1 must be str, not bytes
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\uvicorn\protocols\http\httptools_impl.py", line 411, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 69, in __call__
    return await self.app(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\fastapi\applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\applications.py", line 123, in __call__
    await self.middleware_stack(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\middleware\errors.py", line 186, in __call__
    raise exc
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\middleware\errors.py", line 164, in __call__
    await self.app(scope, receive, _send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\gradio\route_utils.py", line 689, in __call__
    await self.app(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\middleware\exceptions.py", line 65, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\routing.py", line 756, in __call__
    await self.middleware_stack(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\routing.py", line 776, in app
    await route.handle(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\routing.py", line 297, in handle
    await self.app(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\routing.py", line 77, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\routing.py", line 72, in app
    response = await func(request)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\fastapi\routing.py", line 278, in app
    raw_response = await run_endpoint_function(
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\fastapi\routing.py", line 193, in run_endpoint_function
    return await run_in_threadpool(dependant.call, **values)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\concurrency.py", line 42, in run_in_threadpool
    return await anyio.to_thread.run_sync(func, *args)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\anyio\to_thread.py", line 56, in run_sync
    return await get_async_backend().run_sync_in_worker_thread(
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\anyio\_backends\_asyncio.py", line 2144, in run_sync_in_worker_thread
    return await future
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\anyio\_backends\_asyncio.py", line 851, in run
    result = context.run(func, *args)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\gradio\routes.py", line 378, in main
    return templates.TemplateResponse(
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\templating.py", line 229, in TemplateResponse
    template = self.get_template(name)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\templating.py", line 143, in get_template
    return self.env.get_template(name)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\jinja2\environment.py", line 1010, in get_template
    return self._load_template(name, globals)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\jinja2\environment.py", line 969, in _load_template
    template = self.loader.load(self, name, self.make_globals(globals))
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\jinja2\loaders.py", line 125, in load
    source, filename, uptodate = self.get_source(environment, name)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\jinja2\loaders.py", line 206, in get_source
    with open(filename, encoding=self.encoding) as f:
  File "H:\Downloads\text-generation-webui-main\modules\block_requests.py", line 46, in my_open
    file_contents = file_contents.replace(b'\t\t<script\n\t\t\tsrc="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.9/iframeResizer.contentWindow.min.js"\n\t\t\tasync\n\t\t></script>', b'')
TypeError: replace() argument 1 must be str, not bytes
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\uvicorn\protocols\http\httptools_impl.py", line 411, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\uvicorn\middleware\proxy_headers.py", line 69, in __call__
    return await self.app(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\fastapi\applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\applications.py", line 123, in __call__
    await self.middleware_stack(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\middleware\errors.py", line 186, in __call__
    raise exc
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\middleware\errors.py", line 164, in __call__
    await self.app(scope, receive, _send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\gradio\route_utils.py", line 689, in __call__
    await self.app(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\middleware\exceptions.py", line 65, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\routing.py", line 756, in __call__
    await self.middleware_stack(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\routing.py", line 776, in app
    await route.handle(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\routing.py", line 297, in handle
    await self.app(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\routing.py", line 77, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\routing.py", line 72, in app
    response = await func(request)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\fastapi\routing.py", line 278, in app
    raw_response = await run_endpoint_function(
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\fastapi\routing.py", line 193, in run_endpoint_function
    return await run_in_threadpool(dependant.call, **values)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\concurrency.py", line 42, in run_in_threadpool
    return await anyio.to_thread.run_sync(func, *args)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\anyio\to_thread.py", line 56, in run_sync
    return await get_async_backend().run_sync_in_worker_thread(
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\anyio\_backends\_asyncio.py", line 2144, in run_sync_in_worker_thread
    return await future
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\anyio\_backends\_asyncio.py", line 851, in run
    result = context.run(func, *args)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\gradio\routes.py", line 378, in main
    return templates.TemplateResponse(
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\templating.py", line 229, in TemplateResponse
    template = self.get_template(name)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\starlette\templating.py", line 143, in get_template
    return self.env.get_template(name)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\jinja2\environment.py", line 1010, in get_template
    return self._load_template(name, globals)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\jinja2\environment.py", line 969, in _load_template
    template = self.loader.load(self, name, self.make_globals(globals))
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\jinja2\loaders.py", line 125, in load
    source, filename, uptodate = self.get_source(environment, name)
  File "H:\tools\MiniConda2\envs\tg\lib\site-packages\jinja2\loaders.py", line 206, in get_source
    with open(filename, encoding=self.encoding) as f:
  File "H:\Downloads\text-generation-webui-main\modules\block_requests.py", line 46, in my_open
    file_contents = file_contents.replace(b'\t\t<script\n\t\t\tsrc="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.9/iframeResizer.contentWindow.min.js"\n\t\t\tasync\n\t\t></script>', b'')
TypeError: replace() argument 1 must be str, not bytes
┌────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ──────────────────────────────────────────────────────────────────────────────┐
│ H:\Downloads\text-generation-webui-main\server.py:255 in <module>                                                                                                                             │
│                                                                                                                                                                                               │
│   254         # Launch the web UI                                                                                                                                                             │
│ > 255         create_interface()                                                                                                                                                              │
│   256         while True:                                                                                                                                                                     │
│                                                                                                                                                                                               │
│ H:\Downloads\text-generation-webui-main\server.py:161 in create_interface                                                                                                                     │
│                                                                                                                                                                                               │
│   160     with OpenMonkeyPatch():                                                                                                                                                             │
│ > 161         shared.gradio['interface'].launch(                                                                                                                                              │
│   162             max_threads=64,                                                                                                                                                             │
│                                                                                                                                                                                               │
│ H:\tools\MiniConda2\envs\tg\lib\site-packages\gradio\blocks.py:2255 in launch                                                                                                                 │
│                                                                                                                                                                                               │
│   2254         ):                                                                                                                                                                             │
│ > 2255             raise ValueError(                                                                                                                                                          │
│   2256                 "When localhost is not accessible, a shareable link must be created. Ple                                                                                               │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
ValueError: When localhost is not accessible, a shareable link must be created. Please set share=True or check your proxy settings to allow access to localhost.

System Info

Windows 10
MiniConda
nero-dv commented 6 months ago

This can be resolved by modifying the my_open function in the "block_requests.py" file under the modules directory.

# Kindly provided by our friend WizardLM-30B
def my_open(*args, **kwargs):
    filename = str(args[0])
    if filename.endswith("index.html"):
        with original_open(*args, **kwargs) as f:
            file_contents = f.read()

        file_contents = file_contents.replace("cdnjs.cloudflare.com", "127.0.0.1")
        file_contents = file_contents.replace(
            "</head>",
            '\n    <script src="file/js/katex/katex.min.js"></script>'
            '\n    <script src="file/js/katex/auto-render.min.js"></script>'
            '\n    <script src="file/js/highlightjs/highlight.min.js"></script>'
            '\n    <script src="file/js/highlightjs/highlightjs-copy.min.js"></script>'
            "\n    <script>hljs.addPlugin(new CopyButtonPlugin());</script>"
            "\n  </head>",
        )

        return io.StringIO(file_contents)
    else:
        return original_open(*args, **kwargs)

though depending on how old installation is, you would omit the newer replace

# Kindly provided by our friend WizardLM-30B
def my_open(*args, **kwargs):
    filename = str(args[0])
    if filename.endswith("index.html"):
        with original_open(*args, **kwargs) as f:
            file_contents = f.read()

        file_contents = file_contents.replace("cdnjs.cloudflare.com", "127.0.0.1")

        return io.StringIO(file_contents)
    else:
        return original_open(*args, **kwargs)

I had to do this after updating to the latest versions of pytorch, flash_attention 2 and gradio.

Bedoshady commented 6 months ago
def my_open(*args, **kwargs):
    filename = str(args[0])
    if filename.endswith("index.html"):
        with original_open(*args, **kwargs) as f:
            file_contents = f.read()

        file_contents = file_contents.replace("cdnjs.cloudflare.com", "127.0.0.1")

        return io.StringIO(file_contents)
    else:
        return original_open(*args, **kwargs)

I dont know how did you do figure it out but it worked. Can you tell me how did you debug this error as it wasnt clear for me

nero-dv commented 6 months ago

The most recent call in the traceback is:

File "H:\Downloads\text-generation-webui-main\modules\block_requests.py", line 46, in my_open
file_contents = file_contents.replace(b'\t\t<script\n\t\t\tsrc="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.9/iframeResizer.contentWindow.min.js"\n\t\t\tasync\n\t\t></script>', b'')
TypeError: replace() argument 1 must be str, not bytes

First I had to understand why this was being done. The pull request mentions that it's to remove the call to cloudflare (seems like a privacy measure to help prevent fingerprinting or tracking).

The original replace function replaced the entire line, and for some reason this does not seem to act the same way with the latest version of gradio. The error mentions that the argument should be a string, and not a string converted to bytes. Switching this to use StringIO and removing the binary mode (b) from each string initiator resolves the issue.

While I am not completely sure on the exact change that happened on Gradio's end, it might have to do with how they handle storing configs per session now instead of bundling them. Or it could be that they changed how headers are added (sync instead of async). I could be wrong on both accounts.

This fix results in a "not found" error in the network trace, but the benefit is that it is simpler to read and debug and is less hacky.

qnnnnez commented 5 months ago

Actually it is not gradio but jinja that cause the problem. Starting from jinja 3.1.3+, it will open template file in text mode instead of binary mode.

I have the same problem. I did a git pull and a pip install -r requirements.txt, and got this error. In requirements.txt, it is Jinja2==3.1.2, but somehow 3.1.3 is installed. Completely no clue what's happening.

(textgen) user@host:~/miniconda3/envs/textgen/lib/python3.11/site-packages/jinja2$ pip show Jinja2
Name: Jinja2
Version: 3.1.2
Summary: A very fast and expressive template engine.
Home-page: https://palletsprojects.com/p/jinja/
Author: Armin Ronacher
Author-email: armin.ronacher@active-4.com
License: BSD-3-Clause
Location: /home/user/miniconda3/envs/textgen/lib/python3.11/site-packages
Requires: MarkupSafe
Required-by: altair, Flask, gradio, jupyter_server, jupyterlab, jupyterlab_server, llama_cpp_python, llama_cpp_python_cuda, llama_cpp_python_cuda_tensorcores, nbconvert, torch

(textgen) user@host:~/miniconda3/envs/textgen/lib/python3.11/site-packages/jinja2$ conda list | grep -i jinja
jinja2                    3.1.2                    pypi_0    pypi

(textgen) user@host:~/miniconda3/envs/textgen/lib/python3.11/site-packages/jinja2$ python -c "import jinja2; print(jinja2.__path__, jinja2.__version__)"
['/home/user/miniconda3/envs/textgen/lib/python3.11/site-packages/jinja2'] 3.1.3
maxPietsch42 commented 4 months ago

For me start update_wizard_windows.bat with Option A fixed it.

Accurio commented 4 months ago

If you use a manually proxy server in Windows, you may need to set HTTP_PROXY, HTTPS_PROXY and NO_PROXY environment variables.

import os
from urllib.request import getproxies

proxies = getproxies()
os.environ["http_proxy"]  = proxies["http"]
os.environ["https_proxy"] = proxies["https"]
os.environ["no_proxy"]    = "localhost, 127.0.0.1/8, ::1"
nero-dv commented 4 months ago

@Bedoshady this issue should be resolved now that https://github.com/oobabooga/text-generation-webui/pull/5976 has been merged.

Let me know if you have any questions, I'm happy to help.