Deploying a PyTorch model

Hello Streamlit team. I am trying to deploy my PyTorch App over streamlit Teams. The app starts well It is able to import numpy etc.

But it does not import torch. I have listed torch in my requirements.txt. May I know if there is something specific for PyTorch to run.

Also since streamlit provides CPU only machines. I would like to run CPU only torch so that I can save up RAM and disk space.
Here is my repo.

I am very happy with streamlit for teams. It was nice simple one click deploy which I liked a lot.

Hey, thanks for the feedback!

You can view the logs for your installation here: http://s4a.streamlit.io/oke-aditya/mantisshrimp_streamlit/master/app.py/+/?logs=1

(Thereā€™s a list of other useful commands here)

It looks like thereā€™s an issue with the random library specified in your requirements file. I donā€™t think you need to specify random in requirements.txt since itā€™s part of the standard library.

Let me know if this helps!

2 Likes

Thank you for the debug. Great. I will retry it and let you know.

Amazing. I was able to run my app on streamlit now. I had to fix up my requirements and add some packages.txt. I was missing a few things. This is so good. I was struggling to do the same with Heroku. Great stuff Streamlit.

2 Likes

torch app run fine locally using streamlit but when deploying it
I face an error of importing torch library

ModuleNotFoundError: No module named ā€˜torchā€™

Traceback:

File "/usr/local/lib/python3.7/site-packages/streamlit/script_runner.py", line 332, in _run_script
    exec(code, module.__dict__)File "/app/ifacade_style/main.py", line 4, in <module>
    import styleFile "/app/ifacade_style/style.py", line 8, in <module>
    import torch

SOLVED

create requirements.txt in your master repositorory and write all libraries needed to run your app
in my case, I put

-master file
requirements.txt
torch
torchvision

Done

1 Like

I am having this same problem. When I go to run my app I get the following error:

ModuleNotFoundError: No module named 'torch'

File "/usr/local/lib/python3.7/site-packages/streamlit/script_runner.py", line 332, in _run_script
    exec(code, module.__dict__)

File "/app/test_application/nlp_app.py", line 3, in <module>
    import torch

I have a requirements.txt file in the main branch of the repository. It includes the following:

|streamlit|
|torch|
|torchvision|
|spacy|
|transformers|
|en_core_web_sm|


As a side note, I am also having problems with the last requirement on that list (ā€œen_core_web_smā€) as well. If anyone has any experience successfully using that module from spacy I could use your input/advice. Thanks!

Found a solution: No module named 'en_core_web_sm' - #7 by Buckeyes2019

1 Like

I canā€™t access both of the links

I canā€™t local run