How to deploy locally saved cross encoder model (Sbert, distilroberta-uncased) using azure function app.

SouradeepS 0 Reputation points
2023-01-24T13:50:17.13+00:00

I am trying to deploy an azure function which contains a locally trained and saved cross-encoder model. The function is running perfectly locally. However whenever I am deploying it , I am getting a 500 error and the following error message:

Result: Failure Exception: OSError: /home/site/wwwroot/.python_packages/lib/site-packages/torch/lib/libtorch_global_deps.so: cannot open shared object file: No such file or directory Stack: File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/dispatcher.py", line 357, in _handle__function_load_request func = loader.load_function( File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/utils/wrappers.py", line 44, in call return func(*args, **kwargs) File "/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_worker/loader.py", line 132, in load_function mod = importlib.import_module(fullmodname) File "/usr/local/lib/python3.8/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1014, in _gcd_import File "<frozen importlib._bootstrap>", line 991, in _find_and_load File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 671, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 843, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/home/site/wwwroot/mds_plus_question_prediction/init.py", line 2, in <module> from sentence_transformers.cross_encoder import CrossEncoder File "/home/site/wwwroot/.python_packages/lib/site-packages/sentence_transformers/init.py", line 3, in <module> from .datasets import SentencesDataset, ParallelSentencesDataset File "/home/site/wwwroot/.python_packages/lib/site-packages/sentence_transformers/datasets/init.py", line 1, in <module> from .DenoisingAutoEncoderDataset import DenoisingAutoEncoderDataset File "/home/site/wwwroot/.python_packages/lib/site-packages/sentence_transformers/datasets/DenoisingAutoEncoderDataset.py", line 1, in <module> from torch.utils.data import Dataset File "/home/site/wwwroot/.python_packages/lib/site-packages/torch/init.py", line 188, in <module> _load_global_deps() File "/home/site/wwwroot/.python_packages/lib/site-packages/torch/init.py", line 141, in _load_global_deps ctypes.CDLL(lib_path, mode=ctypes.RTLD_GLOBAL) File "/usr/local/lib/python3.8/ctypes/init.py", line 373, in init self._handle = _dlopen(self._name, mode)

I have also tried to deploy the function using serverless framework, however over there , when I include 'sentence-transformers' in the 'requirement. txt' file, the 'sls deploy' command generates the 'Function App not ready, retrying 1/30' error.

Kindly help me on this.

Thanks.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,212 questions
{count} votes