Re: limiting the number of cpu's used by spacy [resolved]

From: Eric Lease Morgan <emorgan_at_nyob>
Date: Thu, 31 May 2018 17:50:26 -0400
To: CODE4LIB_at_LISTS.CLIR.ORG
On May 29, 2018, at 9:09 AM, Adam Constabaris <adam_constabaris_at_NCSU.EDU> wrote:

> I don't know if spacy has anything built in for this, but I'd recommend
> going in the direction suggested by Flannon and one of the answers on Stack
> Overflow, and use your OS to do the limiting, if it supports that.


Yes, thank you. I do not think there is a Spacy-way to limit the number of processors used in a... process. So I took advantage of a Linux utility called taskset to do the limitation. I added the following line to my Python code, and now my program behaves itself accordingly:

  # limit ourselves is a few processors only
  os.system( "taskset -pc 0-1 %d > /dev/null" % os.getpid() )

Thanks all who replied.

--
Eric Morgan
Received on Thu May 31 2018 - 17:52:20 EDT