首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >Google Colab内存不足

Google Colab内存不足
EN

Stack Overflow用户
提问于 2021-07-11 17:45:47
回答 1查看 1.5K关注 0票数 0

我尝试在Google Colab Pro GPU (内存:25 me,磁盘:147 me)上使用更快的RCNN运行TF对象检测模型的演示,但失败了,并给出以下错误:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
Tensorflow/core/common_runtime/bfc_allocator.cc:456] Allocator (GPU_0_bfc) ran out of memory trying to allocate 7.18GiB (rounded to 7707033600)requested by op MultiLevelMatMulCropAndResize/MultiLevelRoIAlign/AvgPool-0-TransposeNHWCToNCHW-LayoutOptimizer
If the cause is memory fragmentation maybe the environment variable 'TF_GPU_ALLOCATOR=cuda_malloc_async' will improve the situation. 

然后它会给我这些统计数据:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
I tensorflow/core/common_runtime/bfc_allocator.cc:1058] Sum Total of in-use chunks: 7.46GiB
I tensorflow/core/common_runtime/bfc_allocator.cc:1060] total_region_allocated_bytes_: 15034482688 memory_limit_: 16183459840 available bytes: 1148977152 curr_region_allocation_bytes_: 8589934592
I tensorflow/core/common_runtime/bfc_allocator.cc:1066] Stats: 
Limit:                     16183459840
InUse:                      8013051904
MaxInUse:                   8081602560
NumAllocs:                        6801
MaxAllocSize:               7707033600
Reserved:                            0
PeakReserved:                        0
LargestFreeBlock:                    0

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
tensorflow.python.framework.errors_impl.ResourceExhaustedError:  OOM when allocating tensor with shape[2400,1024,28,28] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc
     [[{{node MultiLevelMatMulCropAndResize/MultiLevelRoIAlign/AvgPool-0-TransposeNHWCToNCHW-LayoutOptimizer}}]]
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.
 [Op:__inference__dummy_computation_fn_32982]

我真的不明白为什么在25 7GB的系统上只分配7 7GB的内存就会用完?我怎么才能修复它?以下是我用于此任务的配置文件:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
# Faster R-CNN with Resnet-50 (v1)
# Trained on COCO, initialized from Imagenet classification checkpoint

# Achieves -- mAP on COCO14 minival dataset.

# This config is TPU compatible.

model {
  faster_rcnn {
    num_classes: 7
    image_resizer {
      keep_aspect_ratio_resizer {
        min_dimension: 640
        max_dimension: 640
        pad_to_max_dimension: true
      }
    }
    feature_extractor {
      type: 'faster_rcnn_resnet50_keras'
      batch_norm_trainable: true
    }
    first_stage_anchor_generator {
      grid_anchor_generator {
        scales: [0.25, 0.5, 1.0, 2.0]
        aspect_ratios: [0.5, 1.0, 2.0]
        height_stride: 16
        width_stride: 16
      }
    }
    first_stage_box_predictor_conv_hyperparams {
      op: CONV
      regularizer {
        l2_regularizer {
          weight: 0.0
        }
      }
      initializer {
        truncated_normal_initializer {
          stddev: 0.01
        }
      }
    }
    first_stage_nms_score_threshold: 0.0
    first_stage_nms_iou_threshold: 0.7
    first_stage_max_proposals: 300
    first_stage_localization_loss_weight: 2.0
    first_stage_objectness_loss_weight: 1.0
    initial_crop_size: 14
    maxpool_kernel_size: 2
    maxpool_stride: 2
    second_stage_box_predictor {
      mask_rcnn_box_predictor {
        use_dropout: false
        dropout_keep_probability: 1.0
        fc_hyperparams {
          op: FC
          regularizer {
            l2_regularizer {
              weight: 0.0
            }
          }
          initializer {
            variance_scaling_initializer {
              factor: 1.0
              uniform: true
              mode: FAN_AVG
            }
          }
        }
        share_box_across_classes: true
      }
    }
    second_stage_post_processing {
      batch_non_max_suppression {
        score_threshold: 0.0
        iou_threshold: 0.6
        max_detections_per_class: 100
        max_total_detections: 300
      }
      score_converter: SOFTMAX
    }
    second_stage_localization_loss_weight: 2.0
    second_stage_classification_loss_weight: 1.0
    use_static_shapes: true
    use_matmul_crop_and_resize: true
    clip_anchors_to_image: true
    use_static_balanced_label_sampler: true
    use_matmul_gather_in_matcher: true
  }
}

train_config: {
  batch_size: 8
  sync_replicas: true
  startup_delay_steps: 0
  replicas_to_aggregate: 8
  num_steps: 25000
  optimizer {
    momentum_optimizer: {
      learning_rate: {
        cosine_decay_learning_rate {
          learning_rate_base: .04
          total_steps: 25000
          warmup_learning_rate: .013333
          warmup_steps: 2000
        }
      }
      momentum_optimizer_value: 0.9
    }
    use_moving_average: false
  }
  fine_tune_checkpoint_version: V2
  fine_tune_checkpoint: "faster_rcnn_resnet50_v1_640x640_coco17_tpu-8/checkpoint/ckpt-0"
  fine_tune_checkpoint_type: "detection"
  data_augmentation_options {
    random_horizontal_flip {
    }
  }

  max_number_of_boxes: 100
  unpad_groundtruth_tensors: false
  use_bfloat16: true  # works only on TPUs
}

train_input_reader: {
  label_map_path: "label_map.pbtxt"
  tf_record_input_reader {
    input_path: "train.record"
  }
}

eval_config: {
  metrics_set: "coco_detection_metrics"
  use_moving_averages: false
  batch_size: 1;
}

eval_input_reader: {
  label_map_path: "label_map.pbtxt"
  shuffle: false
  num_epochs: 1
  tf_record_input_reader {
    input_path: "test.record"
  }
}
EN

回答 1

Stack Overflow用户

发布于 2021-07-11 18:55:11

我意识到这是图像在样本大小中占用太多内存的问题,根据https://github.com/tensorflow/models/issues/1817,所以我将批处理大小改为2,它起作用了

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68338674

复制
相关文章
Reactive UI -- 反应式编程UI框架入门学习 (转载非原创)
反应式编程是一种相对于命令式的编程范式,由函数式的组合声明来构建异步数据流。要理解这个概念,可以简单的借助Excel中的单元格函数。
wxilejun
2022/08/09
2.3K0
Problem: Delete Number Problem
这题可以使用贪心策略,每次从高位向低位数,删除高位比低位数字小的那位上的数字,直到删除了k位之后,得到的数字肯定是最大值。
宅男潇涧
2018/08/01
4180
Problem: Delete Number Problem
Problem: Vertext Cover Problem
给定一个N个点M条边的无向图G(点的编号从1至N),问是否存在一个不超过K个点的集合S,使得G中的每条边都至少有一个点在集合S中。
宅男潇涧
2018/08/01
5470
Problem: Vertext Cover Problem
Problem: Matrix Chain Problem
矩阵链乘问题是最典型的动态规划问题,本文介绍如何用动规算法解决这个问题,要理解下面的内容请先阅读这篇动态规划的总结。
宅男潇涧
2018/08/01
5430
Problem: Matrix Chain Problem
LIS + Problem
让我们举个例子:求 2 7 1 5 6 4 3 8 9 的最长上升子序列。我们定义d(i) (i∈[1,n])来表示前i个数以A[i]结尾的最长上升子序列长度。
AngelNH
2020/04/16
4210
Jmetal Problem和Problem Set的变量范围
ProblemSet的变量范围 //注意MATP1是一个ProblemSet,其中有50个任务,即有50个Problem //其变量上下界的范围使用getUnified函数获得 double unilw= problemSet.getUnifiedLowerLimit(); double uniup=problemSet.getUnifiedUpperLimit(); System.out.println("unilw "+unilw+" "+"uniup
演化计算与人工智能
2020/08/14
6780
LCS + Problem
最长公共子序列,。其定义是,一个序列 S ,如果分别是两个或多个已知序列的子序列,且是所有符合此条件序列中最长的,则 S 称为已知序列的最长公共子序列。
AngelNH
2020/04/16
5380
A problem is easy
When Teddy was a child , he was always thinking about some simple math problems ,such as “What it’s 1 cup of water plus 1 pile of dough ..” , “100 yuan buy 100 pig” .etc..
书童小二
2018/09/03
3720
A problem is easy
Dual Problem & KKT
I have written a note with respect to SVM. Unfortunately , I was not familiar with convex optimizati
西红柿炒鸡蛋
2020/07/20
5660
Dual Problem & KKT
Train Problem I
思路:我们很容易想到用一个栈就可以解决~~ 然后还要用字符型的不定数组来存火车的标号;不能用整数型的,具体为什么自己想一想就明白了
杨鹏伟
2020/09/11
2860
2301: [HAOI2011]Problem b
2301: [HAOI2011]Problem b Time Limit: 50 Sec  Memory Limit: 256 MB Submit: 1737  Solved: 749 [Submit][Status][Discuss] Description 对于给出的n个询问,每次求有多少个数对(x,y),满足a≤x≤b,c≤y≤d,且gcd(x,y) = k,gcd(x,y)函数为x和y的最大公约数。 Input 第一行一个整数n,接下来n行每行五个整数,分别表示a、b、c、d、k Outp
HansBug
2018/04/11
6080
Backpack problem
1、01背包 /* 一共有n件物品,背包容量为m,每件物品有体积weight 和value,求背包可以装的最大价值。 01背包是最简单的背包问题,每件物品只有选与不选两种情况: dp[i][j] :表示选第i件物品时重量为j的最大价值。 1.不选第i件物品 dp[i][j] = dp[i-1][j] 2.选第i件物品的最大值(背包容量足够) dp[i][j] = max(dp[i-1][j],dp[i-1][j-weight[i]] + value[i]) */ #include<iostream>
AngelNH
2020/04/16
3810
Year 2038 problem
已经知道,对于int了tinyint了这些MySql类型,后面那个4或者11没啥实际意义,只是说(当位数不足时)前面填充多少个0,然后使之变为4位或者11位,对这个类型的字段实际能存的长度没啥影响.
fliter
2023/09/23
2200
Year 2038 problem
2018 MCM Problem A notes
2018 MCM Problem A: Multi-hop HF Radio Propagation(bk1)
magic2728
2019/09/27
4470
D. Minimax Problem
time limit per test:5 seconds memory limit per test:512 megabytes inputstandard input outputstandard output
某些人
2020/04/09
2940
HDOJ 1000 A + B Problem
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 513689 Accepted Submission(s): 162876
谙忆
2021/01/19
3060
ZOJ Problem Set - 3870
原理:异或 #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int MaxN = 1e5 + 10; int a[MaxN], bit[50]; // bit[i]表示有多少个数的最高位的1在第i位上 void solve(int x) { int l = 31; while(l >= 0) { if(x & (1<<l)) {
Gabriel
2022/11/15
1370
A+B Problem(V)
做了A+B Problem之后,Yougth感觉太简单了,于是他想让你求出两个数反转后相加的值。帮帮他吧
书童小二
2018/09/03
4450
【HDU 5105】Math Problem
  b≠0,f为二次函数,最大值点在区间端点或者x0=c/(2*b),当L≤x0≤R时,ans=max{f(L),f(R),f(x0)}。
饶文津
2020/06/02
2530
点击加载更多

相似问题

表单语义UI反应

14

本机反应语义-ui-反应

24

语义-ui图像属性不工作语义-ui-反应

23

语义UI反应不显示

213

语义UI反应,下拉选择

113
添加站长 进交流群

领取专属 10元无门槛券

AI混元助手 在线答疑

扫码加入开发者社群
关注 腾讯云开发者公众号

洞察 腾讯核心技术

剖析业界实践案例

扫码关注腾讯云开发者公众号
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文