tensorflow icon indicating copy to clipboard operation
tensorflow copied to clipboard

zombie process resulting from using many GPUs

Open digitalsword opened this issue 10 years ago • 9 comments

I run the example cifar10_multi_gpu_train.py on a PC equipped with 4 GPUs. Somehow the program occupies 4 GPUs, but only the first GPU is doing computation.

When I hit ctrl + c, the python scripts did not terminate, and I found zombie process using htop (the zombie process is associated with command python). After that I have to reboot using "reboot -nf" to gain access to GPUs. Tensorflow was installed from source (https://github.com/tensorflow/tensorflow.git).

  File "cifar10_multi_gpu_train.py", line 270, in <module>
    tf.app.run()
  File "/home/pc/anaconda2/lib/python2.7/site-packages/tensorflow/python/platform/default/_app.py", line 30, in run
    sys.exit(main(sys.argv))
  File "cifar10_multi_gpu_train.py", line 266, in main
    train()
  File "cifar10_multi_gpu_train.py", line 236, in train
    _, loss_value = sess.run([train_op, loss])
  File "/home/pc/anaconda2/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 373, in run
    results = self._do_run(target_list, unique_fetch_targets, feed_dict_string)
  File "/home/pc/anaconda2/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 433, in _do_run
    target_list)
KeyboardInterrupt

However, if I do export CUDA_VISIBLE_DEVICES=0 before running the example to limit it to one GPU, I am able to terminate the python scripts normally using ctrl + c.

nvidia-smi screenshot 2015-12-31 10 58 57

htop screenshot 2015-12-31 11 01 15

digitalsword avatar Dec 31 '15 16:12 digitalsword

I noticed a similar bug as well, it also is a function of when you do ctrl-c, quite often I've had TensorFlow crash the driver. I presume there must be a NVIDIA driver bug as well, since a user process should never be able to crash a kernel driver...

wchan avatar Jan 02 '16 19:01 wchan

@wchan I was able to do multi-GPU training with tensorflow 0.5, but not with tensorflow 0.6. Did you find this problem? When you use multiple GPUs, do all GPUs work normally? When you do ctrl+c, does it crash the driver every time?

I was using the official example cifar10_multi_gpu_train.py to test multi-GPU training

digitalsword avatar Jan 04 '16 15:01 digitalsword

I was running in to the same issue. Specifically, I could replicate it by

  1. starting a python prompt and running

    import tensorflow as tf
    sess = tf.InteractiveSession()
    
  2. killing the python process

The python process would not die and any other code that used the GPU driver (including simply running nvidia-smi) would hang on a read to /dev/nvidiactl. Setting CUDA_VISIBLE_DEVICES prevented the problem.

After turning on persistence mode (as below) I no longer observed this problem.

$ nvidia-smi -pm 1

mcogswell avatar Feb 19 '16 02:02 mcogswell

@mcogswell what does persistence mode do? Does this solve multi-GPU training case?

digitalsword avatar Feb 19 '16 14:02 digitalsword

Persistence mode keeps the driver loaded even when not used. I'm not sure about the cifar10 example script, but I see no reason why it should be different.

mcogswell avatar Feb 19 '16 15:02 mcogswell

Same problem here, we are using Titan Z which has dual GPU. The python process would not die and any other code that used the GPU driver (including simply running nvidia-smi) would hang. export CUDA_VISIBLE_DEVICES=0 solved the probelm

yil8 avatar Mar 12 '16 01:03 yil8

This could be related to this problem:

https://groups.google.com/forum/#!msg/torch7/kLusyLEj4oc/uwbK1GiQDwAJ

This is an issue associated with kernel version and cuda drivers when multiple GPUs are being used.

Using Nicholas Leonard's instructions at the end solved this issue for me, without having to use CUDA_VISIBLE_DEVICES.

yamins81 avatar Apr 17 '16 17:04 yamins81

Closing because yamins81 provided a solution. Feel free to reopen if this is still a problem!

itsmeolivia avatar May 16 '16 17:05 itsmeolivia

I wish this issue is reopened since @yamins81's solution still doesn't solve the problem of not being able to use multiple GPUs.

kaniblu avatar Jun 09 '16 06:06 kaniblu