TensorRT(8):python版本安装,CUDA11.0,win10

windows下安装TensorRT

一、底层库依赖

在安装TensorRT前,首先需要安装CUDA、CUDNN等NVIDIA的基本库,如何安装,已经老生常谈了,这里不再过多描述。
关于版本的选择,楼主这里:

CUDA版本,楼主这里选择的是 cuda11.0 ,具体cuda版本见https://developer.nvidia.com/cuda-toolkit-archive,可自行下载。
CUDNN版本,选择 cudnn-11.0-windows-x64-v8.2.1.32,官网下载需要先注册账号,https://developer.nvidia.com/rdp/cudnn-archive
pycuda 选择 11.4

二、下载并安装TensorRT库

法一:通过pip安装

目前 pip wheel 的方式只支持 Python 3.6 - 3.9,CUDA 11.x,因为我们不是在系统的 Python 里安装,CUDA 版本暂时不用管。

        之后需要安装 nvidia-pyindex 包,这其实是一个 pip 源,用来连接英伟达的服务器下载我们需要的各种包。所以如果安装的时候,pip 下载很慢也只能等着,只能从英伟达的服务器下载,pip 换源也没用。安装 nvidia-pyindex 包用下面这条命令:

pip install nvidia-pyindex

安装装好之后,就可以开始安装 TensorRT 了。使用下面的命令:

pip install --upgrade nvidia-tensorrt

 这条命令会安装或者更新已有的 TensorRT,同时会自动下载安装 CUDA 和 cuDNN,它们是 TensorRT 的依赖包。因为安装的时候没有指定版本号,这里默认都会安装最新的版本,CUDA 的版本可能比我们实际支持的版本更高。在终端输入  nvidia-smi 可以查看显卡状态,上面会显示支持的 CUDA 版本。使用 deb 方式安装时,要在系统里安装 CUDA,要和这里的版本号一致,安装在虚拟环境里时就不需要了。

        安装的时候如果出现下面的错误信息,说明没用被正确的安装,除了可能是 Python 版本不对外,也有可能是驱动没装上。

This package can be installed as:
```
$ pip install nvidia-pyindex
$ pip install nvidia-tensorrt

参考文章:https://www.cnblogs.com/asnelin/archive/2022/02/24/15929442.html 

法二:通过官网下载ZAR包安装 

1.首先去官网下载对应的TensorRT版本
https://developer.nvidia.com/nvidia-tensorrt-8x-download

2.点击 Download Now(需要登录英伟达账号,没有的注册一个)

3.选择下载的版本

4.完成问卷调查

5.选择同意协议

楼主选的这,再选择对应的系统版本

 6.根据自己的系统版本和 CUDA 版本,选择安装包,如图所示(如果是完整安装,建议选择Tar File Install Packages,这样可以自行选择安装位置)

 

 解压下来对应多个文件,把lib里的所有dll库都拷贝到cuda在的目录下(或者添加到环节变量)。

 拷贝到 :C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\bin

最后,控制台进入安装包的python目录,选择对应的python版本进行安装即可

 如楼主这里是python3.8

在conda环境输入其所在的目录,安装即可:

pip install "C:\Users\lenovo\Desktop\复试\TensorRT-8.2.3.0\python\tensorrt-8.2.3.0-cp38-none-win_amd64.whl"

三、测试是否安装成功

 进入python环境,输入:

import tensorrt as trt
print(trt.__version__)

则安装成功

参考文章:TensorRT(10):python版本安装_python安装tensorrt_hjxu2016的博客-优快云博客

自编译tensorflow: 1.python3.5,tensorflow1.12; 2.支持cuda10.0,cudnn7.3.1,TensorRT-5.0.2.6-cuda10.0-cudnn7.3; 3.支持mkl,无MPI; 软硬件硬件环境:Ubuntu16.04,GeForce GTX 1080 配置信息: hp@dla:~/work/ts_compile/tensorflow$ ./configure WARNING: --batch mode is deprecated. Please instead explicitly shut down your Bazel server using the command "bazel shutdown". You have bazel 0.19.1 installed. Please specify the location of python. [Default is /usr/bin/python]: /usr/bin/python3 Found possible Python library paths: /usr/local/lib/python3.5/dist-packages /usr/lib/python3/dist-packages Please input the desired Python library path to use. Default is [/usr/local/lib/python3.5/dist-packages] Do you wish to build TensorFlow with XLA JIT support? [Y/n]: XLA JIT support will be enabled for TensorFlow. Do you wish to build TensorFlow with OpenCL SYCL support? [y/N]: No OpenCL SYCL support will be enabled for TensorFlow. Do you wish to build TensorFlow with ROCm support? [y/N]: No ROCm support will be enabled for TensorFlow. Do you wish to build TensorFlow with CUDA support? [y/N]: y CUDA support will be enabled for TensorFlow. Please specify the CUDA SDK version you want to use. [Leave empty to default to CUDA 10.0]: Please specify the location where CUDA 10.0 toolkit is installed. Refer to README.md for more details. [Default is /usr/local/cuda]: /usr/local/cuda-10.0 Please specify the cuDNN version you want to use. [Leave empty to default to cuDNN 7]: 7.3.1 Please specify the location where cuDNN 7 library is installed. Refer to README.md for more details. [Default is /usr/local/cuda-10.0]: Do you wish to build TensorFlow with TensorRT support? [y/N]: y TensorRT support will be enabled for TensorFlow. Please specify the location where TensorRT is installed. [Default is /usr/lib/x86_64-linux-gnu]:/home/hp/bin/TensorRT-5.0.2.6-cuda10.0-cudnn7.3/targets/x86_64-linux-gnu Please specify the locally installed NCCL version you want to use. [Default is to use https://github.com/nvidia/nccl]: Please specify a list of comma-separated Cuda compute capabilities you want to build with. You can find the compute capability of your device at: https://developer.nvidia.com/cuda-gpus. Please note that each additional compute capability significantly increases your build time and binary size. [Default is: 6.1,6.1,6.1]: Do you want to use clang as CUDA compiler? [y/N]: nvcc will be used as CUDA compiler. Please specify which gcc should be used by nvcc as the host compiler. [Default is /usr/bin/gcc]: Do you wish to build TensorFlow with MPI support? [y/N]: No MPI support will be enabled for TensorFlow. Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native -Wno-sign-compare]: Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]: Not configuring the WORKSPACE for Android builds. Preconfigured Bazel build configs. You can use any of the below by adding "--config=" to your build command. See .bazelrc for more details. --config=mkl # Build with MKL support. --config=monolithic # Config for mostly static monolithic build. --config=gdr # Build with GDR support. --config=verbs # Build with libverbs support. --config=ngraph # Build with Intel nGraph support. --config=dynamic_kernels # (Experimental) Build kernels into separate shared objects. Preconfigured Bazel build configs to DISABLE default on features: --config=noaws # Disable AWS S3 filesystem support. --config=nogcp # Disable GCP support. --config=nohdfs # Disable HDFS support. --config=noignite # Disable Apacha Ignite support. --config=nokafka # Disable Apache Kafka support. --config=nonccl # Disable NVIDIA NCCL support. Configuration finished 编译: hp@dla:~/work/ts_compile/tensorflow$ bazel build --config=opt --config=mkl --verbose_failures //tensorflow/tools/pip_package:build_pip_package 卸载已有tensorflow: hp@dla:~/temp$ sudo pip3 uninstall tensorflow 安装自己编译的成果: hp@dla:~/temp$ sudo pip3 install tensorflow-1.12.0-cp35-cp35m-linux_x86_64.whl
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值