I have a docker container running a Python (3.10) Flask app. The app had high baseline memory usage (1 GB+) when loading/idle. The app was formerly dependent on these 17 requirements
dependencies. I removed two dependencies: angle-emb
and sentence-transformers
. torch 2.3.0
is a transitive dependency of angle-emb
.
After removing only the dependencies, and changing zero lines of python code, the memory usage immediately dropped by 63%. I want to know why.
angle-emb~=0.3.10 # Removed
couchbase~=4.2.1
Flask~=3.0.3
Flask-Cors~=4.0.0
Flask-JWT-Extended~=4.6.0
google-cloud-aiplatform~=1.49.0
google-cloud-language~=2.13.3
langchain-community~=0.0.36
numpy~=1.26.4
pandas~=2.2.2
prometheus-flask-exporter~=0.23.0
python-dotenv~=1.0.1
requests~=2.31.0
scikit-learn~=1.4.2
sentence-transformers~=2.7.0. # Removed
tiktoken~=0.6.0
vertexai~=1.49.0
I have read the PyTorch docs and found reference to a thread called pt_main_tread
, and somewhat related StackOverflow posts. All of them are explicitly import
ing invoking PyTorch for training. I had zero code that used PyTorch/AnglE/Sentence-Transformers.
What is the mechanism that is invoking something in PyTorch at Flask startup time, OR, how can I investigate more effectively?