tensorflow电脑显存不足解决办法

"C:My FilePythonpython.exe" C:/workspace/Python/deep-learning/card/程序/C识别码.py
2019-05-09 21:42:01.200659: I C:UsersUserSourceRepos ensorflow ensorflowcorecommon_runtimegpugpu_device.cc:955] Found device 0 with properties:
name: GeForce GTX 960M
major: 5 minor: 0 memoryClockRate (GHz) 1.176
pciBusID 0000:01:00.0
Total memory: 2.00GiB
Free memory: 1.65GiB
2019-05-09 21:42:01.201008: I C:UsersUserSourceRepos ensorflow ensorflowcorecommon_runtimegpugpu_device.cc:976] DMA: 0
2019-05-09 21:42:01.201151: I C:UsersUserSourceRepos ensorflow ensorflowcorecommon_runtimegpugpu_device.cc:986] 0: Y
2019-05-09 21:42:01.201313: I C:UsersUserSourceRepos ensorflow ensorflowcorecommon_runtimegpugpu_device.cc:1045] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GTX 960M, pci bus id: 0000:01:00.0)
2019-05-09 21:42:10.905265: E C:UsersUserSourceRepos ensorflow ensorflowstream_executorcudacuda_dnn.cc:371] could not create cudnn handle: CUDNN_STATUS_NOT_INITIALIZED
2019-05-09 21:42:10.905511: E C:UsersUserSourceRepos ensorflow ensorflowstream_executorcudacuda_dnn.cc:375] error retrieving driver version: Unimplemented: kernel reported driver version not implemented on Windows
2019-05-09 21:42:10.906236: E C:UsersUserSourceRepos ensorflow ensorflowstream_executorcudacuda_dnn.cc:338] could not destroy cudnn handle: CUDNN_STATUS_BAD_PARAM
2019-05-09 21:42:10.906464: F C:UsersUserSourceRepos ensorflow ensorflowcorekernelsconv_ops.cc:672] Check failed: stream->parent()->GetConvolveAlgorithms( conv_parameters.ShouldIncludeWinogradNonfusedAlgo<T>(), &algorithms)

Process finished with exit code -1073740791 (0xC0000409)

我的电脑是960M的显卡,跑程序会出现显出不足的问题

那我们就在程序里面控制GPU的占用比,不让他占满就好了,在程序里面加上:

os.environ["CUDA_VISIBLE_DEVICES"] = '0'   #指定第一块GPU可用
config = tf.ConfigProto()
config.gpu_options.per_process_gpu_memory_fraction = 0.5 # 程序最多只能占用指定gpu50%的显存
config.gpu_options.allow_growth = True #程序按需申请内存
sess = tf.Session(config = config)


就好了,就是会稍微慢点
原文地址:https://www.cnblogs.com/zhaochunhui/p/10841454.html