简体   繁体   English

ConnectionRefusedError: [Errno 111] 连接被拒绝- Mlrun

[英]ConnectionRefusedError: [Errno 111] Connection refused- Mlrun

Im trying to invoke a function in a mlrun but getting above error.我试图在mlrun中调用一个函数,但遇到了上述错误。 can anyone please help me with that.im attaching code here...谁能帮我解决这个问题。我在这里附上代码……

from cloudpickle import load
import numpy as np
from typing import List
import mlrun

class ClassifierModel(mlrun.serving.V2ModelServer):
    def load(self):
        """load and initialize the model and/or other elements"""
        model_file, extra_data = self.get_model('.pkl')
        self.model = load(open(model_file, 'rb'))

    def predict(self, body: dict) -> List:
        """Generate model predictions from sample."""
        feats = np.asarray(body['inputs'])
        result: np.ndarray = self.model.predict(feats)
        return result.tolist()

#The following code converts the ClassifierModel class that you defined in the previous step to a serving function. #以下代码将您在上一步中定义的 ClassifierModel 类转换为服务函数。 The name of the class to be used by the serving function is set in spec.default_class.服务函数要使用的类的名称在 spec.default_class 中设置。

serving_fn = mlrun.code_to_function('serving', kind='serving',image='mlrun/mlrun')
serving_fn.spec.default_class = 'ClassifierModel'

model_file = project.get_artifact_uri('my_model') 
serving_fn.add_model('my_model',model_path=model_file)

#Testing Your Function Locally #在本地测试你的功能

my_data = '''{"inputs":[[5.1, 3.5, 1.4, 0.2],[7.7, 3.8, 6.7, 2.2]]}'''

server = serving_fn.to_mock_server()
server.test("/v2/models/my_model/infer", body=my_data)


# Building and Deploying the Serving Function¶

function_address = serving_fn.deploy()

print (f'The address for the function is {function_address} \n')

!curl $function_address

# Now we will try to invoke our serving function

serving_fn.invoke('/v2/models/my_model/infer', my_data)

OSError: error: cannot get build status, HTTPConnectionPool(host='localhost', port=8080): Max retries exceeded with url: /api/v1/build/status?name=serving&project=getting-started-jovyan&tag=&logs=yes&offset=0&last_log_timestamp=1664873747518.8518&verbose=no (Caused by ReadTimeoutError("HTTPConnectionPool(host='localhost', port=8080): Read timed out. (read timeout=45)"))

By the looks of it, there's nothing listening on localhost:8080 , even though there should be.从外观上看,没有任何东西在localhost:8080上监听,尽管应该有。

According to the getting started guide there should be an "MLRun Backend Service", presumably on that address by default.根据入门指南,应该有一个“MLRun 后端服务”,大概默认情况下在该地址上。 I suspect you haven't started the service.我怀疑你还没有启动服务。

The address localhost:8080 in not accessible from docker-composer, it means you have to do MLRun installation to the different IP address. docker-composer 无法访问地址localhost:8080 ,这意味着您必须将 MLRun 安装到不同的 IP 地址。 I see two steps, how to solve the issue:我看到两个步骤,如何解决问题:

Relevant installation相关安装

The MLRun Community Edition in desktop docker has to be install under relevant HOST_IP (not with localhost or 127.0.0.1, but with stable IP address, see ipconfig) and with relevant SHARED_DIR.桌面 docker 中的 MLRun 社区版必须安装在相关的 HOST_IP(不是本地主机或 127.0.0.1,但具有稳定的 IP 地址,请参见 ipconfig)和相关的 SHARED_DIR 下。 See relevant command line (from OS windows):请参阅相关命令行(从操作系统窗口):

set HOST_IP=192.168.0.150
set SHARED_DIR=c:\Apps\mlrun-data
set TAG=1.2.0

mkdir %SHARED_DIR%

docker-compose -f "c:\Apps\mlrun\compose.with-jupyter.yaml" up

BTW: YAML file see https://docs.mlrun.org/en/latest/install/local-docker.html顺便说一句:YAML 文件请参阅https://docs.mlrun.org/en/latest/install/local-docker.html

2. Access to the port 2.端口访问

In case of call serving_fn.invoke you have to open relevant port (from deploy_function ) on your IP address (based on setting of HOST_IP, see the first point).在调用serving_fn.invoke的情况下,您必须在您的 IP 地址上打开相关端口(来自deploy_function )(基于 HOST_IP 的设置,请参见第一点)。

Typically this port can be blocked based on your firewall policy or your local antivirus.通常可以根据您的防火墙策略或本地防病毒软件阻止此端口。 It means, you have to open access to this port before invoke call.这意味着,您必须在调用之前打开对该端口的访问。

BTW:顺便提一句:

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ConnectionRefusedError:[Errno 111]连接被拒绝 - ConnectionRefusedError: [Errno 111] Connection refused Ftplib ConnectionRefusedError: [Errno 111] 连接被拒绝 (python 3.5) - Ftplib ConnectionRefusedError: [Errno 111] Connection refused (python 3.5) python 套接字返回 ConnectionRefusedError: [Errno 111] 连接被拒绝 - python socket return ConnectionRefusedError: [Errno 111] Connection refused python-valve rcon minecraft'ConnectionRefusedError:[Errno 111]连接被拒绝' - python-valve rcon minecraft 'ConnectionRefusedError: [Errno 111] Connection refused' Python ConnectionRefusedError:[Errno 111] Docker 容器上的连接被拒绝 - Python ConnectionRefusedError: [Errno 111] Connection refused on Docker container PythonAnywhere ConnectionRefusedError:[Errno 111] 与 Twilio 一起使用时连接被拒绝 - PythonAnywhere ConnectionRefusedError: [Errno 111] Connection refused when used with Twilio 使用 python ftplib 下载但得到 ConnectionRefusedError: [Errno 111] Connection refused - use python ftplib downloading but get ConnectionRefusedError: [Errno 111] Connection refused Flask+requests API ConnectionRefusedError: [Errno 111] 连接被拒绝 - Flask+requests API ConnectionRefusedError: [Errno 111] Connection refused 在Python(多处理)中正确酸洗和取消代理对象? “ConnectionRefusedError:[Errno 111] 解压时连接被拒绝” - Properly pickling and unpickling proxy objects in Python (multiprocessing)? "ConnectionRefusedError: [Errno 111] Connection refused while unpickling" ConnectionRefusedError:[Errno 111] 笔记本电脑和树莓派之间使用 python 连接被拒绝 - ConnectionRefusedError: [Errno 111] Connection refused between laptop and raspberry pi using python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM