[英]tensorflow: doesn't appear to be using GPU for compute
我已經下載並正在使用 tensorflow 集線器 model。
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'])
我知道我已經正確配置了我的系統,因為其他型號使用 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
但是,當在任務管理器中查看我的資源使用情況時,我的 GPU memory 正在被填充,但我的 GPU 計算 (3D) 活動中沒有任何內容。 然而,CPU 正在做很多工作:
我需要為此 model 專門做些什么,以便它使用 GPU 嗎?
您必須使用MirroredStrategy來告訴 TF 使用 GPU。請參閱使用 Keras 進行分布式訓練,也許可以使用 TPU 上的 BERT 解決 GLUE 任務。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.