以下是我的预测代码:
start=time.time()
with tf.Session(graph=graph) as sess:
predict('/home/4_bikes/test_images/bikerider4.jpg',sess)
predict('/home/4_bikes/test_images/bikerider4.jpg',sess)
predict('/home/4_bikes/test_images/bikerider4.jpg',sess)
predict('/home/4_bikes/test_images/bikerider4.jpg',sess)
predict('/home/4_bikes/test_images/bikerider4.jpg',sess)
predict('/home/4_bikes/test_images/bikerider4.jpg',sess)
predict('/home/4_bikes/test_images/bikerider4.jpg',sess)
predict('/home/4_bikes/test_images/bikerider4.jpg',sess)
predict('/home/4_bikes/test_images/bikerider4.jpg',sess)
stop=time.time()
print('Time taken for prediction :: {}'.format(stop-start))
下面是我的predict
函数:
我已经在python-2上安装了tensorflowgpu,在python-3上安装了tensorflowcpu。当我用tensorflow gpu运行它时,我得到:
Time taken for prediction :: 2.92091107368
使用tensorflow cpu运行时,我得到:
Time taken for prediction :: 1.7942276000976562
我确信我使用的是GPU,因为在运行python-2时,我会得到以下日志:
name: GeForce GTX 1080 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.6705
pciBusID: 0000:01:00.0
totalMemory: 10.91GiB freeMemory: 10.28GiB
2018-05-31 18:23:26.762628: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1435] Adding visible gpu devices: 0
2018-05-31 18:23:26.906629: I tensorflow/core/common_runtime/gpu/gpu_device.cc:923] Device interconnect StreamExecutor with strength 1 edge matrix:
2018-05-31 18:23:26.906672: I tensorflow/core/common_runtime/gpu/gpu_device.cc:929] 0
2018-05-31 18:23:26.906679: I tensorflow/core/common_runtime/gpu/gpu_device.cc:942] 0: N
2018-05-31 18:23:26.906856: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1053] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 9949 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:01:00.0, compute capability: 6.1)
每次调用predict
。在
有人能帮我吗?我哪里错了?当使用GPU时,所花的时间应该更少。在
对于安装,我遵循了this链接。在
我正在使用英伟达GeForce GTX 1080 Ti。在
CPU是英特尔(R)酷睿(TM)i7-7700K CPU
型号为MobileNet_v1
你用的是哪个GPU之王。据我所知,Tensorflow似乎对cuda->;Nvidia进行了优化
也许尝试在创建会话之后
start=time.time()
把这段代码放在with tf.Session(graph=graph) as sess:
之后对我来说,用gpu创建会话需要更多的时间,但是预测速度很快。 你有没有试过著名的型号,我的意思是你的gpu第一次表现不佳?也许可以试试VGG Nets,你可以从here找到基准,并与你的gpu进行比较。如果你的gpu出了问题,请关注它,但也许这是关于你的模型的,有时模型在cpu上的性能要好得多
相关问题 更多 >
编程相关推荐