Titan X Pascal在VGG16上跑得比基准慢得多

我有一块Titan X Pascal,Intel i5-6600,16GB RAM,在Ubuntu 14.04上运行torch7。 Nvidia驱动版本为375.20,CUDA Toolkit为8.0,cuDNN为v5.1。

我使用与 此基准测试 相同的VGG16网络进行了相同的测试(通过loadcaffe导入)。但是,对于前向传递,我的设置需要80ms,这是基准测试需要的时间的两倍。

我还生成了一批16个RGB通道,尺寸为224x224的图像。相关代码如下:

 local model = loadcaffe.load("/home/.../Models/VGG16/VGG_ILSVRC_16_layers_deploy.prototxt",
                          "/home/.../Models/VGG16/VGG_ILSVRC_16_layers.caffemodel",
                          "cudnn")

 for i=1, 50 do
   local input = torch.randn(16, 3, 224, 224):type("torch.CudaTensor")

   cutorch.synchronize()
   local timer = torch.Timer()

   model:forward(input)
   cutorch.synchronize()

   local deltaT = timer:time().real
   print("前向传递时间:" .. deltaT)
 end

输出如下: 前向传递时间:0.96536016464233 前向传递时间:0.10063600540161 前向传递时间:0.096444129943848 前向传递时间:0.089151859283447 前向传递时间:0.082037925720215 前向传递时间:0.082045078277588 前向传递时间:0.079913139343262 前向传递时间:0.080273866653442 前向传递时间:0.080694913864136 前向传递时间:0.082727193832397 前向传递时间:0.082070827484131 前向传递时间:0.079407930374146 前向传递时间:0.080456018447876 前向传递时间:0.083559989929199 前向传递时间:0.082060098648071 前向传递时间:0.081624984741211 前向传递时间:0.080413103103638 前向传递时间:0.083755016326904 前向传递时间:0.083209037780762 ...

我需要做些什么额外的工作才能获得那种速度?还是我做错了什么?还是因为我使用的是Ubuntu 14.04,而不是Ubuntu 16.04(尽管在基准测试中,运行在Ubuntu 14.04上的GTX 1080也只需要60ms)?

点赞
用户3850759
用户3850759

我终于找到了解决方法。

我需要启用cudnn.benchmark标志:

cudnn.benchmark = true

默认情况下它被设置为false,所以cudnn不会选择最快的算法。现在我的前向时间大约是39ms。

2016-12-29 12:18:06