How to deploy WebApp with heavy packages like torch

Arindam Bhattacharjee 0 Reputation points
2024-11-13T06:59:55.3566667+00:00

I am trying to deploy a flask application as web app. But unable to do so-

  1. I tried using requirements.txt file to deploy the code, but it fails everytime
  2. I tried using the below in Startup Command-

pip install --upgrade pip

pip install torch==1.7.1 --no-cache-dir
pip install openai-whisper --no-cache-dir
pip install scipy==1.7.1 --no-cache-dir
pip install werkzeug==2.0.3 --no-cache-dir
pip install Flask==2.0.1 --no-cache-dir

gunicorn --workers 4 --bind 0.0.0.0:$PORT app:app

But it also keeps running for hours but doesn't complete and URl not loading.

Yes, due to torch and openai-whisper it's delaying a lot.

But isn't there any way to deploy a web app using these packages ?

Using App-Service_Plan with Basic-B1 and runtime version Python 3.9

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,940 questions
{count} votes

1 answer

Sort by: Most helpful
  1. VenkateshDodda-MSFT 24,951 Reputation points Microsoft Employee Moderator
    2024-11-15T11:20:56.8633333+00:00

    @Arindam Bhattacharjee Thanks for reaching out to Microsoft Q&A, apologize for any inconvenience caused on this.

    You can follow this blog post steps to configure custom startup in python app service. I understand that your app is hosted on B1, and it is taking longer time to load and service the requests.

    As you application needs heavy package like torch and OpenAI-whisper try scaling out the app service plan to standard or premium which come with more CPU, storage and memory when compared to basic plans which can help in reducing the container runtime.

    Hope this helps, let me know if you have any further questions on this.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.