【问题标题】:OOm - cannot run StyleGAN2 despite reducing batch sizeOOm - 尽管减少了批量大小,但仍无法运行 StyleGAN2
【发布时间】:2019-12-16 17:36:59
【问题描述】:

我正在尝试使用配备八个 GPU (NVIDIA GeForce RTX 2080) 的集群运行 StyleGAN2。目前我在training_loop.py使用如下配置:

minibatch_size_dict     = {4: 512, 8: 256, 16: 128, 32: 64, 64: 32},       # Resolution-specific overrides.
minibatch_gpu_base      = 8,        # Number of samples processed at a time by one GPU.
minibatch_gpu_dict      = {},       # Resolution-specific overrides.
G_lrate_base            = 0.001,    # Learning rate for the generator.
G_lrate_dict            = {},       # Resolution-specific overrides.
D_lrate_base            = 0.001,    # Learning rate for the discriminator.
D_lrate_dict            = {},       # Resolution-specific overrides.
lrate_rampup_kimg       = 0,        # Duration of learning rate ramp-up.
tick_kimg_base          = 4,        # Default interval of progress snapshots.
tick_kimg_dict          = {4:10, 8:10, 16:10, 32:10, 64:10, 128:8, 256:6, 512:4}): # Resolution-specific overrides.

我正在使用一组 512x52 像素的图像进行训练。经过几次迭代后,我收到下面报告的错误消息,脚本似乎停止运行(使用watch nvidia-smi,我们发现 GPU 的温度和风扇活动都降低了)。我已经减少了批量大小,但看起来问题出在其他地方。您对如何解决此问题有任何提示吗?

我能够使用相同的数据集运行 StyleGAN。在论文中他们说 StyleGAN2 应该不那么重,所以我有点惊讶。

这是我收到的错误消息:

2019-12-16 18:22:54.909009: E tensorflow/stream_executor/cuda/cuda_driver.cc:828] failed to allocate 334.11M (350338048 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY: out of memory
2019-12-16 18:22:54.909087: W tensorflow/core/common_runtime/bfc_allocator.cc:314] Allocator (GPU_0_bfc) ran out of memory trying to allocate 129.00MiB (rounded to 135268352).  Current allocation summary follows.
2019-12-16 18:22:54.918750: W tensorflow/core/common_runtime/bfc_allocator.cc:319] **_***************************_*****x****x******xx***_******************************_***************
2019-12-16 18:22:54.918808: W tensorflow/core/framework/op_kernel.cc:1502] OP_REQUIRES failed at conv_grad_input_ops.cc:903 : Resource exhausted: OOM when allocating tensor with shape[4,128,257,257] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc

【问题讨论】:

  • 我看到了相同类型的错误:,如果你想看看我到目前为止的尝试,我已经把我的笔记放在这里了:datascience.stackexchange.com/questions/74666/…
  • 您最近是否从 tensorflow 2.0 降级到 1.15 版?
  • 你的 minibatch_size_base 是多少?

标签: tensorflow gpu


【解决方案1】:

StyleGAN2 的 config-f 模型实际上比 StyleGAN1 大。尝试使用较少 VRAM 消耗的配置,如 config-e。您实际上可以通过在 python 命令中传递一个标志来更改模型的配置,如下所示:https://github.com/NVlabs/stylegan2/blob/master/run_training.py#L144

就我而言,我可以在 2 RTX 2080ti 上使用 config-e 训练 StyleGAN2。

【讨论】:

    【解决方案2】:

    一个或多个高端 NVIDIA GPU、NVIDIA 驱动程序、CUDA 10.0 工具包 和 cuDNN 7.5。为了重现论文中报告的结果,您 需要具有至少 16 GB DRAM 的 NVIDIA GPU。

    您的 NVIDIA GeForce RTX 2080 卡有 11GB,但我猜您是说您有 8 个?我不认为 tensorflow 是为开箱即用的并行性设置的。

    【讨论】:

    • 正确,八是卡的数量,不是我的GB内存;-)
    • 我不认为您使用的 stylegan2 代码是为在多个 GPU 上运行而编写的。
    猜你喜欢
    • 2017-09-25
    • 2016-10-13
    • 2019-02-03
    • 2013-02-21
    • 2018-12-09
    • 1970-01-01
    • 2018-07-21
    • 2020-10-22
    • 2021-07-03
    相关资源
    最近更新 更多