Paddle icon indicating copy to clipboard operation
Paddle copied to clipboard

jetson nano部署CPU推理正常 GPU推理报错

Open QQ39272490 opened this issue 5 years ago • 25 comments

问题类型:模型部署 问题描述 部署环境:Jetson nano,Jetpack 4.5 python3.6+nv_jetson-cuda10.2-cudnn8-trt7 安装官方提供的库 paddlepaddle_gpu-2.1.0-cp36-cp36m-linux_aarch64.whl 代码步骤如:https://paddleinference.paddlepaddle.org.cn/demo_tutorial/cuda_jetson_demo.html config.EnableUseGpu(500, 0); [使用GPU报错,停用GPU正常。报错代码如下图 QQ图片20210701173757

QQ39272490 avatar Jul 01 '21 09:07 QQ39272490

您好,我们已经收到了您的问题,会安排技术人员尽快解答您的问题,请耐心等待。请您再次检查是否提供了清晰的问题描述、复现代码、环境&版本、报错信息等。同时,您也可以通过查看官网API文档、常见问题、历史Issue、AI社区来寻求解答。祝您生活愉快~

Hi! We've received your issue and please be patient to get responded. We will arrange technicians to answer your questions as soon as possible. Please make sure that you have posted enough message to demo your request. You may also check out the API,FAQ,Github Issue and AI community to get the answer.Have a nice day!

paddle-bot-old avatar Jul 01 '21 09:07 paddle-bot-old

关闭TensorRT 是否能正常预测,你的模型是哪个

LDOUBLEV avatar Jul 01 '21 09:07 LDOUBLEV

用的mobileNetV1 关闭TensorRT也一样

QQ39272490 avatar Jul 01 '21 09:07 QQ39272490

我在Nano上测试了一下,可以运行GPU版本的预测

Nano 环境: image

使用的模型是: MobileNetV1_infer.tar.zip

执行预测的逻辑是:python3 infer.py --model_file ./MobileNetV1_infer/inference.pdmodel --params_file ./MobileNetV1_infer/inference.pdiparams 代码是:

import paddle
import argparse
import numpy as np
import paddle.inference as inference
from paddle.inference import Config
from paddle.inference import create_predictor
import cv2
import os

def parse_args():
    parser = argparse.ArgumentParser()
    parser.add_argument("--model_file", type=str, help="model filename")
    parser.add_argument("--params_file", type=str, help="parameter filename")
    parser.add_argument("--batch_size", type=int, default=1, help="batch size")

    return parser.parse_args()


def set_config(args):
    config = Config(args.model_file, args.params_file)
    config.disable_gpu()
    config.switch_use_feed_fetch_ops(False)
    config.switch_specify_input_names(True)
    return config


def main():
    args = parse_args()

    # 设置AnalysisConfig
    config = set_config(args)
    config.enable_use_gpu(200, 0) # use_gpu
    config.enable_memory_optim()
    config.enable_tensorrt_engine(
                precision_mode=inference.PrecisionType.Float32,
                max_batch_size=2)
    predictor = create_predictor(config)
    input_names = predictor.get_input_names()
    input_handle = predictor.get_input_handle(input_names[0])

    fake_input = np.random.randn(1, 3, 224, 224).astype("float32")
    print("fake_input:",fake_input.shape)
    input_handle.copy_from_cpu(fake_input)
    # 运行predictor
    predictor.run()
    # 获取输出
    output_names = predictor.get_output_names()
    output_handle = predictor.get_output_handle(output_names[0])
    out = output_handle.copy_to_cpu()   # numpy.ndarray类型

    print("out: ",out.shape)

main()

LDOUBLEV avatar Jul 01 '21 12:07 LDOUBLEV

我手中版本是nano 2G版本,运行至这个地方一直没动静了 image

QQ39272490 avatar Jul 02 '21 01:07 QQ39272490

image

QQ39272490 avatar Jul 02 '21 01:07 QQ39272490

image

QQ39272490 avatar Jul 02 '21 01:07 QQ39272490

你关闭TRT预测吧,把这一行屏蔽掉

config.enable_tensorrt_engine(
                precision_mode=inference.PrecisionType.Float32,
                max_batch_size=2)

LDOUBLEV avatar Jul 02 '21 02:07 LDOUBLEV

QQ图片20210701173629 还是一样没动静。。。

QQ39272490 avatar Jul 02 '21 02:07 QQ39272490

关闭GPU就正常了

QQ39272490 avatar Jul 02 '21 04:07 QQ39272490

image

QQ39272490 avatar Jul 02 '21 04:07 QQ39272490

测试其他模型是否能GPU预测,如果也不行,那应该是环境问题,可以尝试

  • 检查cuda、cudnn是否都安装好了
  • 更换其他paddle版本

LDOUBLEV avatar Jul 02 '21 05:07 LDOUBLEV

image image cuda cudnn 都没问题 paddle发布了2.1.1在哪可下载适合的whl库文件?

QQ39272490 avatar Jul 02 '21 06:07 QQ39272490

下载链接: 预测库: https://paddle-inference-lib.bj.bcebos.com/2.1.1-nv-jetson-jetpack4.4-nano/paddle_inference_install_dir.tgz whl包 https://paddle-inference-lib.bj.bcebos.com/2.1.1-nv-jetson-jetpack4.4-nano/paddlepaddle_gpu-2.1.1-cp36-cp36m-linux_aarch64.whl

LDOUBLEV avatar Jul 02 '21 07:07 LDOUBLEV

我看到桌面出现System throttled due to over-current,会不会是过流受限制了?

QQ39272490 avatar Jul 02 '21 07:07 QQ39272490

没有限制的,检查下网络吧

LDOUBLEV avatar Jul 04 '21 09:07 LDOUBLEV

网络肯定是没有问题,我烧了4.4没出现System throttled due to over-current,也下载了2.0的paddle-gpu版本,还是一样的问题,没有解决

QQ39272490 avatar Jul 04 '21 14:07 QQ39272490

whl包 https://paddle-inference-lib.bj.bcebos.com/2.1.1-nv-jetson-jetpack4.4-nano/paddlepaddle_gpu-2.1.1-cp36-cp36m-linux_aarch64.whl

尝试下提供的这个paddle whl包,我的机器上测试是可以的。

LDOUBLEV avatar Jul 05 '21 01:07 LDOUBLEV

@LDOUBLEV 方便加个微信或QQ吗?我是nano 2G版本,你是测试的哪种模型呢?

QQ39272490 avatar Jul 05 '21 01:07 QQ39272490

这里回复了问题,https://github.com/PaddlePaddle/Paddle/issues/31767

wangye707 avatar Jul 05 '21 03:07 wangye707