【conda/cuda/cudnn/tensorrt】一份简洁的深度学习环境安装清单
🚀本文主要总结一下conda、cuda、cudnn、tensorrt的快速安装。至于nvidia显卡驱动的安装,暂且不提。本文适合有一定反复安装经验的读者😂,方便其快速整理安装思路。
🌔01
conda
⭐️ 注意,conda环境中使用pip,是安装在该环境下,受conda影响;但使用apt依然安装在系统环境下,不受conda影响。
miniconda index
① {\color{#E16B8C}{①}} ① 选择合适的miniconda版本(假定用latest);
② {\color{#E16B8C}{②}} ② 用sh
安装,先用wget下载文件;
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
③ {\color{#E16B8C}{③}} ③ bash按照指引安装;
bash Miniconda3-latest-Linux-x86_64.sh
🌔02
CUDA
CUDA Toolkit Archive
① {\color{#E16B8C}{①}} ① 根据nvidia显卡驱动和ubuntu的版本选择cuda版本;
② {\color{#E16B8C}{②}} ② 使用runfile
安装(以cuda11.8为例);
chmod +x cuda_11.8.0_520.61.05_linux.run
./cuda_11.8.0_520.61.05_linux.run
③ {\color{#E16B8C}{③}} ③ 创建软连接;
cd /usr/local
ln -s cuda-11.8 cuda
④ {\color{#E16B8C}{④}} ④ 设置.bashrc;
# cuda
export CUDA_HOME=/usr/local/cuda
export PATH=$CUDA_HOME/bin:$PATH
export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH
export CPLUS_INCLUDE_PATH=$CUDA_HOME/include:$CPLUS_INCLUDE_PATH
🌔03
cuDNN
cuDNN Archive
① {\color{#E16B8C}{①}} ① 根据cuda版本选择cudnn版本;
② {\color{#E16B8C}{②}} ② 使用deb
安装(以cudnnn8.9.7为例);
dpkg -i cudnn-local-repo-ubuntu2204-8.9.7.29_1.0-1_amd64.deb
cp /var/cudnn-local-repo-ubuntu2204-8.9.7.29/cudnn-local-8AE81B24-keyring.gpg /usr/share/keyrings/
sudo apt update
sudo apt install libcudnn8
sudo apt install libcudnn8-dev
sudo apt install libcudnn8-samples
③ {\color{#E16B8C}{③}} ③设置.bashrc;
# cudnn
export CUDNN_HOME=/usr/lib/x86_64-linux-gnu
export LD_LIBRARY_PATH=$CUDNN_HOME/lib64:$LD_LIBRARY_PATH
🌔04
TensorRT
TensorRT Download
① {\color{#E16B8C}{①}} ① 根据cuda版本选择tensorrt版本;
② {\color{#E16B8C}{②}} ② 使用tar
安装(以tensorrt8.6.1为例);
tar -xzvf TensorRT-8.6.1.6.Linux.x86_64-gnu.cuda-11.8.tar.gz
sudo mv TensorRT-8.6.1.6 /usr/local
③ {\color{#E16B8C}{③}} ③ 创建软连接;
cd /usr/local
ln -s TensorRT-8.6.1.6 TensorRT
④ {\color{#E16B8C}{④}} ④ 设置.bashrc;
# tensorrt
export TENSORRT_HOME=/usr/local/TensorRT
export PATH=$TENSORRT_HOME/bin:$PATH
export LD_LIBRARY_PATH=$TENSORRT_HOME/lib:$LD_LIBRARY_PATH
export CPLUS_INCLUDE_PATH=$TENSORRT_HOME/include:$CPLUS_INCLUDE_PATH
⑤ {\color{#E16B8C}{⑤}} ⑤ 安装tensorrt python;
cd /usr/local/TensorRT/python
# 根据python版本安装,我的是python3.10版本,选择cp310
# 最好退出conda环境,选择系统环境的python版本,并在系统环境安装
pip install tensorrt-8.6.1-cp310-none-linux_x86_64.whl
🌔05
Appendix
5.1 fishros
安装ros/docker/clash,配置系统/ros/docker源等可以用它。
wget http://fishros.com/install -O fishros && . fishros
5.2 proxy
写在.bashrc中,之后可以使用proxy_on和proxy_off来选择开启或关闭代理。
# >>> proxy set >>>
proxy_on()
{
export hostip=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}')
export http_proxy="http://${hostip}:7890"
export https_proxy="http://${hostip}:7890"
export all_proxy="socks5://${hostip}:7890"
echo "代理已开启,当前代理 IP: ${hostip}"
}proxy_off()
{
unset http_proxy
unset https_proxy
unset all_proxy
echo "代理已关闭"
}
# <<< proxy set <<<