Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory Issue while running model as REST service #10

Closed
Rohit8y opened this issue Jul 13, 2021 · 8 comments
Closed

Memory Issue while running model as REST service #10

Rohit8y opened this issue Jul 13, 2021 · 8 comments

Comments

@Rohit8y
Copy link

Rohit8y commented Jul 13, 2021

I'm using a REST service to run WSD model. But it's RAM keeps on increasing as I the number of hits increase. I was testing how much RAM will be enough for this, so at last I used a 64GB server, and it consumed all of it.

This is the code for rest service:-

import requests
import re
import os
import time
import json
from flask import jsonify
from time import sleep
from json import dumps
from flask import Flask, request
from ewiser.spacy.disambiguate import Disambiguator
import spacy

nlp = spacy.load("en_core_web_sm", disable=['parser', 'ner'])
wsd = Disambiguator("/content/ewiser.semcor+wngt.pt", lang="en")
nlp.add_pipe(wsd, last=True)
app = Flask(name)
@app.route("/wsd", methods=['POST'])
def wsd():

print('service ---------------(( + _ + ))----------------- started')
item = {}
x = request.get_json()
print('+++++++++++++++++++++++++++++++++', x)
sent = x['text'] 
doc = nlp(sent)
List = []
for w in doc:
	if w._.offset:
		print(w.text, w.lemma_, w.pos_, w._.offset, w._.synset.definition())
		itm= {}
		itm['lemma']=w.lemma_
		itm['synset']=w._.offset
		itm['gloss']=w._.synset.definition()
		List.append(itm)
print(List) 
return jsonify(List)

if name == "main":
#app.debug = True
app.run(host='localhost', port=7777)

@Rohit8y Rohit8y changed the title How to run on a sample string. Memory Issue while running model as REST service Jul 29, 2021
@Rohit8y
Copy link
Author

Rohit8y commented Jul 29, 2021

@mbevila

@mirfan899
Copy link

I think you need to run the code in a single process:

app.run(host='localhost', port=7777, threaded=False, processes=1)

@mbevila
Copy link
Collaborator

mbevila commented Aug 5, 2021

@Valahaar

@Valahaar
Copy link

Valahaar commented Aug 5, 2021 via email

@mirfan899
Copy link

Does not exist.

https://github.com/jemalloc/jmalloc

This is correct url.
https://github.com/jemalloc/jemalloc

@Valahaar
Copy link

Valahaar commented Aug 5, 2021 via email

@mbevila
Copy link
Collaborator

mbevila commented Aug 21, 2021

@mirfan899 have you solved this?

@mirfan899
Copy link

Yes, I used the single thread, and its working fine for me.

@mbevila mbevila closed this as completed Aug 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants