1

我正在尝试在 Tesla V100-SXM2 GPU 上运行 CuDNNLSTM 层,但由于安装了 TensorFlow-gpu 2.0.0(无法降级,因为是共享服务器)而出现错误。

ConfigProto 选项在 tf 2.0.0 中已弃用,因此以前的此类线程无济于事。

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)

如果我使用此代码行,则会出现另一个错误:

模块未找到错误:没有名为“tensorflow.contrib”的模块

4

1 回答 1

1

那是第一个GPU的内存已经被另一个同事分配了。我只需使用以下代码和 ie 就可以选择另一个免费的 GPU。输入 = '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)
于 2019-11-08T14:55:29.353 回答