Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

evaluate时显存不够用,怎么修改 #3777

Closed
1 task done
wwma opened this issue Aug 14, 2024 · 10 comments
Closed
1 task done

evaluate时显存不够用,怎么修改 #3777

wwma opened this issue Aug 14, 2024 · 10 comments
Assignees
Labels
question Further information is requested

Comments

@wwma
Copy link

wwma commented Aug 14, 2024

问题确认 Search before asking

  • 我已经搜索过问题,但是没有找到解答。I have searched the question and found no related answer.

请提出你的问题 Please ask your question

使用自定义的数据集进行模型训练,配置文件信息如下:

batch_size: 1
iters: 20000

train_dataset:
  type: Dataset
  dataset_root: dataset
  train_path: dataset\train.txt
  num_classes: 5
  mode: train
  transforms:
    # 训练时的数据未增强
    - type: ResizeStepScaling #将原始图像和标注图像随机缩放为0.5~2.0倍
      min_scale_factor: 0.5
      max_scale_factor: 2.0
      scale_step_size: 0.25
    - type: RandomPaddingCrop
      crop_size: [2048, 1024]
    - type: RandomHorizontalFlip
    - type: RandomDistort
      brightness_range: 0.4
      contrast_range: 0.4
      saturation_range: 0.4
    - type: Normalize



val_dataset:
  type: Dataset
  dataset_root: dataset
  val_path: dataset\val.txt
  num_classes: 5
  mode: val
  transforms:
    - type: Normalize

在配置文件中,已经将batch_size设置为1,训练的时候可以正常运行。
但是在evaluate的时候,会提示错误信息

Out of memory error on GPU 0. Cannot allocate 38.106859GB memory on GPU 0, 8.777832GB memory has been allocated and available memory is 
only 1.221680GB.

Please check whether there is any other process using GPU 0.
1. If yes, please stop them, or start PaddlePaddle on another GPU.
2. If no, please decrease the batch size of your model.
 (at ..\paddle\fluid\memory\allocation\cuda_allocator.cc:86)

请问是因为val数据集中图像尺寸过大吗?
train数据集和val 数据集需要统一成相同尺寸

@wwma wwma added the question Further information is requested label Aug 14, 2024
@UserWangZz
Copy link
Collaborator

请问数据集图像分辨率是多少呢?

@wwma
Copy link
Author

wwma commented Aug 16, 2024

请问数据集图像分辨率是多少呢?

3264 x 2448

@wwma
Copy link
Author

wwma commented Aug 16, 2024

还有我想请问,config中设置了 训练时的参数

type: RandomPaddingCrop
      crop_size: [2048, 1024]

则模型最佳适配的图片大小是2048 x 1024吗?
除此之外,最终进行预测时的图片大小需要resize成2048 x 1024吗?如若不压缩会有什么影响呢?
谢谢~

@UserWangZz
Copy link
Collaborator

请问数据集图像分辨率是多少呢?

3264 x 2448

那这个图太大了,即使batch size为1也会爆显存

@UserWangZz
Copy link
Collaborator

还有我想请问,config中设置了 训练时的参数

type: RandomPaddingCrop
      crop_size: [2048, 1024]

则模型最佳适配的图片大小是2048 x 1024吗? 除此之外,最终进行预测时的图片大小需要resize成2048 x 1024吗?如若不压缩会有什么影响呢? 谢谢~

倒不是说最佳适配图片大小是2048 * 1024,只是训练阶段图片都按照这个大小进行训练,推理时可以和训练时一致,也可以尝试其他size找到最佳分辨率

@wwma
Copy link
Author

wwma commented Aug 16, 2024

请问数据集图像分辨率是多少呢?

3264 x 2448

那这个图太大了,即使batch size为1也会爆显存

请问调小的方式,在transforms中直接resize可以吗?还是有其他的方法

@wwma
Copy link
Author

wwma commented Aug 16, 2024

还有我想请问,config中设置了 训练时的参数

type: RandomPaddingCrop
      crop_size: [2048, 1024]

则模型最佳适配的图片大小是2048 x 1024吗? 除此之外,最终进行预测时的图片大小需要resize成2048 x 1024吗?如若不压缩会有什么影响呢? 谢谢~

倒不是说最佳适配图片大小是2048 * 1024,只是训练阶段图片都按照这个大小进行训练,推理时可以和训练时一致,也可以尝试其他size找到最佳分辨率

还有一个问题想要请教一下,训练时的图片大小是如何影响模型性能的呢?图片越大越好吗(虽然会拖慢训练速度)。我想要预测的结果会存在一些微小情况,因此希望模型可以识别细微特征,请问在这种情况下应如何选择呢?谢谢

@UserWangZz
Copy link
Collaborator

请问数据集图像分辨率是多少呢?

3264 x 2448

那这个图太大了,即使batch size为1也会爆显存

请问调小的方式,在transforms中直接resize可以吗?还是有其他的方法

是的

@UserWangZz
Copy link
Collaborator

还有我想请问,config中设置了 训练时的参数

type: RandomPaddingCrop
      crop_size: [2048, 1024]

则模型最佳适配的图片大小是2048 x 1024吗? 除此之外,最终进行预测时的图片大小需要resize成2048 x 1024吗?如若不压缩会有什么影响呢? 谢谢~

倒不是说最佳适配图片大小是2048 * 1024,只是训练阶段图片都按照这个大小进行训练,推理时可以和训练时一致,也可以尝试其他size找到最佳分辨率

还有一个问题想要请教一下,训练时的图片大小是如何影响模型性能的呢?图片越大越好吗(虽然会拖慢训练速度)。我想要预测的结果会存在一些微小情况,因此希望模型可以识别细微特征,请问在这种情况下应如何选择呢?谢谢

在特征丰富度和训练速度之间取平衡即可

@TingquanGao
Copy link
Collaborator

The issue has no response for a long time and will be closed. You can reopen or new another issue if are still confused.


From Bot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants