ubuntu TensorRT

不羁岁月 提交于 2020-11-13 01:05:56

 

star@xmatrix:~$ 
star@xmatrix:~$ 
star@xmatrix:~$ lspci |grep -i vga
08:00.0 VGA compatible controller: ASPEED Technology, Inc. ASPEED Graphics Family (rev 30)
star@xmatrix:~$ 
star@xmatrix:~$ 
star@xmatrix:~$ 
star@xmatrix:~$ lspci | grep -i nvidia
02:00.0 3D controller: NVIDIA Corporation GP104GL [Tesla P4] (rev a1)
star@xmatrix:~$ 
star@xmatrix:~$ 
star@xmatrix:~$ cat /proc/driver/nvidia/version
NVRM version: NVIDIA UNIX x86_64 Kernel Module  418.67  Sat Apr  6 03:07:24 CDT 2019
GCC version:  gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.12) 
star@xmatrix:~$ 
star@xmatrix:~$ 
star@xmatrix:~$ nvidia-smi
Thu Dec 26 17:19:43 2019       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 418.67       Driver Version: 418.67       CUDA Version: 10.1     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Tesla P4            Off  | 00000000:02:00.0 Off |                    0 |
| N/A   76C    P0    43W /  75W |   7483MiB /  7611MiB |     48%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0     10454      C   python                                      7473MiB |
+-----------------------------------------------------------------------------+
star@xmatrix:~$ 
star@xmatrix:~$ 
star@xmatrix:~$

 

1、下载对应的版本

=====================================================================================

NVIDIA TensorRT is a platform for high performance deep learning inference.

TensorRT works across all NVIDIA GPUs using the CUDA platform. The following files are for use for Linux servers and workstations running NVIDIA Quadro, GeForce, and Tesla GPUs. NVIDIA recommends Tesla V100, T4, P4, and P40 GPUs for production deployment.

I Agree To the Terms of the NVIDIA TensorRT License Agreement

Please download the version compatible with your development environment

Documentation

TensorRT 7.0 for Linux

Debian and RPM Install Packages for Linux x86
Tar File Install Packages For Linux x86
Debian and RPM Install Packages For Linux Power
Tar File Install Packages For Linux Power

TensorRT 7.0 For Windows

Windows ZIP Package

TensorRT is also available on the following NVIDIA GPU platforms:

=====================================================================================

2、配置环境变量

# cuda
export LD_LIBRARY_PATH=/home/star/TensorRT/TensorRT-7.0.0.11/lib:$LD_LIBRARY_PATH
export CUDA_INSTALL_DIR=/usr/local/cuda-10.1
export CUDNN_INSTALL_DIR=/usr/local/cuda-10.1

 

(wind1) star@xmatrix:~/TensorRT/TensorRT/build$ 
(wind1) star@xmatrix:~/TensorRT/TensorRT/build$ 
(wind1) star@xmatrix:~/TensorRT/TensorRT/build$ 
(wind1) star@xmatrix:~/TensorRT/TensorRT/build$ 
(wind1) star@xmatrix:~/TensorRT/TensorRT/build$ 
(wind1) star@xmatrix:~/TensorRT/TensorRT/build$ 
(wind1) star@xmatrix:~/TensorRT/TensorRT/build$ 
(wind1) star@xmatrix:~/TensorRT/TensorRT/build$ vim ~/.bashrc
(wind1) star@xmatrix:~/TensorRT/TensorRT/build$ 
(wind1) star@xmatrix:~/TensorRT/TensorRT/build$ 
(wind1) star@xmatrix:~/TensorRT/TensorRT/build$ 
(wind1) star@xmatrix:~/TensorRT/TensorRT/build$ 
(wind1) star@xmatrix:~/TensorRT/TensorRT/build$ 
(wind1) star@xmatrix:~/TensorRT/TensorRT/build$ 
(wind1) star@xmatrix:~/TensorRT/TensorRT/build$ cat ~/.bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar

# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
    xterm-color|*-256color) color_prompt=yes;;
esac

# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
    # We have color support; assume it's compliant with Ecma-48
    # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
    # a case would tend to support setf rather than setaf.)
    color_prompt=yes
    else
    color_prompt=
    fi
fi

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    #alias dir='dir --color=auto'
    #alias vdir='vdir --color=auto'

    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
fi

# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'

# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

# Add an "alert" alias for long running commands.  Use like so:
#   sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
fi

# Anaconda 2019-12-22
export PATH=$PATH:/home/star/anaconda3/bin

# cuda
export LD_LIBRARY_PATH=/home/star/TensorRT/TensorRT-7.0.0.11/lib:$LD_LIBRARY_PATH
export CUDA_INSTALL_DIR=/usr/local/cuda-10.1
export CUDNN_INSTALL_DIR=/usr/local/cuda-10.1
(wind1) star@xmatrix:~/TensorRT/TensorRT/build$ 
(wind1) star@xmatrix:~/TensorRT/TensorRT/build$ 
(wind1) star@xmatrix:~/TensorRT/TensorRT/build$ 
(wind1) star@xmatrix:~/TensorRT/TensorRT/build$ 
(wind1) star@xmatrix:~/TensorRT/TensorRT/build$ 
(wind1) star@xmatrix:~/TensorRT/TensorRT/build$

 

----------------------------------------------------------------------------------------------

star@xmatrix:~/TensorRT/TensorRT-7.0.0.11$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11$ cd python
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/python$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/python$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/python$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/python$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/python$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/python$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/python$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/python$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/python$ ls
tensorrt-7.0.0.11-cp27-none-linux_x86_64.whl  tensorrt-7.0.0.11-cp36-none-linux_x86_64.whl
tensorrt-7.0.0.11-cp34-none-linux_x86_64.whl  tensorrt-7.0.0.11-cp37-none-linux_x86_64.whl
tensorrt-7.0.0.11-cp35-none-linux_x86_64.whl
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/python$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/python$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/python$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/python$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/python$ pip3 --version
pip 19.3.1 from /usr/local/lib/python3.5/dist-packages/pip (python 3.5)
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/python$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/python$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/python$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/python$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/python$ sudo pip3 install tensorrt-7.0.0.11-cp35-none-linux_x86_64.whl
[sudo] password for star:
WARNING: The directory '/home/star/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
WARNING: The directory '/home/star/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Processing ./tensorrt-7.0.0.11-cp35-none-linux_x86_64.whl
Installing collected packages: tensorrt
Successfully installed tensorrt-7.0.0.11
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/python$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/python$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/python$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/python$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/python$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/python$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/python$ python3
Python 3.5.2 (default, Oct  8 2019, 13:06:37)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import tensorrt
>>> #导入tensorrt发现不报错
>>> exit();
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/python$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/python$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/python$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/python$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/python$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/python$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/python$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/python$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/python$ cd ../
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11$ ls
bin  data  doc  graphsurgeon  include  lib  python  samples  targets  TensorRT-Release-Notes.pdf  uff
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11$ cd uff
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/uff$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/uff$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/uff$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/uff$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/uff$ ls
uff-0.6.5-py2.py3-none-any.whl
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/uff$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/uff$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/uff$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/uff$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/uff$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/uff$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/uff$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/uff$ sudo pip3 install uff-0.6.5-py2.py3-none-any.whl
WARNING: The directory '/home/star/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
WARNING: The directory '/home/star/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Processing ./uff-0.6.5-py2.py3-none-any.whl
Requirement already satisfied: protobuf>=3.3.0 in /home/star/.local/lib/python3.5/site-packages (from uff==0.6.5) (3.7.1)
Requirement already satisfied: numpy>=1.11.0 in /home/star/.local/lib/python3.5/site-packages (from uff==0.6.5) (1.16.3)
Requirement already satisfied: six>=1.9 in /home/star/.local/lib/python3.5/site-packages (from protobuf>=3.3.0->uff==0.6.5) (1.12.0)
Requirement already satisfied: setuptools in /home/star/.local/lib/python3.5/site-packages (from protobuf>=3.3.0->uff==0.6.5) (41.0.1)
Installing collected packages: uff
Successfully installed uff-0.6.5
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/uff$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/uff$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/uff$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/uff$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/uff$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/uff$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/uff$ which convert-to-uff
/usr/local/bin/convert-to-uff
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/uff$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/uff$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/uff$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/uff$ python3
Python 3.5.2 (default, Oct  8 2019, 13:06:37)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>>
>>> import tensorrt
>>> tensorrt.__version__
'7.0.0.11'
>>>
>>> exit();
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/uff$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/uff$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/uff$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/uff$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/uff$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/uff$
star@xmatrix:~/TensorRT/TensorRT-7.0.0.11/uff$

配置成功

 

 

参考:https://blog.csdn.net/calmuse/article/details/93616720   

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!