You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

TensorRT Python包与Python3.6不兼容,求手动安装方案

Installing TensorRT 4 on Python 3.6 via Manual File Copy

Yep, you absolutely can get TensorRT 4 working with Python 3.6 by manually copying the necessary files—I’ve tackled this exact scenario before. Here’s a step-by-step breakdown:

Step 1: Extract the Python 3.5 Wheel File

The .whl file is just a zip archive under the hood. Unpack it to access the internal files:

unzip tensorrt-4.0.0.3-cp35-cp35m-linux_x86_64.whl -d tensorrt_temp

Step 2: Copy the TensorRT Python Module to Your Python 3.6 Site Packages

First, find the path to your Python 3.6’s site-packages directory (this is where Python looks for installed modules):

python3.6 -c "import site; print(site.getsitepackages()[0])"

Then copy the extracted tensorrt folder into that path. For example, if the path is /usr/local/lib/python3.6/dist-packages:

sudo cp -r tensorrt_temp/tensorrt /usr/local/lib/python3.6/dist-packages/

Step 3: Install the Required Shared Libraries

The TensorRT tarball should include a lib directory (usually at TensorRT-4.0.0.3/lib) containing the core TensorRT shared libraries. You need to make these accessible to Python:

  • Option 1 (Global Installation): Copy the libraries to a system-wide library path and update the cache:
    sudo cp TensorRT-4.0.0.3/lib/*.so /usr/local/lib/
    sudo ldconfig
    
  • Option 2 (Local/Environment-Specific): Add the TensorRT lib directory to your LD_LIBRARY_PATH environment variable. You can add this line to your ~/.bashrc or ~/.zshrc to make it permanent:
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/TensorRT-4.0.0.3/lib
    

Step 4: Verify the Installation

Test if TensorRT loads correctly in Python 3.6:

python3.6 -c "import tensorrt; print(f'TensorRT version: {tensorrt.__version__}')"

Notes & Potential Fixes

  • If you get import errors related to missing symbols, double-check that your CUDA and cuDNN versions are compatible with TensorRT 4 (TensorRT 4 typically requires CUDA 9.0/9.1 and cuDNN 7.0.x).
  • Rarely, you might run into ABI compatibility issues between Python 3.5 and 3.6. If this happens, you can try modifying the wheel’s metadata (editing the tensorrt_temp/tensorrt.dist-info/WHEEL file to list cp36 as a supported platform) and repacking it into a new wheel, then installing with pip—but the manual copy method usually works without this extra step.

内容的提问来源于stack exchange,提问作者Sam

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 08:40:15