研究で使用しているstable diffusion webUIをapiモードで実行した際に出たエラーと解決方法です。
エラー内容
sh webui.sh --api
################################################################
Install script for stable-diffusion + Web UI
Tested on Debian 11 (Bullseye)
################################################################
################################################################
Running on kitsune_yk user
################################################################
################################################################
Repo already cloned, using it as install directory
################################################################
################################################################
python venv already activate or run without venv: ./stable-diffusion-webui/venv
################################################################
################################################################
Launching launch.py...
################################################################
Python 3.10.6 (main, Jan 11 2024, 16:37:36) [Clang 15.0.0 (clang-1500.0.40.1)]
Version: v1.5.1
Commit hash: 68f336bd994bed5442ad95bad6b6ad5564a5409a
Launching Web UI with arguments: --api --skip-torch-cuda-test --upcast-sampling --no-half-vae --use-cpu interrogate
Traceback (most recent call last):
File "./stable-diffusion-webui/launch.py", line 39, in <module>
main()
File "./stable-diffusion-webui/launch.py", line 35, in main
start()
File "./stable-diffusion-webui/modules/launch_utils.py", line 390, in start
import webui
File "./stable-diffusion-webui/webui.py", line 44, in <module>
import gradio # noqa: F401
File "./stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/__init__.py", line 3, in <module>
import gradio.components as components
File "./stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/components.py", line 55, in <module>
from gradio import processing_utils, utils
File "./stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/utils.py", line 339, in <module>
class AsyncRequest:
File "./stable-diffusion-webui/venv/lib/python3.10/site-packages/gradio/utils.py", line 358, in AsyncRequest
client = httpx.AsyncClient()
File "./stable-diffusion-webui/venv/lib/python3.10/site-packages/httpx/_client.py", line 1397, in __init__
self._transport = self._init_transport(
File "./stable-diffusion-webui/venv/lib/python3.10/site-packages/httpx/_client.py", line 1445, in _init_transport
return AsyncHTTPTransport(
File "./stable-diffusion-webui/venv/lib/python3.10/site-packages/httpx/_transports/default.py", line 275, in __init__
self._pool = httpcore.AsyncConnectionPool(
TypeError: AsyncConnectionPool.__init__() got an unexpected keyword argument 'socket_options'
(venv)
解決策
ライブラリで使用しているhttpxのバージョンが古いのが原因みたいなので、下記コマンドを実行しhttpxのバージョンを変更する(issue)
pip install httpx==0.24.1