zoukankan      html  css  js  c++  java
  • linux下caffe的命令运行脚本

    参考:https://www.cnblogs.com/denny402/p/5076285.html

    首先编译:

    make -j8

    make pycaffe

    注:下面的--solver=.... 等价于 -solver ....

    ########################## -solver:必选参数 ###################
    set -e
    ./build/tools/caffe train
    --solver=examples/mnist/lenet_solver.prototxt -gpu 2
    #gpu 2表示用第2块gpu运行,如果设置为"-gpu all"表示使用所有的gpu运行

    ######################-snapshot:可选参数,-gpu:可选参数 #############
    #加上断点的训练
    set -e
    ./build/tools/caffe train
    --solver=examples/mnist/lenet_solver.prototxt
    --snapshot=examples/mnist/snapshot/lenet_solver_iter_400.solverstate

    ######################## -weights:可选参数 #################
    #用预先训练好的权重来fine-tuning模型,需要一个caffemodel,不能和-snapshot同时使用
    set -e
    ./build/tools/caffe train
    --solver=examples/mnist/lenet_solver.prototxt
    #这里放训练好的模型参数caffemodel
    --weights=models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel


    ########### test参数用在测试阶段,用于最终结果的输出,要配置模型中设定输入accuracy或loss,若我们在验证集中已训练好模型,则可以这么写(用caffe自带的测试方法)###################################

    ./build/tools/caffe test --model=examples/mnist/lenet_train_test.prototxt
    --weights=examples/mnist/lenet_iter_10000.caffemodel -gpu 0 -iterations 100

    ############## time参数在屏幕上显示程序运行时间 ##################
    ###########可以在屏幕上显示lenet模型迭代10次所用的时间,包括每次迭代的forward和backward所用的时间##############
    ############也包括每层forward和backward所用的平均时间###################
    ./build/tools/caffe time --model=examples/mnist/lenet_train_test.prototxt -gup 0 -iterations 10


    ########### 利用给定的权重,利用第一块gpu,迭代10次lenet模型所用的时间 #################
    ./build/tools/caffe time --model=examples/mnist/lenet_train_test.prototxt
    --weights=examples/mnist/lenet_iter_10000.caffemodel -gpu 0 -iterations 10


    ############### device_query参数诊断gpu信息 ##############
    ./build/tools/caffe device_query -gpu 0


    ################# 2个关于gpu的例子 #####################
    ./build/tools/caffe train --solver=examples/mnist/lenet_solver.prototxt -gpu 0,1
    ./build/tools/caffe train --solver=examples/mnist/lenet_solver.prototxt -gpu all
    #这2个例子说明:用2块或多块GPU来平行运算,速度会快很多;但是如果只有1块或没有GPU,就不要加-gpu参数了,加了反而更慢


    #######最后在linux下本身就有1个time命令,因此可以结合使用,因此运行mnist例子的最终命令(1块GPU)############
    sudo time ./build/tools/caffe train --solver=examples/mnist/lenet_solver.prototxt

  • 相关阅读:
    android开发 退出程序
    armeabi和armeabi-v7a引起的问题
    我的博客
    第二章 应用层(一) 应用层概览
    第一章 计算机网络和因特网
    Linux学习笔记——第一篇——Ubuntu安装与操作
    怒学Python——完结篇——I/O
    怒学Python——第四篇——函数与模块
    怒学Python——第三篇——结构控制
    怒学Python——第二篇——类型与运算
  • 原文地址:https://www.cnblogs.com/xiaochouk/p/9271499.html
Copyright © 2011-2022 走看看