问题
I'm trying to build Caffe on Ubuntu 14.04 x64 in VirtualBox with openblas in CPU_ONLY mode.(Enviroment install script , Makefile.config )
Also I'm not compiling OpenBlas, but install it via apt-get
like sudo apt-get -y install libopenblas-dev
, can it be reason of the problem?
After I set any of this variables, there is no speed improvement and in htop
I see only one CPU utilisation.
export OPENBLAS_NUM_THREADS=4
export GOTO_NUM_THREADS=4
export OMP_NUM_THREADS=4
How to check if Caffe use several threads / CPUs?
UPDATE:
I tried caffe binary on MNIST example and it utilise 400% of CPU.
1 thread
I0520 15:58:09.749832 12424 caffe.cpp:178] Use CPU.
...
I0520 16:06:14.553506 12424 caffe.cpp:222] Optimization Done.
~8 min
4 threads
I0520 16:06:44.634735 12446 caffe.cpp:178] Use CPU.
...
I0520 16:13:15.904394 12446 caffe.cpp:222] Optimization Done.
~6.5 min
ps -T -p <PID>
gives me:
export OPENBLAS_NUM_THREADS=1
6 threads
export OPENBLAS_NUM_THREADS=4
9 threads
Seems openblas works, but it depends on network architecture?
Also seems Caffe also use BLAS for conv layers.
回答1:
I'm using the intel branch on CentOS 7.3 and able to see 2500% CPU usage on my Broadwell when training caffenet example. The following is the steps I used to build the tools:
git clone https://github.com/BVLC/caffe.git caffe_intel
cd caffe_intel
git branch -r
git checkout intel
cp Makefile.config.example Makefile.config
# mkl will be automatically download once make is run
# Edit Makefile.config in the following lines
PYTHON_LIB := /usr/lib64
LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib64 /usr/lib
yum install cmake # will be used to build mkl as a sub-routine of make
make -j32 all
make pycaffe
make distribute
cd distribute/lib
ln -s ../../external/mkldnn/install/lib/libmkldnn.so .
And put caffe_intel/distribute/bin in $PATH, caffe_intel/distribute/lib in $LD_LIBRARY_PATH. Also, enable mkl library by adding the following line at the beginning of prototxt file(s)
engine: "MKL2017"
来源:https://stackoverflow.com/questions/37327064/caffe-multi-cpu-build