FastChat icon indicating copy to clipboard operation
FastChat copied to clipboard

openai_api_server stop working

Open aceerez opened this issue 3 years ago • 1 comments

Hi,

I am trying to set up an API server as I did before, many times.

I'm getting errors.

after running the controller and the worker like this:

root@360ad52f0e52:/# python3 -m fastchat.serve.controller --host=0.0.0.0 & [2] 24 root@360ad52f0e52:/# 2023-07-20 06:54:16 | INFO | controller | args: Namespace(dispatch_method='shortest_queue', host='0.0.0.0', port=21001) 2023-07-20 06:54:16 | ERROR | stderr | INFO: Started server process [24] 2023-07-20 06:54:16 | ERROR | stderr | INFO: Waiting for application startup. 2023-07-20 06:54:16 | ERROR | stderr | INFO: Application startup complete. 2023-07-20 06:54:16 | ERROR | stderr | INFO: Uvicorn running on http://0.0.0.0:21001 (Press CTRL+C to quit)

python3 -m fastchat.serve.model_worker --model-path /models/models--lmsys--vicuna-7b-v1.3/snapshots/30a07c35c99b04617243200163e77e6c569f7e5d/ --model-name test --controller-address=http://0.0.0.0:21001 --host=127.0.0.1 &

[3] 38 2023-07-20 06:55:11 | INFO | model_worker | args: Namespace(controller_address='http://0.0.0.0:21001', cpu_offloading=False, device='cuda', gptq_act_order=False, gptq_ckpt=None, gptq_groupsize=-1, gptq_wbits=16, gpus=None, host='127.0.0.1', limit_model_concurrency=5, load_8bit=False, max_gpu_memory=None, model_names=['test'], model_path='/models/models--lmsys--vicuna-7b-v1.3/snapshots/30a07c35c99b04617243200163e77e6c569f7e5d/', no_register=False, num_gpus=1, port=21002, revision='main', stream_interval=2, worker_address='http://localhost:21002') 2023-07-20 06:55:11 | INFO | model_worker | Loading the model ['test'] on worker 24ea8e88 ... Loading checkpoint shards: 0%| | 0/2 [00:00<?, ?it/s] Loading checkpoint shards: 50%|████████████████████████████████████████████████████████████████████████ | 1/2 [00:04<00:04, 4.30s/it] Loading checkpoint shards: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:06<00:00, 3.06s/it] Loading checkpoint shards: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2/2 [00:06<00:00, 3.25s/it] 2023-07-20 06:55:17 | ERROR | stderr | 2023-07-20 06:55:21 | INFO | model_worker | Register to controller 2023-07-20 06:55:21 | INFO | controller | Register a new worker: http://localhost:21002 2023-07-20 06:55:21 | INFO | controller | Register done: http://localhost:21002, {'model_names': ['test'], 'speed': 1, 'queue_length': 0} 2023-07-20 06:55:21 | INFO | stdout | INFO: 127.0.0.1:57674 - "POST /register_worker HTTP/1.1" 200 OK 2023-07-20 06:55:21 | ERROR | stderr | INFO: Started server process [38] 2023-07-20 06:55:21 | ERROR | stderr | INFO: Waiting for application startup. 2023-07-20 06:55:21 | ERROR | stderr | INFO: Application startup complete. 2023-07-20 06:55:21 | ERROR | stderr | INFO: Uvicorn running on http://127.0.0.1:21002 (Press CTRL+C to quit)

when I try to run the API server I'm getting this error:

root@360ad52f0e52:/# python3 -m fastchat.serve.openai_api_server --host 0.0.0.0 --port 8000

Traceback (most recent call last): File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/lib/python3.8/runpy.py", line 87, in _run_code exec(code, run_globals) File "/usr/local/lib/python3.8/dist-packages/fastchat/serve/openai_api_server.py", line 24, in from pydantic import BaseSettings File "/usr/local/lib/python3.8/dist-packages/pydantic/init.py", line 206, in getattr return _getattr_migration(attr_name) File "/usr/local/lib/python3.8/dist-packages/pydantic/_migration.py", line 279, in wrapper raise PydanticImportError( pydantic.errors.PydanticImportError: BaseSettings has been moved to the pydantic-settings package. See https://docs.pydantic.dev/2.0.2/migration/#basesettings-has-moved-to-pydantic-settings for more details.

I tried to fix this error by doing:

pip install pydantic-settings

and then replaced in the code in /fastchat/serve/openai_api_server.py

from pydantic import BaseSettings # OLD from pydantic_settings import BaseSettings # NEW

I'm getting this Error now:

root@360ad52f0e52:/# python3 -m fastchat.serve.openai_api_server --host 0.0.0.0 --port 8000 ╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮ │ /usr/lib/python3.8/runpy.py:194 in _run_module_as_main │ │ │ │ 191 │ main_globals = sys.modules["main"].dict │ │ 192 │ if alter_argv: │ │ 193 │ │ sys.argv[0] = mod_spec.origin │ │ ❱ 194 │ return _run_code(code, main_globals, None, │ │ 195 │ │ │ │ │ "main", mod_spec) │ │ 196 │ │ 197 def run_module(mod_name, init_globals=None, │ │ │ │ /usr/lib/python3.8/runpy.py:87 in _run_code │ │ │ │ 84 │ │ │ │ │ loader = loader, │ │ 85 │ │ │ │ │ package = pkg_name, │ │ 86 │ │ │ │ │ spec = mod_spec) │ │ ❱ 87 │ exec(code, run_globals) │ │ 88 │ return run_globals │ │ 89 │ │ 90 def _run_module_code(code, init_globals=None, │ │ │ │ /usr/local/lib/python3.8/dist-packages/fastchat/serve/openai_api_server.py:77 in │ │ │ │ 74 │ api_keys: List[str] = None │ │ 75 │ │ 76 │ │ ❱ 77 app_settings = AppSettings() │ │ 78 app = fastapi.FastAPI() │ │ 79 headers = {"User-Agent": "FastChat API Server"} │ │ 80 get_bearer_token = HTTPBearer(auto_error=False) │ │ │ │ /usr/local/lib/python3.8/dist-packages/pydantic_settings/main.py:71 in init │ │ │ │ 68 │ │ **values: Any, │ │ 69 │ ) -> None: │ │ 70 │ │ # Uses something other than self the first arg to allow "self" as a settable a │ │ ❱ 71 │ │ super().init( │ │ 72 │ │ │ **pydantic_self._settings_build_values( │ │ 73 │ │ │ │ values, │ │ 74 │ │ │ │ _case_sensitive=_case_sensitive, │ │ │ │ /usr/local/lib/python3.8/dist-packages/pydantic/main.py:150 in init │ │ │ │ 147 │ │ """ │ │ 148 │ │ # __tracebackhide__ tells pytest and some other tools to omit this function fr │ │ 149 │ │ tracebackhide = True │ │ ❱ 150 │ │ pydantic_self.pydantic_validator.validate_python(data, self_instance=__p │ │ 151 │ │ │ 152 │ # The following line sets a flag that we use to determine when __init__ gets overr │ │ 153 │ init.pydantic_base_init = True # type: ignore │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ ValidationError: 1 validation error for AppSettings api_keys Input should be a valid list [type=list_type, input_value=None, input_type=NoneType] For further information visit https://errors.pydantic.dev/2.1.2/v/list_type

can anyone please help me understand what am I supposed to do?

aceerez avatar Jul 20 '23 07:07 aceerez

Shalom. I've pinned pydantic==1.4.0 and it seems to solve the issue.

Orad avatar Jul 20 '23 18:07 Orad