问题描述
我使用自定义 pyfunc 创建了一个 mlflow 模型。当我将输入发送到 Jupyter notebook 中加载的模型时,它会显示结果。 但是,如果我尝试将其提供给本地端口
!mlflow models serve -m Home/miniconda3/envs/mlruns/0/baa40963927a49258c845421e3175c06/artifacts/model -p 8001
我收到此错误
Traceback (most recent call last):
File "/home/subhojyoti/miniconda3/envs/python3-env/bin/mlflow",line 10,in <module>
sys.exit(cli())
File "/home/subhojyoti/miniconda3/envs/python3-env/lib/python3.6/site-packages/click/core.py",line 829,in __call__
return self.main(*args,**kwargs)
File "/home/subhojyoti/miniconda3/envs/python3-env/lib/python3.6/site-packages/click/core.py",line 782,in main
rv = self.invoke(ctx)
File "/home/subhojyoti/miniconda3/envs/python3-env/lib/python3.6/site-packages/click/core.py",line 1259,in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/subhojyoti/miniconda3/envs/python3-env/lib/python3.6/site-packages/click/core.py",line 1066,in invoke
return ctx.invoke(self.callback,**ctx.params)
File "/home/subhojyoti/miniconda3/envs/python3-env/lib/python3.6/site-packages/click/core.py",line 610,in invoke
return callback(*args,**kwargs)
File "/home/subhojyoti/miniconda3/envs/python3-env/lib/python3.6/site-packages/mlflow/models/cli.py",line 56,in serve
install_mlflow=install_mlflow).serve(model_uri=model_uri,port=port,File "/home/subhojyoti/miniconda3/envs/python3-env/lib/python3.6/site-packages/mlflow/models/cli.py",line 163,in _get_flavor_backend
append_to_uri_path(underlying_model_uri,"MLmodel"),output_path=tmp.path())
File "/home/subhojyoti/miniconda3/envs/python3-env/lib/python3.6/site-packages/mlflow/tracking/artifact_utils.py",line 76,in _download_artifact_from_uri
artifact_path=artifact_path,dst_path=output_path)
File "/home/subhojyoti/miniconda3/envs/python3-env/lib/python3.6/site-packages/mlflow/store/artifact/local_artifact_repo.py",line 67,in download_artifacts
return super(LocalArtifactRepository,self).download_artifacts(artifact_path,dst_path)
File "/home/subhojyoti/miniconda3/envs/python3-env/lib/python3.6/site-packages/mlflow/store/artifact/artifact_repo.py",line 140,in download_artifacts
return download_file(artifact_path)
File "/home/subhojyoti/miniconda3/envs/python3-env/lib/python3.6/site-packages/mlflow/store/artifact/artifact_repo.py",line 105,in download_file
self._download_file(remote_file_path=fullpath,local_path=local_file_path)
File "/home/subhojyoti/miniconda3/envs/python3-env/lib/python3.6/site-packages/mlflow/store/artifact/local_artifact_repo.py",line 95,in _download_file
shutil.copyfile(remote_file_path,local_path)
File "/home/subhojyoti/miniconda3/envs/python3-env/lib/python3.6/shutil.py",line 120,in copyfile
with open(src,'rb') as fsrc:
FileNotFoundError: [Errno 2] No such file or directory: 'Home/miniconda3/envs/mlruns/0/baa40963927a49258c845421e3175c06/artifacts/model/MLmodel'
解决方法
从您的错误回溯中,无法找到模型工件。在您的代码中,您正在 Jupyter Notebook 中执行“mlflow”命令。我建议尝试以下操作:
- 检查您的模型工件是否在您使用的路径上 Home/miniconda3/envs/mlruns/0/baa40963927a49258c845421e3175c06/artifacts/model
- 尝试打开终端,然后
await t.switchToIframe( Selector("iframe[title^='SR']"),{ timeout: 60000 }));
并执行cd /Home/miniconda3/envs
- MLFlow 提供了不同的解决方案来为模型提供服务,您可以尝试注册您的模型并将其称为“models:/{model_name}/{stage}”,如模型注册表中所述docs