原文链接:https://blog.csdn.net/zchang81/article/details/73794535
caffe程序的命令行执行格式如下:
caffe <command> <args>
<command>包含如下四种:
train————(训练或finetune模型(model))
test————(测试模型)
device_query————(显示gpu信息)
time————(显示程序执行时间)
<args>参数包含:
-solver
-gpu
-snapshot
-weights
-iteration
-model
-sighup_effect
-sigint_effect
-solver:必选参数。一个protocol buffer类型的文件,即模型的配置文件。如:
./build/tools/caffe train -solver examples/mnist/lenet_solver.prototxt
-gpu: 可选参数。该参数用来指定用哪一块gpu运行,根据gpu的id进行选择,如果设置为'-gpu all'则使用所有的gpu运行。如使用第二块gpu运行:
./build/tools/caffe train -solver examples/mnist/lenet_solver.prototxt -gpu 1
-snapshot:可选参数。该参数用来从快照(snapshot)中恢复训练。如:
./build/tools/caffe train -solver examples/mnist/lenet_solver.prototxt -snapshot examples/mnist/lenet_iter_5000.solverstate
-weights:可选参数。用预先训练好的权重来fine-tuning模型,需要一个caffemodel,不能和-snapshot同时使用。如:
./build/tools/caffe train -solver examples/solver.prototxt -weights models/bvlc_reference_caffenet/bvlc_reference_caffenet.caffemodel
-iterations: 可选参数,迭代次数,默认为50。
-model:可选参数,定义在protocol buffer文件中的模型。也可以在solver配置文件中指定。
-sighup_effect:可选参数。用来设定当程序发生挂起事件时,执行的操作,可以设置为snapshot, stop或none, 默认为snapshot
-sigint_effect: 可选参数。用来设定当程序发生键盘中止事件时(ctrl+c), 执行的操作,可以设置为snapshot, stop或none, 默认为stop
test参数用在测试阶段:
./build/tools/caffe test -model examples/mnist/lenet_train_test.prototxt -weights examples/mnist/lenet_iter_10000.caffemodel -gpu 0 -iterations 100
time参数用来显示程序运行时间:
./build/tools/caffe time -model examples/mnist/lenet_train_test.prototxt -iterations 100
这个例子用来在屏幕上显示lenet模型迭代10次所使用的时间。包括每次迭代的forward和backward所用的时间,也包括每层forward和backward所用的平均时间。
./build/tools/caffe time -model examples/mnist/lenet_train_test.prototxt -weights examples/mnist/lenet_iter_10000.caffemodel -gpu 0 -iterations 10
利用给定的权重,利用第一块gpu,迭代10次lenet模型所用的时间。
device_query参数用来诊断gpu信息。
./build/tools/caffe device_query -gpu 0