使用TensorFlow 2.0.0时:错误:设置XLA_GPU_JIT设备编号0时,设备CUDA:0不受XLA服务支持



我正试图在特斯拉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"的模块

第一个GPU的内存已经由另一个同事分配。我手动选择另一个免费的GPU,只需使用以下代码和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)

相关内容

最新更新