我试图在TeslaV100-SXM2 GPU上运行一个CuDNNLSTM层,但是由于TensorFlow-GPU2.0.0安装了错误(不能降级,因为是共享服务器)。
Tf2.0.0不推荐ConfigProto选项,因此以前的线程(如this )没有帮助。
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)如果我使用此代码行,则会显示另一个错误:
模块notfoundError:没有名为“tensorflow.contrib”
的模块
发布于 2019-11-08 14:55:29
第一个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)https://stackoverflow.com/questions/58727767
复制相似问题