Teichlab / SpatialDE

Test genes for Spatial Variation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How do we restrict the number of cores used?

sayadennis opened this issue · comments

Dear authors,

Thank you for the great package! I had a quick question: I notice that the workflow is parallelized and it appears that the program automatically detects the number of available cores, but is there a way for the user to explicitly specify the number of cores to be used?

I'm running this on a server that is shared by a few people and don't want it to take up all the available cores on it. I searched a bit for patterns like cpu_count() and didn't find anything, so wanted to hear if you had any instructions.

Thanks in advance!

Just noting here for future reference that I was able to get around this issue by adding the below codes to my Python script where I run SpatialDE, inspired by this Stack Overflow post:

import os
os.environ["OMP_NUM_THREADS"] = "40" # export OMP_NUM_THREADS=1
os.environ["OPENBLAS_NUM_THREADS"] = "40" # export OPENBLAS_NUM_THREADS=1
os.environ["MKL_NUM_THREADS"] = "40" # export MKL_NUM_THREADS=1
os.environ["VECLIB_MAXIMUM_THREADS"] = "40" # export VECLIB_MAXIMUM_THREADS=1
os.environ["NUMEXPR_NUM_THREADS"] = "40" # export NUMEXPR_NUM_THREADS=1

Based on my understanding, the R package can automatically detect the number of cores while Python package doesn't support parallel computation. Don't think the authors are going to add this feature to Python package. But it's truly painful for large dataset.