20200319のTensorFlowに関する記事は2件です。

Tensorflow v2.x でCould not create cudnn handle: CUDNN_STATUS_INTERNAL_ERRORの対処

環境

バージョン

  • Tensorflow: 2.1.0
  • Ubuntu: 18.04
  • python: 3.6.8
  • CUDA: 10.0.130
  • cuDNN: 7.6.5

原因

TensorflowのGPUメモリ割り当ての問題。だと思う

対処

以下のコードでメモリ割り当てを制限している場合

gpus = tf.config.experimental.list_physical_devices('GPU')
if gpus:
  # Restrict TensorFlow to only use the first GPU
  try:
    tf.config.experimental.set_visible_devices(gpus[0], 'GPU')
    logical_gpus = tf.config.experimental.list_logical_devices('GPU')
    print(len(gpus), "Physical GPUs,", len(logical_gpus), "Logical GPU")
  except RuntimeError as e:
    # Visible devices must be set before GPUs have been initialized
    print(e)

以下↓に変更することで治った。

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)

詳しく(Tensorflow公式Doc)

  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

Tensorflow 2.~ でCould not create cudnn handle: CUDNN_STATUS_INTERNAL_ERRORの対処

環境

バージョン

  • Tensorflow: 2.1.0
  • Ubuntu: 18.04
  • python: 3.6.8
  • CUDA: 10.0.130
  • cuDNN: 7.6.5

原因

TensorflowのGPUメモリ割り当ての問題。だと思う

対処

以下のコードでメモリ割り当てを制限している場合

gpus = tf.config.experimental.list_physical_devices('GPU')
if gpus:
  # Restrict TensorFlow to only use the first GPU
  try:
    tf.config.experimental.set_visible_devices(gpus[0], 'GPU')
    logical_gpus = tf.config.experimental.list_logical_devices('GPU')
    print(len(gpus), "Physical GPUs,", len(logical_gpus), "Logical GPU")
  except RuntimeError as e:
    # Visible devices must be set before GPUs have been initialized
    print(e)

以下↓に変更することで治った。

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)

詳しく(Tensorflow公式Doc)

  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む