本文主要是介绍【subprocess-exited-with-error】pip安装tensorrt-9.3.0.post12.dev1.tar.gz,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
目录
- 前情提要
- 报错内容
- 报错一:9.3.0版本无法安装
- 报错二:8.6.1版本无法安装
- 解决方案
- 解决一:设置英伟达源
- 解决二:设置清华源下的英伟达源
- 后记
- 检验
- 设置include路径
- 设置lib路径
前情提要
本人已设置过清华源
https://pypi.tuna.tsinghua.edu.cn/simple
安装之前需要更新pip,安装nvidia-pyindex
python3 -m pip install --upgrade setuptools pip
python3 -m pip install nvidia-pyindex
报错内容
报错一:9.3.0版本无法安装
安装TensorRT官网指导安装时出现的报错:
# python3 -m pip install --pre --upgrade tensorrt
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple, https://pypi.ngc.nvidia.com
Collecting tensorrtDownloading https://pypi.tuna.tsinghua.edu.cn/packages/bc/70/d633add6eef5edf414f3ec48b3fe9b0116837cf4b935edc531ede2e65b00/tensorrt-9.3.0.post12.dev1.tar.gz (6.9 kB)Preparing metadata (setup.py) ... errorerror: subprocess-exited-with-error× python setup.py egg_info did not run successfully.│ exit code: 1╰─> [6 lines of output]Traceback (most recent call last):File "<string>", line 2, in <module>File "<pip-setuptools-caller>", line 34, in <module>File "/tmp/pip-install-pd1g0qot/tensorrt_ab7006731a644e11b9e76fbb52612c47/setup.py", line 90, in <module>raise RuntimeError("Bad params")RuntimeError: Bad params[end of output]note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed× Encountered error while generating package metadata.
╰─> See above for output.note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
报错二:8.6.1版本无法安装
安装中没有反应,只能手动取消
# pip install tensorrt
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting tensorrtUsing cached https://pypi.tuna.tsinghua.edu.cn/packages/46/08/da496b4f20890b6f717f159bbdda98e9248b560e712aa22cd9bb1daafe15/tensorrt-8.6.1.post1.tar.gz (18 kB)Preparing metadata (setup.py) ... done
Building wheels for collected packages: tensorrtBuilding wheel for tensorrt (setup.py) ... |^canceled
ERROR: Operation cancelled by user
解决方案
解决一:设置英伟达源
pip config set global.index-url https://pypi.nvidia.com
python3 -m pip install --pre --upgrade tensorrt
这种方式安装的是最新版9.3.0
安装时弹出的查找地址为
Looking in indexes: https://pypi.nvidia.com, https://pypi.ngc.nvidia.com
解决二:设置清华源下的英伟达源
pip install tensorrt --extra-index-url https://pypi.nvidia.com
这种方式安装的是最旧版8.6.1
安装时弹出的查找地址为
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple, https://pypi.ngc.nvidia.com, https://pypi.nvidia.com
后记
我安装的自然是最新版9.3.0
检验
python
import tensorrt
print(tensorrt.__version__)
# 9.3.0.post12.dev1
assert tensorrt.Builder(tensorrt.Logger())
到这里还没结束,在之后需要编译的时候,需要指定tensorrt的lib和include路径,用pip安装的话路径和别的安装方法(tar、deb)中的路径不太一样,千万要注意!
设置include路径
git clone https://github.com/NVIDIA/TensorRT.git
cd TensorRT
git submodule update --init --recursive
其中git submodule update --init --recursive
运行后要检查是否有出现Failed
,有话再次运行进行下载
这样include路径就确认了
设置lib路径
在python路径下找
which python
#/root/anaconda3/envs/sakura/bin/python
cd /root/anaconda3/envs/sakura/lib/python3.10/site-packages/tensorrt_libs
ls
# __init__.py __pycache__ libnvinfer.so.9 libnvinfer_builder_resource.so.9.3.0 libnvinfer_plugin.so.9 libnvonnxparser.so.9
可以看到许多动态库.so文件
之后编译的时候只需要修改tensorrt的lib和include位置即可
include directories
对应include
link directories
对应lib
这篇关于【subprocess-exited-with-error】pip安装tensorrt-9.3.0.post12.dev1.tar.gz的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!