如何知道 CAFFE 代码是 运行 使用 GPU 还是 CUDA 代码?
How to know if CAFFE code is running using GPU or CUDA code?
我知道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中,我有一个层,例如Deconvolution层
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。
我知道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中,我有一个层,例如Deconvolution层
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。