我无法在GPU上使用转移学习(VGG16)来训练模型

时间:2020-11-03 19:11:28

标签: tensorflow transfer-learning vgg-net

我正在尝试使用迁移学习来训练我的模型,以便在植物图像上检测水稻中的疾病。我尝试使用VGG16,但无法通过GPU进行训练。我有一台NVIDIA GeForce MX150。

下面是我用来拟合模型的代码:

import tensorflow as tf
from tensorflow.python.client import device_lib

print(device_lib.list_local_devices())

with tf.device('/device:GPU:1'):
    # fit the model
    r = model.fit(
        training_set,
        validation_data=test_set,
        epochs=20,
        steps_per_epoch=len(training_set),
        validation_steps=len(test_set)
    )

1 个答案:

答案 0 :(得分:0)

Tensorflow GPU支持需要一些依赖性。请参阅https://www.tensorflow.org/install/gpu

然后尝试tf.test.is_gpu_available()-如果是True,则说明您的GPU正在用于训练。

在单个GPU上,您无需使用with在GPU上进行训练。为我提供更多帮助,请提供任何日志或错误。