TShopping

 找回密碼
 註冊
搜索
查看: 385|回復: 0
打印 上一主題 下一主題

[教學] Tensorflow GPU 運算出現 failed to create cublas handle 訊息

[複製鏈接]
跳轉到指定樓層
1#
發表於 2023-8-17 21:46:13 | 只看該作者 |只看大圖 回帖獎勵 |倒序瀏覽 |閱讀模式
 
Push to Facebook
用GPU RUN PYTHON時,
出現錯誤訊息

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



解決方法
1. 指定 GPU 顯示卡
  1. import os
  2. # 使用第一張與第三張 GPU 卡
  3. os.environ["CUDA_VISIBLE_DEVICES"] = "0,2"
複製代碼


2. 指定 GPU 記憶體的佔用量
  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. # ..
複製代碼


3.自動增長 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. # ..
複製代碼


4. 如果還是不行
換CUDA跟CUDNN版本

文章出處: NetYea網頁設計

 

臉書網友討論
*滑块验证:
您需要登錄後才可以回帖 登錄 | 註冊 |

本版積分規則



Archiver|手機版|小黑屋|免責聲明|TShopping

GMT+8, 2024-5-20 22:51 , Processed in 0.060532 second(s), 23 queries .

本論壇言論純屬發表者個人意見,與 TShopping綜合論壇 立場無關 如有意見侵犯了您的權益 請寫信聯絡我們。

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回復 返回頂部 返回列表