Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Connection refused" and "name 'ml' is not defined" #21

Open
abuluoshuai opened this issue Mar 31, 2024 · 2 comments
Open

"Connection refused" and "name 'ml' is not defined" #21

abuluoshuai opened this issue Mar 31, 2024 · 2 comments

Comments

@abuluoshuai
Copy link

abuluoshuai commented Mar 31, 2024

Ubuntu20.04.6 LTS
按照readme安装好,并且下载好模型参数放到正确位置之后,在docker内部启动时,报类似错误

(py38) root@a6eb6770f824:/mtai_workspace/MobiMaliangSDK# streamlit run frontend/main.py --server.port 1001

  You can now view your Streamlit app in your browser.

  Network URL: http://172.17.0.2:1001
  External URL: http://114.86.67.1:1001

The cache for model files in Transformers v4.22.0 has been updated. Migrating your old cache. This is a one-time only operation. You can interrupt this and resume the migration later on by calling `transformers.utils.move_cache()`.
0it [00:00, ?it/s]
We cannot import torch_musa
2024-03-31 21:38:05.595 Uncaught app exception
Traceback (most recent call last):
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/streamlit/runtime/caching/cache_utils.py", line 263, in _get_or_create_cached_value
    cached_result = cache.read_result(value_key)
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/streamlit/runtime/caching/cache_resource_api.py", line 500, in read_result
    raise CacheKeyNotFoundError()
streamlit.runtime.caching.cache_errors.CacheKeyNotFoundError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/streamlit/runtime/caching/cache_utils.py", line 311, in _handle_cache_miss
    cached_result = cache.read_result(value_key)
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/streamlit/runtime/caching/cache_resource_api.py", line 500, in read_result
    raise CacheKeyNotFoundError()
streamlit.runtime.caching.cache_errors.CacheKeyNotFoundError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/mtai_workspace/MobiMaliangSDK/modules/shared.py", line 71, in load_models
    pipe = StableDiffusionPipeline.from_single_file(
  File "/mtai_workspace/MobiMaliangSDK/modules/hijack/load_from_single_file.py", line 192, in from_single_file
    pipe = download_from_original_stable_diffusion_ckpt(
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py", line 1236, in download_from_original_stable_diffusion_ckpt
    original_config = OmegaConf.load(original_config_file)
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/omegaconf/omegaconf.py", line 189, in load
    with io.open(os.path.abspath(file_), "r", encoding="utf-8") as f:
FileNotFoundError: [Errno 2] No such file or directory: '/mtai_workspace/MobiMaliangSDK/models/Stable-diffusion/v1-inference.yaml'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/urllib3/connection.py", line 200, in _new_conn
    sock = connection.create_connection(
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/urllib3/util/connection.py", line 85, in create_connection
    raise err
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/urllib3/util/connection.py", line 73, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/urllib3/connectionpool.py", line 790, in urlopen
    response = self._make_request(
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/urllib3/connectionpool.py", line 491, in _make_request
    raise new_e
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/urllib3/connectionpool.py", line 467, in _make_request
    self._validate_conn(conn)
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/urllib3/connectionpool.py", line 1092, in _validate_conn
    conn.connect()
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/urllib3/connection.py", line 604, in connect
    self.sock = sock = self._new_conn()
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/urllib3/connection.py", line 215, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7f92ce517af0>: Failed to establish a new connection: [Errno 111] Connection refused

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/urllib3/connectionpool.py", line 844, in urlopen
    retries = retries.increment(
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/urllib3/util/retry.py", line 515, in increment
    raise MaxRetryError(_pool, url, reason) from reason  # type: ignore[arg-type]
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='raw.githubusercontent.com', port=443): Max retries exceeded with url: /CompVis/stable-diffusion/main/configs/stable-diffusion/v1-inference.yaml (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f92ce517af0>: Failed to establish a new connection: [Errno 111] Connection refused'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 552, in _run_script
    exec(code, module.__dict__)
  File "/mtai_workspace/MobiMaliangSDK/frontend/main.py", line 476, in <module>
    ml = load_ckpt()
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/streamlit/runtime/caching/cache_utils.py", line 211, in wrapper
    return cached_func(*args, **kwargs)
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/streamlit/runtime/caching/cache_utils.py", line 240, in __call__
    return self._get_or_create_cached_value(args, kwargs)
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/streamlit/runtime/caching/cache_utils.py", line 266, in _get_or_create_cached_value
    return self._handle_cache_miss(cache, value_key, func_args, func_kwargs)
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/streamlit/runtime/caching/cache_utils.py", line 320, in _handle_cache_miss
    computed_value = self._info.func(*func_args, **func_kwargs)
  File "/mtai_workspace/MobiMaliangSDK/frontend/main.py", line 86, in load_ckpt
    ml.load_models(path, diffusers_format=os.path.isdir(path))
  File "/mtai_workspace/MobiMaliangSDK/modules/shared.py", line 78, in load_models
    pipe = StableDiffusionPipeline.from_single_file(
  File "/mtai_workspace/MobiMaliangSDK/modules/hijack/load_from_single_file.py", line 192, in from_single_file
    pipe = download_from_original_stable_diffusion_ckpt(
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/diffusers/pipelines/stable_diffusion/convert_from_ckpt.py", line 1234, in download_from_original_stable_diffusion_ckpt
    original_config_file = BytesIO(requests.get(config_url).content)
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/requests/api.py", line 73, in get
    return request("get", url, params=params, **kwargs)
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/requests/adapters.py", line 519, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='raw.githubusercontent.com', port=443): Max retries exceeded with url: /CompVis/stable-diffusion/main/configs/stable-diffusion/v1-inference.yaml (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f92ce517af0>: Failed to establish a new connection: [Errno 111] Connection refused'))

此时在网页端更换模型的话,会报如下错误

2024-03-31 21:38:23.568 Uncaught app exception
Traceback (most recent call last):
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 548, in _run_script
    self._session_state.on_script_will_rerun(rerun_data.widget_states)
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/streamlit/runtime/state/safe_session_state.py", line 68, in on_script_will_rerun
    self._state.on_script_will_rerun(latest_widget_states)
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/streamlit/runtime/state/session_state.py", line 484, in on_script_will_rerun
    self._call_callbacks()
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/streamlit/runtime/state/session_state.py", line 497, in _call_callbacks
    self._new_widget_state.call_callback(wid)
  File "/opt/conda/envs/py38/lib/python3.8/site-packages/streamlit/runtime/state/session_state.py", line 249, in call_callback
    callback(*args, **kwargs)
  File "/mtai_workspace/MobiMaliangSDK/frontend/main.py", line 109, in switch_ckpt
    ml.offload_models()
NameError: name 'ml' is not defined

应该是因为网络不好导致对raw.githubusercontent.com的DNS解析失败。
关掉服务,在docker内部编辑/etc/host,在最下边加入一行

185.199.111.133 raw.githubusercontent.com

再重新启动服务就正常了。
但是我这还有另外的问题。成功启动服务之后会报无法import torch_musa

(py38) root@a6eb6770f824:/mtai_workspace/MobiMaliangSDK# streamlit run frontend/main.py --server.port 1001

  You can now view your Streamlit app in your browser.

  Network URL: http://172.17.0.2:1001
  External URL: http://114.86.67.1:1001

We cannot import torch_musa

求解决。驱动用的是SDK中自带的。

@abuluoshuai
Copy link
Author

补充,mthreads-gmi工作正常,显卡是S80

Sun Mar 31 21:54:26 2024
---------------------------------------------------------------
    mthreads-gmi:1.6.0           Driver Version:2.1.1
---------------------------------------------------------------
ID   Name           |PCIe                |%GPU  Mem
     Device Type    |Pcie Lane Width     |Temp  MPC Capable
+-------------------------------------------------------------+
0    MTT S80        |00000000:01:00.0    |0%    397MiB(16384MiB)
     Physical       |16x(16x)            |55C   YES
---------------------------------------------------------------

---------------------------------------------------------------
Processes:
ID   PID       Process name                         GPU Memory
                                                         Usage
+-------------------------------------------------------------+
0    1587      /usr/bin/gnome-shell                     298MiB
0    1011      /usr/local/bin/Xorg                       94MiB
---------------------------------------------------------------

@abuluoshuai
Copy link
Author

再补充,现在能作图,但是是用的CPU作图

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant