16G内存炸裂??

from mxnet.gluon import nn
net = nn.Sequential()
with net.name_scope():
    net.add(
        nn.Conv2D(channels=96, kernel_size=11,
                  strides=4, activation='relu'),
        nn.MaxPool2D(pool_size=3, strides=2),
        nn.Conv2D(channels=256, kernel_size=5,
                  padding=2, activation='relu'),
        nn.MaxPool2D(pool_size=3, strides=2),
        nn.Conv2D(channels=384, kernel_size=3,
                  padding=1, activation='relu'),
        nn.Conv2D(channels=384, kernel_size=3,
                  padding=1, activation='relu'),
        nn.Conv2D(channels=256, kernel_size=3,
                  padding=1, activation='relu'),
        nn.MaxPool2D(pool_size=3, strides=2),
        nn.Flatten(),
        nn.Dense(4096, activation='relu'),
        nn.Dropout(0.5),
        # nn.Dense(4096, activation='relu'),
        # nn.Dropout(0.5),
        nn.Dense(10)
    )

import sys
sys.path.append('..')
# from .utils import *
from stu.utils import *

train_data, test_data = load_data_fashion_mnist(batch_size=64, resize=224)

from mxnet import init
from mxnet import gluon

ctx = try_gpu()
net.initialize()

loss = gluon.loss.SoftmaxCrossEntropyLoss()
trainer = gluon.Trainer(net.collect_params(),
                        'sgd', {'learning_rate': 0.01})
train(train_data, test_data, net, loss,
            trainer, ctx, num_epochs=1)

内存?显存吧?代码贴了倒是也把报错给贴出来啊

内存炸裂是因为’load_data_fashion_mnist‘函数的原因,这个函数会把fashionMNIST数据集的所有图片都先resize,然后存储到内存里面。 你这里resize = 224,然后它会把整个数据集的60000张图片一起resize,这时候数据集的数据就有60000 * 224 * 224 * 3。这个用float32存储需要30多g的内存。
你可以尝试将resize减小,或者使用我在’深度卷积神经网络和AlexNet 讨论区’ 里提供的方法,修改load_data_fashion_mnist函数,每个batch的数据单独resize,虽然程序耗时会加一点,但是内存不再是问题。

是的 非常感谢

卧槽。。。吓得我去闲鱼买了一条16G的内存。。。组32G双通道了。。。:sob: