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:

(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!


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.


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

ModuleNotFoundError: No module named ‘torch’


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


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

-master file


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/", line 332, in _run_script
    exec(code, module.__dict__)

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

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


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