安装 torch-tensorrt 报错?

作者站长头像
站长
· 阅读数 23

教程: https://pytorch.org/TensorRT/tutorials/installation.html

安装 torch-tensorrt 报错?

╰─➤  pip install torch-tensorrt -f https://github.com/NVIDIA/Torch-TensorRT/releases 
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Looking in links: https://github.com/NVIDIA/Torch-TensorRT/releases
Collecting torch-tensorrt
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/f3/5e/81c357454c59acedb1b83bfa1e2032f95bde827b5631bb695af6911f5a14/torch-tensorrt-0.0.0.post1.tar.gz (9.0 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [13 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-43y1ectf/torch-tensorrt_1366a8a2e4074e988cfb338889f6660c/setup.py", line 125, in <module>
          raise RuntimeError(open("ERROR.txt", "r").read())
      RuntimeError:
      ###########################################################################################
      The package you are trying to install is only a placeholder project on PyPI.org repository.
      To install Torch-TensorRT please run the following command:
      
      $ pip install torch-tensorrt -f https://github.com/NVIDIA/Torch-TensorRT/releases
      ###########################################################################################
      
      [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.

环境是 pipenv 创建的 python3.10 虚拟环境

(image2vector) ╭─ponponon@M60GPU ~/code/image2vector  ‹master*› 
╰─➤  python --version                                                                                                                                                                                                                                                   1 ↵
Python 3.10.6
(image2vector) ╭─ponponon@M60GPU ~/code/image2vector  ‹master*› 
╰─➤  pip --version                                                                  
pip 23.0.1 from /home/ponponon/.local/share/virtualenvs/image2vector-oucNrpsS/lib/python3.10/site-packages/pip (python 3.10)

上传到 pypi 的 torch-tensorrt 是不可使用的

安装 torch-tensorrt 报错?

我查了一下 pip 的 -f 参数的用法,说是先搜索 -f 指定的仓库,在使用默认的仓库

安装 torch-tensorrt 报错?

所以,这个 pip 为什么不去 github 下载 torch-tensorrt,而是去了清华源呢?


问题和 pypi 源无关

换了几个源,也是没用

aliyun 不行

pip install torch-tensorrt -f https://github.com/NVIDIA/Torch-TensorRT/releases -i https://mirrors.aliyun.com/pypi/simple/                    1 ↵
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Looking in links: https://github.com/NVIDIA/Torch-TensorRT/releases
Collecting torch-tensorrt
  Downloading https://mirrors.aliyun.com/pypi/packages/f3/5e/81c357454c59acedb1b83bfa1e2032f95bde827b5631bb695af6911f5a14/torch-tensorrt-0.0.0.post1.tar.gz (9.0 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [13 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-h9ttq398/torch-tensorrt_dd19014765894c7781117b8cfe81726a/setup.py", line 125, in <module>
          raise RuntimeError(open("ERROR.txt", "r").read())
      RuntimeError:
      ###########################################################################################
      The package you are trying to install is only a placeholder project on PyPI.org repository.
      To install Torch-TensorRT please run the following command:
      
      $ pip install torch-tensorrt -f https://github.com/NVIDIA/Torch-TensorRT/releases
      ###########################################################################################
      
      [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.

清华 不行

╰─➤  pip install torch-tensorrt -f https://github.com/NVIDIA/Torch-TensorRT/releases -i https://pypi.tuna.tsinghua.edu.cn/simple
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Looking in links: https://github.com/NVIDIA/Torch-TensorRT/releases
Collecting torch-tensorrt
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/f3/5e/81c357454c59acedb1b83bfa1e2032f95bde827b5631bb695af6911f5a14/torch-tensorrt-0.0.0.post1.tar.gz (9.0 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [13 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-z3s3hdj1/torch-tensorrt_668cdb167fd94274bb2438b6ca5b94ef/setup.py", line 125, in <module>
          raise RuntimeError(open("ERROR.txt", "r").read())
      RuntimeError:
      ###########################################################################################
      The package you are trying to install is only a placeholder project on PyPI.org repository.
      To install Torch-TensorRT please run the following command:
      
      $ pip install torch-tensorrt -f https://github.com/NVIDIA/Torch-TensorRT/releases
      ###########################################################################################
      
      [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.
回复
1个回答
avatar
test
2024-07-08

answer image

解决方案,把 wheel 文件下载到本地,本地安装就行

回复
likes
适合作为回答的
  • 经过验证的有效解决办法
  • 自己的经验指引,对解决问题有帮助
  • 遵循 Markdown 语法排版,代码语义正确
不该作为回答的
  • 询问内容细节或回复楼层
  • 与题目无关的内容
  • “赞”“顶”“同问”“看手册”“解决了没”等毫无意义的内容