ITeye博客

TensorFlow训练模型报错——莫烦学习例子3

董瑞龙 · 2017-07-20 15:38 · TensorFlow · 互联网 · Markdown

运行莫烦TensorFlow教程报错,例子3 https://morvanzhou.github.io/tutorials/machine-learning/tensorflow/3-2-create-NN/

错误:

InternalError (see above for traceback): Blas GEMM launch failed : a.shape=(300, 1), b.shape=(1, 10), m=300, n=10, k=1
	 [[node: matmul = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/job:localhost/replica:0/task:0/gpu:0"](_arg_Placeholder_0_0/_7, Variable/read)]]

日志报错: failed to create cublas handle: CUBLAS_STATUS_ALLOC_FAILED

后查询资料 https://segmentfault.com/a/1190000009954640?utm_source=itdadao&utm_medium=referral

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

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

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。