• redhat配置caffe多核训练


    参考网站:

    http://blog.csdn.net/10km/article/details/52723306

    http://stackoverflow.com/questions/31395729/how-to-enable-multithreading-with-caffe

    redhat配置caffe多核训练

    一、安装openblas

    要利用openblas进行加速

    安装

    1. sudo yum install openblas-devel

    查看安装的路径

    1. rpm -ql openblas-devel

     

     1 /usr/include/openblas
     2 /usr/include/openblas/cblas.h
     3 /usr/include/openblas/f77blas.h
     4 /usr/include/openblas/lapacke.h
     5 /usr/include/openblas/lapacke_config.h
     6 /usr/include/openblas/lapacke_mangling.h
     7 /usr/include/openblas/lapacke_utils.h
     8 /usr/include/openblas/openblas_config.h
     9 /usr/lib64/libopenblas.so
    10 /usr/lib64/libopenblaso.so
    11 /usr/lib64/libopenblasp.so

     

     

    /usr/include/openblas

    /usr/include/openblas/cblas.h

    /usr/include/openblas/f77blas.h

    /usr/include/openblas/lapacke.h

    /usr/include/openblas/lapacke_config.h

    /usr/include/openblas/lapacke_mangling.h

    /usr/include/openblas/lapacke_utils.h

    /usr/include/openblas/openblas_config.h

    /usr/lib64/libopenblas.so

    /usr/lib64/libopenblaso.so

    /usr/lib64/libopenblasp.so

    二、配置Makefile.config

    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 := /usr/include/openblas

    BLAS_LIB := /usr/lib64/openblas

    1. make clean
    2. make all

    三、报错

    make: /usr/local/bin/bin/mexext: Command not found

     

    目测:matlab路径没有配置正确

    查找matlab安装路径

    1. sudo find /usr/local -name mexext

    /usr/local/MATLAB/R2014a/bin/mexext

    配置Makefile.config中MATLAB路径

    MATLAB_DIR := /usr/local/MATLAB/R2014a

     

    1. Make clean
    2. Make –j64 all

    成功

    查看caffe指向的依赖库

    1. ldd build/tools/caffe

    linux-vdso.so.1 => (0x00007fffff5ff000)

        libcaffe.so.1.0.0-rc3 =>

        libopenblas.so.0 => /usr/lib64/libopenblas.so.0 (0x00007f17b58de000)

        ******

     

        libnppc.so.6.5 => /usr/local/cuda-6.5/lib64/libnppc.so.6.5 (0x00007f4d257c6000)

    运行后照旧是单核。

    /usr/lib64下不仅有libopenblas.so.0(单线程版本),还有一个libopenblasp.so.0,这个就是前面软件列表中的openblas-openmpso文件(多线程版本)

    如何利用Makefile配置openblas的库文件没有搞明白。

    因此,查看教程,利用CMake来指定openbals的库为多线程版本,重新编译caffe

    http://blog.csdn.net/10km/article/details/52723306

    四、CMake编译caffe

    于是修改OMP_NUM_THREADS(OPENBLAS_NUM_THREADS)参数减少OpenBlas的线程数再试

    1. export OMP_NUM_THREADS=4
    2. export OPENBLAS_NUM_THREADS=4
    3. echo $ OMP_NUM_THREADS
    4. echo $ OPENBLAS_NUM_THREADS

    关于OMP_NUM_THREADSOPENBLAS_NUM_THREADS的详细用法说明参见OpenBlas github网站》

    重新运行mnist,可以看到cpu跑满4核。

    但是到4核以上会报错

    Segmentation fault,至今没有发现原因。

  • 相关阅读:
    少儿编程之图形编程
    少儿编程是什么?要学吗?如何学?
    AlloyDesigner 使用
    轮播总结
    git实用攻略
    git subtree用法(转)
    vue 插值,v-once,v-text, v-html
    webpack的学习准备工作
    webstorm中github的配置
    less 安装和webstorm的使用
  • 原文地址:https://www.cnblogs.com/yizhichun/p/6437106.html
Copyright © 2020-2023  润新知