简体   繁体   English

tensorflow:似乎没有使用 GPU 进行计算

[英]tensorflow: doesn't appear to be using GPU for compute

I have downloaded and am using a tensorflow hub model.我已经下载并正在使用 tensorflow 集线器 model。

The model creation code is: model创建码为:

model_url = "https://tfhub.dev/google/imagenet/mobilenet_v3_large_075_224/feature_vector/5"  # "https://tfhub.dev/google/imagenet/resnet_v2_152/feature-vector/4"

model = tf.keras.Sequential([
    tf.keras.layers.InputLayer(input_tensor=input_tensor),
    hub.KerasLayer(model_url, trainable=do_fine_tuning),
    tf.keras.layers.Dropout(rate=0.2),
    tf.keras.layers.Dense(len(class_names),
                          kernel_regularizer=tf.keras.regularizers.l2(0.0001))
])
model.build((None,) + IMAGE_SIZE + (3,))
model.summary()

model.compile(
    optimizer=tf.keras.optimizers.SGD(learning_rate=0.005, momentum=0.9),
    loss=tf.keras.losses.CategoricalCrossentropy(from_logits=True, label_smoothing=0.1),
    metrics=['accuracy'])

I know I've configured my system correctly as other models use the GPU, and my tensorflow output includes the following:我知道我已经正确配置了我的系统,因为其他型号使用 GPU,而我的 tensorflow output 包括以下内容:

2022-02-07 14:39:24.415320: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: NVIDIA GeForce GTX 1080 computeCapability: 6.1
coreClock: 1.7715GHz coreCount: 20 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 298.32GiB/s
2022-02-07 14:39:24.415404: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.10.1
2022-02-07 14:39:24.425868: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcublas.so.10
2022-02-07 14:39:24.426021: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcublasLt.so.10
2022-02-07 14:39:24.439115: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcufft.so.10
2022-02-07 14:39:24.441114: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcurand.so.10
2022-02-07 14:39:24.448086: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcusolver.so.10
2022-02-07 14:39:24.452371: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcusparse.so.10
2022-02-07 

However, when looking at my resource usage in task manager my GPU memory is being filled, but there's nothing in my GPU compute (3D) activity.但是,当在任务管理器中查看我的资源使用情况时,我的 GPU memory 正在被填充,但我的 GPU 计算 (3D) 活动中没有任何内容。 CPU however is doing a lot of work:然而,CPU 正在做很多工作:

在此处输入图像描述

Is there something I need to do for this model specifically so that it uses the GPU?我需要为此 model 专门做些什么,以便它使用 GPU 吗?

You have to use a MirroredStrategy to tell TF to use the GPU. See Distributed training with Keras and perhaps Solve GLUE tasks using BERT on TPU .您必须使用MirroredStrategy来告诉 TF 使用 GPU。请参阅使用 Keras 进行分布式训练,也许可以使用 TPU 上的 BERT 解决 GLUE 任务

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM