Contents ...
udn網路城邦
網站架設 Tensorflow GPU 運算出現 failed to create cublas handle 訊息
2024/03/16 00:59
瀏覽29
迴響0
推薦0
引用0
網站架設
  1. import tensorflow as tf
  2. # 只利用 30% 的 GPU 記憶體
  3. gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.3)
  4. sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options))
  5. # 設定 Keras 利用的 TensorFlow Session
  6. tf.keras.backend.set_session(sess)
  7. # 利用 Keras 建立模型
  8. # ..
複製代碼

1.png


解決方式
1. 指定 GPU 顯示卡



2. 指定 GPU 記憶體的佔用量

  1. import tensorflow as tf
  2. # 自動增加 GPU 記憶體用量
  3. gpu_options = tf.GPUOptions(allow_growth=True)
  4. sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options))
  5. # 設定 Keras 利用的 Session
  6. tf.keras.backend.set_session(sess)
  7. # 使用 Keras 設立建設模子
  8. # ..
複製代碼

用GPU RUN PYTHON時,
出現錯誤訊息
 

  1. failed to create cublas handle: cublas_status_alloc_failed
複製代碼



3.主動增加 GPU 記憶體用量

  1. import os
  2. # 使用第一張與第三張 GPU 卡
  3. os.environ["CUDA_VISIBLE_DEVICES"] = "0,2"
  4.  
複製代碼



4. 若是仍是不可
換CUDA跟CUDNN版本

文章出處: NetYea網頁設計

你可能會有興趣的文章:

限會員,要發表迴響,請先登入