Azure Function App部署含PyTorch的函数失败求助
Azure Function部署问题:引入torch失败+部署成功后函数不显示
已解决的依赖问题
之前因requirements.txt配置问题导致spacy的en_core_web_sm模型无法加载,添加以下内容后,基础功能恢复正常:
https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.7.1/en_core_web_sm-3.7.1.tar.gz
未解决问题1:添加torch依赖后部署失败
当在requirements.txt中添加torch的安装配置时,部署直接失败:
torch==2.2.0 --index-url https://download.pytorch.org/whl/cpu
当前使用的是Y1定价计划的Azure App Service Plan,怀疑是否与torch包体积过大有关?
未解决问题2:注释torch部署成功后函数不显示
注释掉torch依赖并修正spacy配置后,部署流程显示成功,但函数并未在Azure Function App中显示。尝试过重启服务、执行命令func azure functionapp publish <Azure_Function_App_Name> --build remote重新部署,均无效果,且日志中未检测到HTTP触发URL。
相关函数代码
function_app.py中的HTTP触发函数代码如下:
@app.function_name(name='Tokenizer') @app.route(route='tokenization') def tokenization(req: func.HttpRequest) -> func.HttpResponse: if req.method=='POST': logging.info("Processing POST Request ... ") return _post_handler_tokenization(req) elif req.method == 'GET': logging.info("Processing GET Request ... ") return _get_handler_tokenization(req) return func.HttpResponse('[INFO] Service isnt ready', mimetype='text/plain', status_code=200)
该函数在本地可正常收发HTTP请求。
内容的提问来源于stack exchange,提问作者Amir
相关产品推荐
相关产品推荐

