MINIST进阶
今天的歌舍离书
今天就解决了一个小问题,然而碰到了其他问题。问题还真是一个接一个啊。
问题1: TensorFlow、CUDA、CuDNN版本问题。
在运行MINIST进阶搭建的CNN时,运行的时候出现了以下错误:
Loaded runtime CuDNN library: 7101 (compatibility version 7100) but source was compiled with 7003
这个问题是由于CNN运行的时候启动了CuDNN加速,很明显之前在运行softmax的时候并没有出现这个问题是因为没有启动加速啦,程序默认使用版本的CuDNN和安装版本不一致。在搜解决方案的时候,基本就是两种,一种是按照版本提示,降低版本到7.0兼容;另一种就是升级Tensorflow,使其使用相对应版本的CuDNN。
果断的选择了升级TensorFlow,升级到tensorflow-gpu 1.8
升级语句如下:
pip install --user --upgrade tensorflow-gpu==1.8
问题2: gpu占用问题。
报错情况如下:
ResourceExhaustedError (see above for traceback): OOM when allocating tensor with shape[10000,32,28,28] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc
[[Node: Conv2D = Conv2D[T=DT_FLOAT, data_format="NHWC", dilations=[1, 1, 1, 1], padding="SAME", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/device:GPU:0"](Reshape, Variable/read)]]
Hint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info.
[[Node: add_3/_7 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_49_add_3", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]
Hint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info.
嗯,真是怀疑人生,和案例一样的2W次循环,跑到了1.9W,上次崩掉是跑到了1.2W左右,这个问题还没有处理好。也可能之后搭一下服务器。
有点晚了呢,再跑一次试试。晚安啦。
昨天跑了很多次,都是在1.9W也就是最后一次循环结束之后,进入测试崩掉的。今天来更新解决办法。这里是参考博客。
出现ResourceExhaustedError的原因,就是一次的计算开的太大,导致了内存不够用。原来代码在训练的时候,每50个计算一次,而在测试的时候一起开10000的内存,需要100003228*28这么大。所以根据参考博客降低了测试的batch,跑10次每次1000。最后跑出了满意的结果,准确率也和教程相符,基本在99.27%左右。今天也仔细观察了以下gpu的占用,训练过程每一次循环占用gpu在23%左右,循环结束就会变为0,下一次又在23%左右,然后再变为0..............
![](https://img.haomeiwen.com/i13293525/6eec22c434283d10.png)
我的github
愿君心坚韧难囚
网友评论