分配带有shape [1,48,48,1024]的张量并在/ job:localhost / replica:0 / task:0 / device:GPU:0上通过分配器GPU_0_bfc

时间:2020-08-17 14:04:32

标签: tensorflow keras deep-learning gpu custom-training

我正在尝试在以下存储库中重现Mask RCNN的训练:https://github.com/maxkferg/metal-defect-detection

火车的代码段如下:

        # Training - Stage 1
        print("Training network heads")
        model.train(dataset_train, dataset_val,
        learning_rate=config.LEARNING_RATE,
        epochs=40,
        layers='heads')

        # Training - Stage 2
        # Finetune layers from ResNet stage 4 and up
        print("Fine tune Resnet stage 4 and up")
        model.train(dataset_train, dataset_val,
        learning_rate=config.LEARNING_RATE,
        epochs=120,
        layers='4+')

        # # Training - Stage 3
        # # Fine tune all layers
        print("Fine tune all layers")
        model.train(dataset_train, dataset_val,
        learning_rate=config.LEARNING_RATE / 10,
        epochs=160,
        layers='all')

第一阶段进展顺利。但是从第二阶段失败。提供以下内容:

2020-08-17 15:53:10.685456:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 123块大小2048总计246.0KiB 2020-08-17 15:53:10.685456:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 1个块,大小总计2816 2.8公斤 2020-08-17 15:53:10.686456:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 6个块,总大小为3072 18.0公斤 2020-08-17 15:53:10.686456:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 387个块,总大小为4096 1.51英里 2020-08-17 15:53:10.687456:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 1个块,大小总计6144 6.0千位 2020-08-17 15:53:10.687456:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 1个块,大小为6656,总计6.5磅 2020-08-17 15:53:10.688456:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 60个块,总大小为8192 480.0公斤 2020-08-17 15:53:10.688456:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 2个块,总大小为9216 18.0公斤 2020-08-17 15:53:10.689456:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 12个块,总大小为12288 144.0公斤 2020-08-17 15:53:10.689456:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 2个块,总大小为16384 32.0公斤 2020-08-17 15:53:10.690456:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 1个块,总大小为21248 20.8磅 2020-08-17 15:53:10.691456:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 1个块,大小总计24064 23.5公斤 2020-08-17 15:53:10.691456:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 5个块,总大小为24576 120.0公斤 2020-08-17 15:53:10.692456:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 1个块,总大小为37632 36.8公斤 2020-08-17 15:53:10.692456:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 1个块,大小总计40960 40.0公斤 2020-08-17 15:53:10.693456:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 4个块,总计49152 192.0公斤 2020-08-17 15:53:10.693456:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 6个块,大小总计65536 384.0公斤 2020-08-17 15:53:10.694456:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 1个块,总大小为81920 80.0公斤 2020-08-17 15:53:10.695456:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 1个块,大小为90624,总计88.5公斤 2020-08-17 15:53:10.695456:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 1个块,总大小为131072 128.0公斤 2020-08-17 15:53:10.695456:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 3个块,总大小为147456 432.0公斤 2020-08-17 15:53:10.696456:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 12个块,总计262144 3.00米 2020-08-17 15:53:10.696456:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 1个块,总大小为327680 320.0公斤 2020-08-17 15:53:10.697457:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 11个块,总大小为524288 5.50英里 2020-08-17 15:53:10.697457:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 4个块,总计589824 2.25米 2020-08-17 15:53:10.698457:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 194个块,总大小为1048576 194.00MiB 2020-08-17 15:53:10.699457:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 17个块,总大小为2097152 34.00MiB 2020-08-17 15:53:10.699457:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 1个块,总大小为2211840 2.11米 2020-08-17 15:53:10.700457:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 146个块,大小总计2359296 328.50MiB 2020-08-17 15:53:10.701457:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 1个块,大小总计2360320 2.25米 2020-08-17 15:53:10.701457:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 1个块,总大小为2621440 2.50米 2020-08-17 15:53:10.702457:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 1个块,大小总计2698496 2.57米 2020-08-17 15:53:10.702457:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 1个块,总大小为3670016 3.50米 2020-08-17 15:53:10.703457:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 31个块,大小总计4194304 124.00MiB 2020-08-17 15:53:10.703457:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 6个块,总大小为4718592 27.00MiB 2020-08-17 15:53:10.704457:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 5个块,大小为8388608,总计40.00MiB 2020-08-17 15:53:10.705457:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 25个块,大小为9437184,总计225.00MiB 2020-08-17 15:53:10.705457:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 2个块,大小为9438208 18.00MiB 2020-08-17 15:53:10.706457:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 1个块,总大小为9441280 9.00英里 2020-08-17 15:53:10.706457:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 1个块,总大小为16138752 15.39MiB 2020-08-17 15:53:10.707457:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 1个块,大小总计18874368 18.00MiB 2020-08-17 15:53:10.707457:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 1个块,大小为37748736,总计36.00MiB 2020-08-17 15:53:10.708457:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:680] 7个块,总大小为51380224 343.00MiB 2020-08-17 15:53:10.708457:IC:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:684]总和块:1.41GiB 2020-08-17 15:53:10.709457:I C:\ tf_jenkins \ workspace \ rel-win \ M \ windows-gpu \ PY \ 36 \ tensorflow \ core \ common_runtime \ bfc_allocator.cc:686]统计: 限制:1613615104 使用中:1510723072 最大使用量:1510723072 NumAllocs:3860 MaxAllocSize:119947776

培训在具有2GB RAM的QuadroK420上运行。仅仅是内存不足的问题,还是我缺少了什么? 有什么办法可以训练我的装备吗?

3 个答案:

答案 0 :(得分:1)

最有可能是RAM问题。您可以尝试将批量大小减小为1或简化网络。如果这些方法中的任何一种可行,都可以使用更大的RAM。

答案 1 :(得分:1)

问题是视频卡的GPU内存。

在第一阶段,由于您只训练了网络的“头部”,因此您可以顺利进行训练。

在第二阶段,您开始摆脱内存不足的问题,因为您训练了更多的层,从而导致内存不足。

我建议使用至少具有8 GB VRAM的视频卡来解决计算机视觉问题。

实际上,有时可以通过减小批量大小来解决内存不足的问题,但是在您这种情况下,唯一可行的解​​决方案是选择更大/更好的视频卡。

答案 2 :(得分:0)

有时解决此问题的一种方法是在模型中放置一个上采样层。所以在图像生成器中降低你的目标,然后添加一个上采样层。是一种欺骗它的好方法。如果有效,那么您知道 colab 无法处理它