4

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

Dimitri S
  • 81
  • 4

2 Answers2

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