TensorFlow GPU错误:failed to create cublas handle: CUBLAS_STATUS_ALLOC_FAILED

深度学习TensorFlow 1860

如果你是使用GPU版TensorFlow,并且你想在显卡高占用率的情况下(比如玩游戏)训练模型,那你要注意在初始化 Session的时候为其分配固定数量的显存,否则可能会在开始训练的时候直接报错退出:

2018-05-02 13:24:21.958514: E T:\src\github\tensorflow\tensorflow\stream_executor\cuda\cuda_blas.cc:462] failed to create cublas handle: CUBLAS_STATUS_ALLOC_FAILED

解决方法

这时你需要用下面的方法创建 Session

gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.333)
sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options))

Post Comment