我知道CAFFE中的几乎所有层都可以运行在CPU/GPU上。在使用GPU的情况下,它有一些模式,称为引擎。如果engine=CAFFE
,它将使用GPU运行,而engine=CUDNN
,它将基于CUDA代码运行。默认模式是DEFAULT模式。
在我的Makefile.config中,我在构建CAFFE时开启了CUDNN模式
# cuDNN acceleration switch (uncomment to build with cuDNN).USE_CUDNN := 1
在我的prototxt中,我有一个层,例如反卷积层
layer { name: "DeconvolutionLayer" type: "Deconvolution" bottom: "conv1" top: "DeconvolutionLayer" param { lr_mult: 1 decay_mult: 1 } convolution_param { num_output: 128 bias_term: false pad: 0 kernel_size: 2 stride: 2 weight_filler { type: "msra" } }}
请注意,我没有为engine
标志设置任何值。当我运行时,会使用哪种模式,GPU还是CUDNN?训练脚本是
caffe/build/tools/caffe train --solver=solver.prototxt -gpu 0
回答:
如果你查看caffe.proto
,它提到"The default for the engine is set by the ENGINE switch at compile-time."
。如果你查看layer_factory.cpp
,如果USE_CUDNN
被设置,那么默认引擎将被设置为cuDNN
。所以在你的情况下是CUDNN。