help with memory profiling FastAPI application

I'm currently facing a challenge with high memory usage by my FastAPI application hosted on Railway. My API does music source separation using the deep learning library Demucs, and the memory consumption spikes with each API request, accumulating substantial costs. I would really appreciate if anyone here in the community have good suggestions for how I should approach memory profiling or if there are better alternative approaches to troubleshoot this!
No description
No description
No description
Solution:
I honestly don't see much of an issue here with only the screenshots you have provided, yes there is a spike, but it does settle back down to a lower level than what it spiked to, for something that does music source separation with deep learning likely completely in memory that is not a crazy amount of memory at all
Jump to solution
12 Replies
Percy
Percy•7mo ago
Project ID: N/A
kristiankauffeld
kristiankauffeldOP•7mo ago
N/A
Solution
Brody
Brody•7mo ago
I honestly don't see much of an issue here with only the screenshots you have provided, yes there is a spike, but it does settle back down to a lower level than what it spiked to, for something that does music source separation with deep learning likely completely in memory that is not a crazy amount of memory at all
kristiankauffeld
kristiankauffeldOP•7mo ago
@Brody I tried do memory profiling with guppy in the RQ worker, but I don't see anything unusual here either
No description
kristiankauffeld
kristiankauffeldOP•7mo ago
@Brody any other ideas on how I could make requests more cost-effective? $1.60 per request does not seem very scalable to me, but I don't know what the industry standard is either, so maybe I'm being ignorant
Brody
Brody•7mo ago
I mean, I didn't think deep learning was really cost effective to begin with?
kristiankauffeld
kristiankauffeldOP•7mo ago
I think maybe that the initial memory spike is actually caused by the RQ worker downloading Demucs at runtime I'm just baking the model into my Docker image
Brody
Brody•7mo ago
sounds possible
kristiankauffeld
kristiankauffeldOP•7mo ago
@Brody that was the issue 😅
Brody
Brody•7mo ago
just a friendly reminder that pinging is against the rules
kristiankauffeld
kristiankauffeldOP•7mo ago
oh sorry thx for answering my questions
Brody
Brody•7mo ago
no problem
Want results from more Discord servers?
Add your server