Tensorflow model.fit freeze in Streamlit

I have created a local streamlit app to train tensorflow-based deep learning model. When the function model.fit(…) is being executed, it echos that Epoch 1/… and then hangs.

I have executed the code without streamlit. It is working well.It just hangs in streamlit mode execution. It does not throw any error.

Python Version::3.11.9
Streamlit Version:1.36.0
Tensorflow Version:2.16.1

I also tried another environment, where it is failed.
Python version: 3.11.5
Streamlit version: 1.35.0
Tensorflow version: 2.12.0

Any suggestions, to resolve this issue.

This is probably due to a different version of… something.

Thanks. Yes, some common dependent packages of streamlit and tensorflow conflict.
Do I have raise issue? Please let me know

You just need to solve the conflicts.

Unable to figure it out which dependent packages…

I need to downgrade tensorflow to 2.10 and streamlit to 1.32 to make it work.

By Downgrading tensorflow, missing needed new features of tensorflow

Well I don’t know what conflicts you are having with other version so what can I do.

Just in case, make sure you have numpy<2 since some packages appear to be compatible with numpy==2 but they actually aren’t.

Suggestion 1: caching the expensive calls might help

Suggestion 2: solve the dependencies conflicts without downgrading, but instead upgrading.
Pass an updated tensorflow version in the requirements.txt file (specify which version).

Suggestion 3: If that didn’t work, pass it as a GitHub repo in the requirements.txt with prefixing the repo link with git+ (see this)

I found after installing pyarrow==16.1.0 which is required by streamlit, tensorflow will stuck at epoch 1 if the model includes a convolutional layer and whether it’s running in streamlit or not. after downgrading pyarrow to 15.0.0 the problem solved.
Hope this could help!

I had the same problem : the fit() was in a librairy imported in the streamlit file.
Once I have dropped the tensorflow code directly in the streamllit file : it works!
I have no satisfying explaination …

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.