I have a script :
from deepmultilingualpunctuation import PunctuationModel
import tensorflow as tf
tf.debugging.set_log_device_placement(True)
gpus = tf.config.list_physical_devices('GPU')
if gpus:
# Restrict TensorFlow to only use the first GPU
try:
tf.config.set_visible_devices(gpus[0], 'GPU')
logical_gpus = tf.config.list_logical_devices('GPU')
print(len(gpus), "Physical GPUs,", len(logical_gpus), "Logical GPU")
except RuntimeError as e:
# Visible devices must be set before GPUs have been initialized
print(e)
model = PunctuationModel()
# text = "My name is Clara and I live in Berkeley California Ist das eine Frage Frau Müller"
result = model.restore_punctuation(text)
print(result)
I run the script and it works fine but it uses both the GPU (a little) and the CPU (50% utilisation)
this is what is in the run window
2022-08-15 15:06:20.670490: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2022-08-15 15:06:21.460364: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1532] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 10815 MB memory: -> device: 0, name: Tesla K80, pci bus id: 0000:09:00.0, compute capability: 3.7
2 Physical GPUs, 1 Logical GPU
C:\Users\five\anaconda3\envs\tf10\lib\site-packages\transformers\pipelines\token_classification.py:135: UserWarning: `grouped_entities` is deprecated and will be removed in version v5.0.0, defaulted to `aggregation_strategy="none"` instead.
warnings.warn(
Any help would be appreciated.
P.S I have had this running fine utilising the GPU but single and spread load :
import os
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "2"
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
from tensorflow.keras.datasets import cifar10
(x_train, y_train), (x_test, y_test) = cifar10.load_data()
x_train = x_train.astype("float32") / 255.0
x_test = x_test.astype("float32") / 255.0
model = keras.Sequential(
[
keras.Input(shape=(32, 32, 3)),
layers.Conv2D(32, 3, padding="valid", activation="relu"),
layers.MaxPooling2D(),
layers.Conv2D(64, 3, activation="relu"),
layers.MaxPooling2D(),
layers.Conv2D(128, 3, activation="relu"),
layers.Flatten(),
layers.Dense(64, activation="relu"),
layers.Dense(10),
]
)
def my_model():
inputs = keras.Input(shape=(32, 32, 3))
x = layers.Conv2D(32, 3)(inputs)
x = layers.BatchNormalization()(x)
x = keras.activations.relu(x)
x = layers.MaxPooling2D()(x)
x = layers.Conv2D(64, 3)(x)
x = layers.BatchNormalization()(x)
x = keras.activations.relu(x)
x = layers.MaxPooling2D()(x)
x = layers.Conv2D(128, 3)(x)
x = layers.BatchNormalization()(x)
x = keras.activations.relu(x)
x = layers.Flatten()(x)
x = layers.Dense(64, activation="relu")(x)
outputs = layers.Dense(10)(x)
model = keras.Model(inputs=inputs, outputs=outputs)
return model
model = my_model()
model.compile(
loss=keras.losses.SparseCategoricalCrossentropy(from_logits=True),
optimizer=keras.optimizers.Adam(lr=3e-4),
metrics=["accuracy"],
)
model.fit(x_train, y_train, batch_size=64, epochs=10, verbose=2)
model.evaluate(x_test, y_test, batch_size=64, verbose=2)
And not a problem with GPU - Results =
Epoch 1/10
782/782 - 9s - loss: 1.3355 - accuracy: 0.5256 - 9s/epoch - 12ms/step
Epoch 2/10
782/782 - 5s - loss: 0.9657 - accuracy: 0.6622 - 5s/epoch - 6ms/step
Epoch 3/10
782/782 - 5s - loss: 0.8171 - accuracy: 0.7158 - 5s/epoch - 6ms/step
Epoch 4/10
782/782 - 5s - loss: 0.7092 - accuracy: 0.7558 - 5s/epoch - 6ms/step
Epoch 5/10
782/782 - 5s - loss: 0.6288 - accuracy: 0.7822 - 5s/epoch - 6ms/step
Epoch 6/10
782/782 - 5s - loss: 0.5617 - accuracy: 0.8074 - 5s/epoch - 6ms/step
Epoch 7/10
782/782 - 5s - loss: 0.5014 - accuracy: 0.8271 - 5s/epoch - 6ms/step
Epoch 8/10
782/782 - 5s - loss: 0.4489 - accuracy: 0.8456 - 5s/epoch - 6ms/step
Epoch 9/10
782/782 - 5s - loss: 0.3961 - accuracy: 0.8671 - 5s/epoch - 6ms/step
Epoch 10/10
782/782 - 5s - loss: 0.3488 - accuracy: 0.8832 - 5s/epoch - 6ms/step
157/157 - 1s - loss: 0.9133 - accuracy: 0.7200 - 671ms/epoch - 4ms/step
Process finished with exit code 0
So I dont think it my setup?
I am Facing the same thing.
What is the error or you are having? Are you using colab or local system with GPU
Paste your error here
there’s no error the script only uses the cpu not the gpu. But my other scripts use my k80 gpu without any problem.
This indicates that GPU is being used and is due to a small model for making full use of the GPU’s resources. There is no problem here. Thank you!