提高运行Caffe时的CPU使用率

在训练网络时发现CPU使用率低,为了提高其使用率,进而实现加速,本文参考了两篇博客,最终采用OpenBLAS实现。

参考的两篇博客地址如下,在此表示感谢:
https://www.cnblogs.com/llxrl/p/5292119.html
http://blog.csdn.net/quhediegooo/article/details/53082809


在实验过程中的具体实现步骤如下:

  1. apt-get install libopenblas-dev (没有这一步会报错)
  2. git clone https://github.com/xianyi/OpenBLAS.git (由于是在云服务器上实现,网络带宽较小,速度很慢,所以是先下载在本地主机上后再上传的服务器的)
  3. cd OpenBLAS
  4. make -jn (n为使用的核数)
  5. make PREFIX=/root/OpenBLAS install (由于是在云服务器,最好是先查一下当前所在路径pwd命令,我的是/root/OpenBLAS)
  6. 修改caffe中Makefile.config配置文件中的参数:
# open for OpenBlas
BLAS := open
# Custom (MKL/ATLAS/OpenBLAS) include and lib directories.
# Leave commented to accept the defaults for your choice of BLAS
# (which should work)!
# 注意填写正确的路径
BLAS_INCLUDE := /root/OpenBLAS/include  
BLAS_LIB := /root/OpenBLAS/lib

7.添加环境变量:

export OPENBLAS_NUM_THREADS=n   (n为使用的核数)
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/root/OpenBLAS/lib/ 

8.重新编译caffe:

make clean
make all -jn   (n为使用的核数)
make test 
make runtest

9.修改成功,测试发现CPU使用率提升

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值