Caffe runs in pure CPU mode with multiple cores

I accidentally found a problem. When caffe is training, if it is only in cpu mode, it is super slow. I took a look. The reason is that the program only uses one core for training, so the speed is super slow.

How to solve this problem? You need to specify the use of openblas when compiling caffe, and you need to specify the number of cores used when you use it. The specific operations are as follows


1. First install openblas

-
Bash code
1 sudo apt-get install -y libopenblas-dev

2. Modify the Makefile.config file in the caffe directory and change BLAS: =atlas to BLAS: =open

3. Compile caffe again, first make clean, clear the previous compilation results, and then execute make all -j16, make test -j16, make runtest -j16 in turn to compile caffe. -j16 refers to compiling caffe in parallel with 16 cores, which can greatly speed up the compilation.

4. After the compilation is completed, before the training is performed, you need to export OPENBLAS_NUM_THREADS=4, that is, use 4 cores for training

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325723359&siteId=291194637