Is there a way to limit Caffe's CPU core usage? For my instance I have a Xeon E5-2699 and I'd like to limit Caffe to using 9 cores, so 50 percent of the CPU. Most of the training is done on the GPU and I have some other development I would like to work on in the meantime. Is there an easy way to do this? Running CentOS
Asked
Active
Viewed 547 times
4
-
what blas are you using? – Shai Apr 25 '16 at 19:31
-
I'm using OpenBLAS – Dimitri S Apr 27 '16 at 16:24
-
1openblas trends to consume CPU. It uses many threads. you should check how to restrict openblas – Shai Apr 27 '16 at 17:28
-
thank you. adding that to my search came up with this thread: http://stackoverflow.com/questions/30195837/how-to-use-multi-cpu-cores-to-train-nns-using-caffe-and-openblas – Dimitri S Apr 28 '16 at 01:07
2 Answers
0
I am unsure how caffe is invoked, but you can use cgroups to restrict cpu usage for processes on centos6 and onwards. An example to restrict cpu usage to 5 logical cpus:
sudo mkdir -p /sys/fs/cgroup/cpu/fivecpus
sudo bash -c "echo 500000 > /sys/fs/cgroup/cpu/fivecpus/cpu.cfs_quota_us"
sudo bash -c "echo $$ > /sys/fs/cgroup/cpu/fivecpus/tasks"
your_command
Note that 500000 is 5 times the value in /sys/fs/cgroup/cpu/fivecpus/cpu.cfs_period_us

codegrep_admin
- 519
- 4
- 7
0
To limit the cores used by any process, use taskset
.
Install taskset
on CentOS :
sudo yum install util-linux
Then invoke your training/inference script and limit it to use cores 0 to 8 (9 cores) :
taskset -c 0,1,2,3,4,5,6,7,8 <your_command>

MohamedEzz
- 2,830
- 3
- 20
- 26