解决“测试TensorRT安装过程中download_pgms.py报错”问题

问题描述

尝试使用TensorRT对yolov5模型推理加速,首先进行安装,参考博客已经写的很详细了:Ubuntu1804+CUDA10.0安装TensorRT7

对了,在更改环境配置的时候还添加了CUDA和cuDNN:

vim ~/.bashrc

# tensorrt cuda and cudnn
export CUDA_INSTALL_DIR=/usr/local/cuda
export CUDNN_INSTALL_DIR=/usr/local/cuda


source ~/.bashrc

但是在测试TensorRT是否安装成功时,需要下载MNIST数据集,运行download_pgms.py会有两个报错:

1.函数报错

download_pgms.py:12: DeprecationWarning: The binary mode of fromstring is deprecated, as it behaves surprisingly on unicode inputs. Use frombuffer instead
  raw_buf = np.fromstring(buffer, dtype=np.uint8)
download_pgms.py:23: DeprecationWarning: The binary mode of fromstring is deprecated, as it behaves surprisingly on unicode inputs. Use frombuffer instead
  raw_buf = np.fromstring(buffer, dtype=np.uint8)

2.网络连接报错:

urllib.error.HTTPError: HTTP Error 503: Service Unavailable

解决方法

1.更改函数名称

# 源代码
  raw_buf = np.fromstring(buffer, dtype=np.uint8)

  raw_buf = np.fromstring(buffer, dtype=np.uint8)

# 改为

  raw_buf = np.frombuffer(buffer, dtype=np.uint8)

  raw_buf = np.frombuffer(buffer, dtype=np.uint8)

2.网络连接报错,这个就没办法了,只能看运气多运行几次程序试试,运气好就下载下来提取到的pgm文件了:

解决“测试TensorRT安装过程中download_pgms.py报错”问题_第1张图片

 

测试安装成功如图:

解决“测试TensorRT安装过程中download_pgms.py报错”问题_第2张图片

 

还参考了一篇博客:ubuntu 下安装 TensorRT 7.0 以及验证

你可能感兴趣的:(Python,debug,踩坑记录,python,ubuntu,TensorRT)