python - 无法将 Ray Serve HTTP 代理绑定到“127.0.0.1:8000”
问题描述
使用以下命令启动 Ray Head 节点:
ray start \
--head \
--port=6379 \
--object-manager-port=8076 \
--include-dashboard=true \
--dashboard-host=0.0.0.0 \
--dashboard-port=8266
输出:
local node IP: localhost
2021-07-10 20:58:01,607 INFO services.py:1245 -- View the Ray dashboard at http://localhost:8266
--------------------
Ray runtime started.
--------------------
Next steps
To connect to this Ray runtime from another node, run
ray start --address='localhost:PORT' --redis-password='xxxx'
Alternatively, use the following Python code:
import ray
ray.init(address='auto', _redis_password='xxxx')
If connection fails, check your firewall settings and network configuration.
To terminate the Ray runtime, run
ray stop
之后在fastapi上写了一段小python代码:
import ray
from ray import serve
from fastapi import FastAPI
app = FastAPI()
serve_handle = None
@app.on_event("startup") # Code to be run when the server starts.
async def startup_event():
ray.init(address='auto', _redis_password='xxxx')
client = serve.start()
for _ in range(100):
x.append(1)
print(x)
但是当我用命令运行脚本时:
uvicorn py_code:app
出现以下错误:
ValueError: Failed to bind Ray Serve HTTP proxy to '127.0.0.1:8000'.
Please make sure your http-host and http-port are specified correctly.
有人可以解释一下我怎样才能让它工作。谢谢
解决方案
推荐阅读
- c++11 - Switch 语句的大 O 在其 Case 中具有函数调用?
- python - 为什么我在 facenet 中收到此错误?
- rust - 为什么在 if let 中添加分号可以避免借用检查器错误?
- python - 为什么这个脚本在 Python 中这么慢?
- neo4j - Neo4j Cypher 匹配没有找到它应该的节点
- git - git中的用户访问控制
- python - 将参数传递给 python 脚本的问题
- generics - 你能写一个通用函数来比较任何数字类型(例如int、float、double)和零吗?
- symfony - 在 Symfony Flex / Symfony 4 的同一台机器上测试和开发环境
- php - DataTables 插件不喜欢与 Bootstrap 4 结合使用