python运行提示显卡内存不足_tensorflow电脑显存不足解决办法

本文档描述了在使用TensorFlow时遇到GPU资源不足和初始化错误的状况,详细日志显示了CUDA设备未正确初始化。作者提出了通过设置环境变量和配置TensorFlow会话来限制GPU内存使用和按需分配,以避免资源耗尽,虽然这可能导致程序运行速度减慢。
摘要由CSDN通过智能技术生成

“C:\My File\Python\python.exe” C:/workspace/Python/deep-learning/card/程序/C识别码.py

2019-05-09 21:42:01.200659: I C:\Users\User\Source\Repos\tensorflow\tensorflow\core\common_runtime\gpu\gpu_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:\Users\User\Source\Repos\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:976] DMA: 0

2019-05-09 21:42:01.201151: I C:\Users\User\Source\Repos\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:986] 0: Y

2019-05-09 21:42:01.201313: I C:\Users\User\Source\Repos\tensorflow\tensorflow\core\common_runtime\gpu\gpu_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:\Users\User\Source\Repos\tensorflow\tensorflow\stream_executor\cuda\cuda_dnn.cc:371] could not create cudnn handle: CUDNN_STATUS_NOT_INITIALIZED

2019-05-09 21:42:10.905511: E C:\Users\User\Source\Repos\tensorflow\tensorflow\stream_executor\cuda\cuda_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:\Users\User\Source\Repos\tensorflow\tensorflow\stream_executor\cuda\cuda_dnn.cc:338] could not destroy cudnn handle: CUDNN_STATUS_BAD_PARAM

2019-05-09 21:42:10.906464: F C:\Users\User\Source\Repos\tensorflow\tensorflow\core\kernels\conv_ops.cc:672] Check failed: stream->parent()->GetConvolveAlgorithms( conv_parameters.ShouldIncludeWinogradNonfusedAlgo(), &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)

就好了,就是会稍微慢点

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值