一、安装CUDA和CUDNN
基于上面的博客,安装了CUDA10.0
二、安装tensorflow
错误1:from google.protobuf.pyext import _message ImportError: DLL load failed: The specified procedure could not be found.
解决方案:卸载protobuf,并 pip install protobuf==3.6.0
错误2:FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy.......
解决方案:numpy1-17-0版本过高,使用numpy-1.16-0版本即可
错误3: Blas GEMM launch failed 或者
failed to create cublas handle: CUBLAS_STATUS_ALLOC_FAILED
解决方案:原因均为显存不足,添加如下代码
import tensorflow as tf
from keras.backend.tensorflow_backend import set_session
config = tf.compat.v1.ConfigProto()
config.gpu_options.allocator_type = 'BFC' #A "Best-fit with coalescing" algorithm, simplified from a version of dlmalloc.
config.gpu_options.per_process_gpu_memory_fraction = 0.3
config.gpu_options.allow_growth = True
tf.compat.v1.keras.backend.set_session(tf.compat.v1.Session(config=config))
解决方案:还是显存不足
尝试以下几种措施:
1 减少Batch 的大小
2 分析错误的位置,在哪一层出现显卡不够,比如在全连接层出现的,则降低全连接层的维度,把2048改成1042啥的
3 增加pool 层,降低整个网络的维度。
4 修改输入图片的大小
由于当前用的是1050TI显卡,显存只有4G,多次尝试均无法解决显存问题,只能卸载tensorflow-gpu,重新安装了cpu版