question

SuperMX-6605 avatar image
0 Votes"
SuperMX-6605 asked SaravananSivaraj-8082 answered

Python Webapp on Azure - PyTorch

Hello!

I have a python web app on Azure.
How can I install torch with requirements.txt?

With the Web SSH, it always restarts.

azure-webapps
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ryanchill avatar image
0 Votes"
ryanchill answered ryanchill commented

Hi @SuperMX-6605,

When you deploy your Python app, Azure App Service will create a virtual environment to and run pip install -r requirements.txt. If you don't see this happening, make sure SCM_DO_BUILD_DURING_DEPLOYMENT is set to 1. See https://docs.microsoft.com/en-us/azure/app-service/configure-language-python for more details. If you're seeing errors during app startup, please comment down below.

· 7
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello @ryanchill , thank you for your answer!

SCM_DO_BUILD_DURING_DEPLOYMENT was already set to 1.
I've tried a lot and it seems the build only fails if i add torch to requirements.txt. But without, of course it cannot find the module.


This is the end of the deployment log:

 *[21:11:00+0000] Collecting numpy
 [21:11:00+0000]   Downloading numpy-1.21.1-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (15.8 MB)
 [21:11:02+0000] Collecting torch
 [21:11:02+0000]   Downloading torch-1.9.0-cp38-cp38-manylinux1_x86_64.whl (831.4 MB)
 An unknown error has occurred. Check the diagnostic log for details.
 Error: Failed to deploy web package to App Service.
 Error: Deployment Failed with Error: Package deployment using ZIP Deploy failed. Refer logs for more details.*
0 Votes 0 ·

@SuperMX-6605 is your app service Windows or Linux hosted?

1 Vote 1 ·

It is linux based but I was able to install it with putting the pytorch path in the requirements.txt! (Install from path).
Do you still want the logs?

0 Votes 0 ·
Show more comments
SaravananSivaraj-8082 avatar image
0 Votes"
SaravananSivaraj-8082 answered

Try adding this to the requirements file. It worked for me.

-f https://download.pytorch.org/whl/torch_stable.html
torch==1.11.0+cpu
torchvision==0.12.0+cpu

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.