close
如何安裝 CUDA , cuDNN 和 OpenCV
1.下載 CUDA
版本 8.0
wget "http://developer.download.nvidia.com/devzone/devcenter/mobile/jetpack_l4t/013/linux-x64/cuda-repo-l4t-8-0-local_8.0.84-1_arm64.deb"
版本 9.0
wget "https://developer.download.nvidia.com/devzone/devcenter/mobile/jetpack_l4t/3.2.1/m8u2ki/JetPackL4T_321_b23/cuda-repo-l4t-9-0-local_9.0.252-1_arm64.deb"
版本 10.0
wget "https://developer.nvidia.com/assets/embedded/secure/tools/files/jetpack-sdks/jetpack-4.2/JETPACK_42_b158/cuda-repo-l4t-10-0-local-10.0.166_1.0-1_arm64.deb"
2. 安裝 CUDA
執行下面指令後再重新開機:
# Version 8.0 ./cuda-l4t.sh cuda-repo-l4t-8-0-local_8.0.84-1_arm64.deb 8.0 8-0 # Version 9.0 ./cuda-l4t.sh cuda-repo-l4t-9-0-local_9.0.252-1_arm64.deb 9.0 9-0
檔案 cuda-l4t.sh
#!/bin/bash # $1: cuda debian file name # $2: cuda_ver (example 6.0, 6.5) # $3: cuda_dash_ver (6-0, 6-5) if [ $# != 3 ] ; then echo "Incorrect arguments, use following command to install cuda" echo "$0 cuda_deb_file_name 6.5 6-5" exit 1 fi while sudo fuser /var/lib/dpkg/lock > /dev/null 2>&1; do echo "Waiting for other apt-get command to finish" sleep 3 done # 原始檔案 #sudo dpkg --force-all -i ~/cuda-l4t/$1 # 修改過 sudo dpkg --force-all -i $1 sleep 5 sudo apt-key add /var/cuda-repo-$3-local/*.pub sleep 2 sudo sed -i.bak 's/\(^deb.*main restricted\)\s*$/\1 universe multiverse/g' /etc/apt/sources.list sudo sed -i.bak 's/\(^deb.*main restricted universe\)\s*$/\1 multiverse/g' /etc/apt/sources.list sudo apt-get -y update sudo apt-get -y --allow-downgrades install cuda-toolkit-$3 libgomp1 libfreeimage-dev libopenmpi-dev openmpi-bin grep -q "export PATH=.*/usr/local/cuda-$2/bin" ~/.bashrc || echo "export PATH=/usr/local/cuda-"$2"/bin:$PATH">>~/.bashrc if dpkg --print-architecture | grep -q arm64; then lib_dir=lib64 else lib_dir=lib fi grep -q "export LD_LIBRARY_PATH=/usr/local/cuda-$2/$lib_dir" ~/.bashrc || echo "export LD_LIBRARY_PATH=/usr/local/cuda-"$2"/"$lib_dir":$LD_LIBRARY_PATH" >> ~/.bashrc export LD_LIBRARY_PATH=/usr/local/cuda-$2/$lib_dir:$LD_LIBRARY_PATH
3. 驗證 CUDA 是否安裝成功
nvcc --version
4. 下載 cuDNN
# Version 6.0
wget "http://developer.download.nvidia.com/devzone/devcenter/mobile/jetpack_l4t/013/linux-x64/libcudnn6_6.0.21-1+cuda8.0_arm64.deb" wget "http://developer.download.nvidia.com/devzone/devcenter/mobile/jetpack_l4t/013/linux-x64/libcudnn6-dev_6.0.21-1+cuda8.0_arm64.deb" wget "http://developer.download.nvidia.com/devzone/devcenter/mobile/jetpack_l4t/013/linux-x64/libcudnn6-doc_6.0.21-1+cuda8.0_arm64.deb"
# Version 7.1
wget "https://developer.download.nvidia.com/devzone/devcenter/mobile/jetpack_l4t/3.2.1/m8u2ki/JetPackL4T_321_b23/libcudnn7_7.1.5.14-1+cuda9.0_arm64.deb" wget "https://developer.download.nvidia.com/devzone/devcenter/mobile/jetpack_l4t/3.2.1/m8u2ki/JetPackL4T_321_b23/libcudnn7-dev_7.1.5.14-1+cuda9.0_arm64.deb" wget "https://developer.download.nvidia.com/devzone/devcenter/mobile/jetpack_l4t/3.2.1/m8u2ki/JetPackL4T_321_b23/libcudnn7-doc_7.1.5.14-1+cuda9.0_arm64.deb"
5. 安裝 cuDNN
# Version 6.0
sudo dpkg -i ./libcudnn6_6.0.21-1+cuda8.0_arm64.deb sudo dpkg -i ./libcudnn6-dev_6.0.21-1+cuda8.0_arm64.deb sudo dpkg -i ./libcudnn6-doc_6.0.21-1+cuda8.0_arm64.deb
# Version 7.1
sudo dpkg -i ./libcudnn7_7.1.5.14-1+cuda9.0_arm64.deb sudo dpkg -i ./libcudnn7-dev_7.1.5.14-1+cuda9.0_arm64.deb sudo dpkg -i ./libcudnn7-doc_7.1.5.14-1+cuda9.0_arm64.deb
6. 確認是否有安裝
確認這個檔案 /usr/include/cudnn.h 是否存在
再確認usr/lib/aarch64-linux-gnu/libcudnn* 相關檔案
7. 下載 Opencv
8. 安裝 opencv
9. 驗證 opencv的版本
pkg-config --modversion opencv
10. 下載和安裝Tensor-RT
# Version 3.0.4
參考網站
https://docs.opencv.org/3.2.0/d6/d15/tutorial_building_tegra_cuda.html
文章標籤
全站熱搜
留言列表