Tensorflow Study Notes 6: solve tensorflow training process GPU is not called problem

1, identify problems
At present a model train takes about 11 seconds, there is no doubt GPU successful call

GPU see whether a successful call, nvidia-smi, interpretation nvidia-smi command

No GPU found in the process of running, GPU has not been called, what is the problem? Need to find the next reason, our first thought is whether tensorflow version GPU version.
 
2, View tensorflow version

The default display called the CPU, then tensorflow version 1.7.0, and also found that calls GPU cuda and cudnn related to checking the time

Our first version to view the next cuda

Version 8.0, and we look at whether there is a conflict of tensorflow version, reference: TensorFlow GPU version summary

Display version 1.5 or higher, to be cuda 9.0 version, and our tensorflow version 1.7, theoretically need more than 9.0 cuda, now there are two ideas:
1, cuda upgrade version;
2, downgrade tensorflow version.
Checked the Internet a little early, cuda upgrade issues you might encounter will be more, let's use the first two kinds of thinking
 
3, tensorflow downgrade to version 1.4
pip install tensorflow-gpu==1.4.0
 
The test run is CPU or GPU
import numpy
import tensorflow as tf
a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
c = tf.matmul(a, b)
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
print(sess.run(c))
之后就会出现详细的信息:

然后设置train.py里面的文件,不同模块找不同模块的train.py文件,在object_detection模块修改一下内容:

修改为False即可,在运行模块,可以发现速度快了很多

服务器终端输入:nvidia-smi,发现已经有相关GPU的进程在跑

 

Guess you like

Origin www.cnblogs.com/zheng1076/p/11239085.html