1

I'm trying to run a CuDNNLSTM layer on Tesla V100-SXM2 GPU, but error appears due to TensorFlow-gpu 2.0.0 installed (can not downgrade because is a shared server).

ConfigProto options are deprecated at tf 2.0.0, so previous threads like this does not help.

os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"
os.environ["CUDA_VISIBLE_DEVICES"] = "2"  # Or 2, 3, etc. other than 0

tf.config.gpu.set_per_process_memory_growth(True)
tf.config.set_soft_device_placement(True)

If I use this code lines, another error shows up:

module notfoundError: no module named 'tensorflow.contrib'

4b0
  • 21,981
  • 30
  • 95
  • 142
Periko
  • 21
  • 4

1 Answers1

1

it was that the first GPU's memory was already allocated by another workmate. I mannage to select another free GPU just by using the following code and ie. input = 'gpu:3'

def config_device(computing_device):
if 'gpu' in computing_device:
    device_number = computing_device.rsplit(':', 1)[1]
    os.environ["CUDA_VISIBLE_DEVICES"] = device_number
# with tf.device(computing_device):

gpus = tf.config.experimental.list_physical_devices('GPU')
if gpus:
    try:
        # Currently, memory growth needs to be the same across GPUs
        for gpu in gpus:
            tf.config.experimental.set_memory_growth(gpu, True)
        logical_gpus = tf.config.experimental.list_logical_devices('GPU')
        print(len(gpus), "Physical GPUs,", len(logical_gpus), "Logical GPUs")
    except RuntimeError as e:
        # Memory growth must be set before GPUs have been initialized
        print(e)
Periko
  • 21
  • 4