didri.ru » Новости » Как использовать несколько графических процессоров с TensorFlow
Новости / Программирование

Как использовать несколько графических процессоров с TensorFlow

1 августа 2025, 06:37 840 0 0

Код и tf.keras модели TensorFlow будут прозрачно работать на одном графическом процессоре без необходимости внесения изменений в код.

Примечание didri.ru: используйте tf.config.list_physical_devices('GPU') для подтверждения того, что TensorFlow использует графический процессор.

Самый простой способ запуска на нескольких графических процессорах, на одной или нескольких машинах, — это использование стратегий распределения.

Это руководство предназначено для пользователей, которые опробовали эти подходы и обнаружили, что им необходим детальный контроль над тем, как TensorFlow использует ресурсы графического процессора. Чтобы узнать, как устранять проблемы с производительностью в сценариях с одним и несколькими графическими процессорами, см. руководство «Оптимизация производительности графического процессора TensorFlow» .

Настраивать
Убедитесь, что у вас установлена последняя версия графического процессора TensorFlow.

import tensorflow as tf
print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))


2024-08-15 02:53:40.344028: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:485] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
2024-08-15 02:53:40.365851: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:8454] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
2024-08-15 02:53:40.372242: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1452] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
Num GPUs Available: 4
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
I0000 00:00:1723690422.944962 162671 cuda_executor.cc:1015] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355
I0000 00:00:1723690422.948934 162671 cuda_executor.cc:1015] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355
I0000 00:00:1723690422.952655 162671 cuda_executor.cc:1015] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355
I0000 00:00:1723690422.955880 162671 cuda_executor.cc:1015] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355
I0000 00:00:1723690422.967120 162671 cuda_executor.cc:1015] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355
I0000 00:00:1723690422.970596 162671 cuda_executor.cc:1015] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355
I0000 00:00:1723690422.973980 162671 cuda_executor.cc:1015] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355
I0000 00:00:1723690422.976984 162671 cuda_executor.cc:1015] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355
I0000 00:00:1723690422.979869 162671 cuda_executor.cc:1015] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355
I0000 00:00:1723690422.983344 162671 cuda_executor.cc:1015] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355
I0000 00:00:1723690422.986754 162671 cuda_executor.cc:1015] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero. See more at https://github.com/torvalds/linux/blob/v6.0/Documentation/ABI/testing/sysfs-bus-pci#L344-L355
I0000 00:00:1723690422.989690 162671 cuda_executor.cc:1015] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning

Обзор
TensorFlow поддерживает выполнение вычислений на различных типах устройств, включая центральные и графические процессоры. Они представлены строковыми идентификаторами, например:

"/device:CPU:0": Центральный процессор вашего компьютера.
"/GPU:0": Сокращенное обозначение первого графического процессора вашей машины, который виден TensorFlow.
"/job:localhost/replica:0/task:0/device:GPU:1": Полное имя второго графического процессора вашей машины, которое видно TensorFlow.
Если операция TensorFlow реализуется как на CPU, так и на GPU, по умолчанию приоритет отдаётся устройству GPU при назначении операции. Например, если tf.matmul есть ядра CPU и GPU, а в системе с устройствами CPU:0 и GPU:0, GPU:0 то для запуска будет выбрано устройство, tf.matmul если только вы явно не запросите запуск на другом устройстве.

Если операция TensorFlow не имеет соответствующей реализации на графическом процессоре, то она возвращается к использованию центрального процессора. Например, поскольку tf.cast имеется только ядро центрального процессора, в системе с устройствами CPU:0 и для запуска выбирается устройство GPU:0, даже если запрос на запуск был отправлен на устройство.CPU:0tf.castGPU:0

Продолжение – будет.

Didri.ru: Как использовать несколько графических процессоров с TensorFlow

Как, использовать, несколько, графический процессор, TensorFlow

Поделится
0 0

Комментарии