一. 安装cuda
(nvcc -V 查看是否安装cuda)
1.查看linux型号:
cat /proc/version
我的是:
Linux version 5.4.0-107-generic (buildd@lcy02-amd64-058) (gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1)) #121-Ubuntu SMP Thu Mar 24 16:04:27 UTC 2022
2.根据型号下载cuda
image.png3.执行给的两行代码:
wget https://developer.download.nvidia.com/compute/cuda/11.6.0/local_installers/cuda_11.6.0_510.39.01_linux.run
sudo sh cuda_11.6.0_510.39.01_linux.run --override
第二行代码可以加上 --override
稍等一会,会弹出一个界面,输入accept
将cuda自带的驱动用回车取消勾选,进行安装。
image.png
二.下载cudnn
1.下载
https://developer.nvidia.com/cudnn
下载第三个或者以下链接:
Local Installer for Linux x86_64 (Tar)
2.解压压缩包:
tar -xvf cudnn-linux-x86_64-8.3.3.40_cuda11.5-archive.tar.xz
3.把解压后的文件复制粘贴到cuda文件夹内:
cp -r cudnn-linux-x86_64-8.3.3.40_cuda11.5-archive/include/* /usr/local/cuda/include/
cp -r cudnn-linux-x86_64-8.3.3.40_cuda11.5-archive/lib/* /usr/local/cuda/lib64/
cp -r cudnn-linux-x86_64-8.3.3.40_cuda11.5-archive/include/* /usr/local/cuda-11.6/include/
cp -r cudnn-linux-x86_64-8.3.3.40_cuda11.5-archive/lib/* /usr/local/cuda-11.6/lib64/
4.添加环境变量:
vim ~/.bashrc
#在末尾添加上:
export LD_LIBRARY_PATH=/usr/local/cuda/lib64/:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH=/usr/local/cuda-11.6/lib64/:${LD_LIBRARY_PATH}
#退出vim后
source ~/.bashrc
三.配置tensorRT
1.下载:
下载网页:
https://developer.nvidia.com/nvidia-tensorrt-8x-download
(下载.tar格式更灵活一些)
2.跟着官方步骤走
https://docs.nvidia.com/deeplearning/tensorrt/install-guide/index.html#installing-tar
3.安装好后
cd xxx/TensorRT-x.x.x.x/samples
make
然后添加环境变量:
source ~/.bashrc
#末尾添加:
export LD_LIBRARY_PATH=/root/autodl-tmp/TensorRT-8.4.1.4/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export PATH=/root/autodl-tmp/TensorRT-8.4.1.4/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/root/autodl-tmp/TensorRT-8.4.1.4/lib/:$LD_LIBRARY_PATH
#保存退出vim
source ~/.bashrc
安装polygraphy:
python -m pip install colored polygraphy --extra-index-url https://pypi.ngc.nvidia.com
安装onnxruntime:
pip install onnxruntime
#安装onnxruntime-gpu要根据官网选择版本
#[https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html](https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html)
pip install onnxruntime-gpu==xx
网友评论