tensorflow CUDA out of memory
来源:互联网 发布:用户画像建模算法 编辑:程序博客网 时间:2024/05/16 14:04
今天刚把服务器搭建起来 结果程序就跑不起来 当时差点把自己吓尿了
错误类型:CUDA_ERROE_OUT_OF_MEMORY
E tensorflow/stream_executor/cuda/cuda_driver.cc:924] failed to alloc 17179869184 bytes on host: CUDA_ERROR_OUT_OF_MEMORYW ./tensorflow/core/common_runtime/gpu/pool_allocator.h:195] could not allocate pinned host memory of size: 17179869184Killed
其实很容易理解 大致意思就是 服务器的GPU大小为M
tensorflow只能申请N(N<M)
也就是tensorflow告诉你 不能申请到GPU的全部资源 然后就不干了
解决方法:
找到代码中Session
在session定义前 增加
config = tf.ConfigProto(allow_soft_placement=True)
#最多占gpu资源的70%
gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.7)
#开始不会给tensorflow全部gpu资源 而是按需增加
config.gpu_options.allow_growth = True
sess = tf.Session(config=config)
这样就没问题了
其实tensorflow 算是一个比较贪心的工具了
就算用device_id指定gpu 也会占用别的GPU的显存资源 必须在执行程序前
执行 export CUDA_VISIBLE_DEVICES=n(n为可见的服务器编号)
再去执行python 代码.py 才不会占用别的GPU资源
最近刚开始搞tensorflow 之前都是caffe
这周连续3天被实验室的人 举报 占用过多服务器资源 真是心累 只要用上面的方法
也就是执行代码前 执行 export CUDA_VISIBLE_DEVICES=n
只让1个或者个别GPU可见 其他GPU看不见 就行了
阅读全文
7 0
- tensorflow CUDA out of memory
- out of memory
- Out of memory
- out of memory
- android out of memory
- out of memory
- MATLAB: OUT OF MEMORY
- MATLAB out of memory
- 解决out of memory
- Out Of Memory
- android Out of memory
- linux out of memory
- matlab out of memory
- thrift out of memory
- Android Out Of Memory
- out of memory
- centos out of memory
- GP Out of memory
- iFunk翼超极本苏宁易购正式开售啦
- Windows下使用BeautifulSoup 出现You are trying to run the Python 2 version of Beautiful Soup under Python
- 【JMeter】JMeter使用plugins插件进行服务器性能监控
- Java基础——substring字符串截取
- Python3.6请求网站时报错:http.client.RemoteDisconnected: Remote end closed connection without response
- tensorflow CUDA out of memory
- Servlet生命周期、工作原理
- getpwnam,getgrnam,getpwent,crypt等函数
- python 中文乱码问题深入分析
- leetcode 26. Remove Duplicates from Sorted Array
- home键源码分析
- Jquery 点击图片在弹出层显示大图
- JDBC 连接池封装
- java中的Timer用法(一) 基础知识