tf.test.gpu_device_name
Возвращает имя устройства GPU, если оно доступно, или пустую строку.
tf.test.gpu_device_name() -> str
Используется в ноутбуках
| Используется в учебниках |
|---|
Этот метод следует использовать только в тестах, написанных с помощью tf.test.TestCase.
class MyTest(tf.test.TestCase):
def test_add_on_gpu(self):
if not tf.test.is_built_with_gpu_support():
self.skipTest("test is only applicable on GPU")
with tf.device(tf.test.gpu_device_name()):
self.assertEqual(tf.math.add(1.0, 2.0), 3.0)
© 2022 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 4.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/test/gpu_device_name