1
1

More than 3 years have passed since last update.

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

Last updated at Posted at 2020-03-19

環境

バージョン

  • 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)

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1