Ho una stazione di lavoro con 2 GPU e sto cercando di eseguire più processi tensorflow allo stesso tempo, in modo da poter formare più di un modello in una sola volta, ecctensorflow più sessioni con più GPU
Ad esempio, ho cercato di separare le sessioni in diverse risorse tramite l'API Python usando in script1.py:
with tf.device("/gpu:0"):
# do stuff
in script2.py:
with tf.device("/gpu:1"):
# do stuff
in script3.py
with tf.device("/cpu:0"):
# do stuff
Se eseguo autonomamente ogni script, posso vedere che sta utilizzando il dispositivo specificato. (Anche i modelli si adattano molto bene a una singola GPU e non ne usano un altro anche se sono entrambi disponibili.)
Tuttavia, se uno script è in esecuzione e io cerco di eseguirne un altro, ottengo sempre questo errore:
I tensorflow/core/common_runtime/local_device.cc:40] Local device intra op parallelism threads: 8
I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:909] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
I tensorflow/core/common_runtime/gpu/gpu_init.cc:103] Found device 0 with properties:
name: GeForce GTX 980
major: 5 minor: 2 memoryClockRate (GHz) 1.2155
pciBusID 0000:01:00.0
Total memory: 4.00GiB
Free memory: 187.65MiB
I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:909] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
I tensorflow/core/common_runtime/gpu/gpu_init.cc:103] Found device 1 with properties:
name: GeForce GTX 980
major: 5 minor: 2 memoryClockRate (GHz) 1.2155
pciBusID 0000:04:00.0
Total memory: 4.00GiB
Free memory: 221.64MiB
I tensorflow/core/common_runtime/gpu/gpu_init.cc:127] DMA: 0 1
I tensorflow/core/common_runtime/gpu/gpu_init.cc:137] 0: Y Y
I tensorflow/core/common_runtime/gpu/gpu_init.cc:137] 1: Y Y
I tensorflow/core/common_runtime/gpu/gpu_device.cc:702] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 980, pci bus id: 0000:01:00.0)
I tensorflow/core/common_runtime/gpu/gpu_device.cc:702] Creating TensorFlow device (/gpu:1) -> (device: 1, name: GeForce GTX 980, pci bus id: 0000:04:00.0)
I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:42] Allocating 187.40MiB bytes.
E tensorflow/stream_executor/cuda/cuda_driver.cc:932] failed to allocate 187.40M (196505600 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY
F tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:47] Check failed: gpu_mem != nullptr Could not allocate GPU device memory for device 0. Tried to allocate 187.40MiB
Aborted (core dumped)
Sembra che ogni processo di tensorflow stia cercando di afferrare tutte le GPU sulla macchina quando viene caricato anche se non tutti i dispositivi verranno utilizzati per eseguire il modello.
mi ci vedo è un'opzione per limitare la quantità di GPU ogni processo utilizza
tf.GPUOptions(per_process_gpu_memory_fraction=0.5)
... non ho provato, ma questo mi sembra che sarebbe fare due processi cercano di condividere il 50% di ogni GPU invece di eseguire ogni processo su una GPU separata ...
Qualcuno sa come configurare tensorflow per utilizzare solo una GPU e lasciare l'altra disponibile per un altro processo di tensorflow?
Sto tentando di eseguire più lavori TensorFlow allo stesso tempo. +1 –