그래서 기본 회선 레이어의 일부로 구현 된 pycaffe의 회선 기능을 사용하여 놀고있었습니다.Caffe의 회선은 실제로 어떻게 작동합니까?
name: "convolution"
input: "data"
input_dim: 1
input_dim: 1
input_dim: 227
input_dim: 227
layer {
name: "conv"
type: "Convolution"
bottom: "data"
top: "conv"
convolution_param {
num_output: 96
kernel_size: 11
stride: 1
}
}
그 매개 변수 (실제로는 4 보폭, 제외) AlexNet 최초의 CONV 층과 동일하다 : 여기 내 convolution.prototxt
파일입니다.
저는 MacBook Pro에 NVIDIA GeForce GT 650M 1024MB GPU가 있습니다. 그다지 의미는 모르지만 내 노트북에는 인텔 HD 4000이 기본 제공되는 GPU로 있습니다.
나는 랩탑에서 GPU 모드와 CPU에서 스트라이드 하이퍼 파라미터를 변경하면서 몇 가지 테스트를 수행했습니다.
1) 변화시키는 진보 caffe.set_device(0); caffe.set_mode_gpu()
를 호출 한 후 : 진보 다양한
Stride 1: 27.26 ms
Stride 2: 14.27 ms
Stride 3: 10.57 ms
Stride 4: 7.45 ms
2) caffe.set_mode_cpu()
를 호출 한 후 :
Stride 1: 49.77 ms # expected
Stride 2: 9.92 ms # this and the results after this don't make sense
Stride 3: 4.50 ms
Stride 4: 1.96 ms
(
난 그냥 해요) (3)의 의미 Caffe의 회선이이 테스트를 기반으로 작동하는 방식을 이해하려고합니다. 누구든지 이걸 비춰 줄 수 있습니까? CPU 모드가 GPU 모드보다 빠르게 실행되는 이유는 무엇입니까?
테스트 코드는 당신이 자신에 대한보고에 관심이 있다면 사용 :
import numpy as np
import caffe
import time
caffe.set_device(0)
caffe.set_mode_gpu() # caffe.set_mode_cpu()
net = caffe.Net('convolution.prototxt', caffe.TEST)
total = 0.0
for _ in range(3):
net.blobs['data'].data[...] = np.random.randn(1, 1, 227, 227) # there really is an ellipsis there
net.params['conv'][0].data[...] = np.random.randn(96, 1, 11, 11)
s = time.time()
r = net.forward()
e = time.time()
total += (e - s)
print total/3 * 1000