PaddlePaddle/PaddleSeg

用Predict.py进行推理时,无法使用GPU进行推理,一直默认使用CPU,请问如何解决?

Qiuyanghang opened this issue · 0 comments

问题确认 Search before asking

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

请提出你的问题 Please ask your question

刚接触paddleseg,配置好环境后想直接测试提供的预训练模型效果如何,但其始终用CPU进行推理,不清楚是什么原因,请问如何调用GPU推理。
尝试了以下操作都不管:1.用命令行参数设置GPU设备 2.pycharm终端运行前用 set CUDA_VISIBLE_DEVICES=0 设置GPU
python版本:3.9 paddlepaddle-gpu版本: 2.6.1.post116 paddleseg版本:2.8.0 cuda版本:11.6
window系统,一张3060显卡。
预测脚本运行时的信息:
------------Environment Information-------------
platform: Windows-10-10.0.19045-SP0
Python: 3.9.19 (main, Mar 21 2024, 17:21:27) [MSC v.1916 64 bit (AMD64)]
Paddle compiled with cuda: True
NVCC: Build cuda_11.6.r11.6/compiler.30794723_0
cudnn: 8.6
GPUs used: 1
CUDA_VISIBLE_DEVICES: None
GPU: ['GPU 0: NVIDIA GeForce']
PaddleSeg: 2.8.0
PaddlePaddle: 2.6.1
OpenCV: 4.5.5

2024-05-29 19:05:57 [INFO]
---------------Config Information---------------
batch_size: 4
iters: 160000
train_dataset:
dataset_root: data/cityscapes
mode: train
transforms:

  • max_scale_factor: 2.0
    min_scale_factor: 0.5
    scale_step_size: 0.25
    type: ResizeStepScaling
  • crop_size:
    • 1024
    • 512
      type: RandomPaddingCrop
  • type: RandomHorizontalFlip
  • brightness_range: 0.5
    contrast_range: 0.5
    saturation_range: 0.5
    type: RandomDistort
  • type: Normalize
    type: Cityscapes
    val_dataset:
    dataset_root: data/cityscapes
    mode: val
    transforms:
  • type: Normalize
    type: Cityscapes
    optimizer:
    momentum: 0.9
    type: SGD
    weight_decay: 0.0005
    lr_scheduler:
    end_lr: 0
    learning_rate: 0.005
    power: 0.9
    type: PolynomialDecay
    warmup_iters: 1000
    warmup_start_lr: 1.0e-05
    loss:
    coef:
  • 1
  • 1
  • 1
    types:
  • min_kept: 130000
    type: OhemCrossEntropyLoss
  • min_kept: 130000
    type: OhemCrossEntropyLoss
  • min_kept: 130000
    type: OhemCrossEntropyLoss
    model:
    backbone:
    pretrained: https://bj.bcebos.com/paddleseg/dygraph/PP_STDCNet2.tar.gz
    type: STDC2
    type: PPLiteSeg
    test_config:
    aug_eval: true
    scales: 1.0

2024-05-29 19:05:57 [INFO] Set device: cpu
2024-05-29 19:05:57 [WARNING] Add the num_classes in train_dataset class to model config. We suggest you manually set num_classes in model config.
2024-05-29 19:05:57 [WARNING] Add the in_channels in train_dataset class to model config. We suggest you manually set in_channels in model config.
2024-05-29 19:05:57 [INFO] Use the following config to build model
model:
backbone:
in_channels: 3
pretrained: https://bj.bcebos.com/paddleseg/dygraph/PP_STDCNet2.tar.gz
type: STDC2
num_classes: 19
type: PPLiteSeg
2024-05-29 19:05:58 [INFO] Loading pretrained model from https://bj.bcebos.com/paddleseg/dygraph/PP_STDCNet2.tar.gz
2024-05-29 19:05:58 [INFO] There are 265/265 variables loaded into STDCNet.
2024-05-29 19:05:58 [INFO] The number of images: 33
2024-05-29 19:05:58 [INFO] Loading pretrained model from my_model/model_pp.pdparams
2024-05-29 19:05:59 [WARNING] ppseg_head.arm_list.0._scale is not in pretrained model
2024-05-29 19:05:59 [WARNING] ppseg_head.arm_list.1._scale is not in pretrained model
2024-05-29 19:05:59 [WARNING] ppseg_head.arm_list.2._scale is not in pretrained model
2024-05-29 19:05:59 [INFO] There are 367/370 variables loaded into PPLiteSeg.
2024-05-29 19:05:59 [INFO] Start to predict...
7/33 [=====>........................] - ETA: 58s Traceback (most recent call last):