# Yolo 安裝(通用 v3、v4) <!-- <font color="#f00">訂閱</font> 以上為改變字體顏色的語法--> 前言:光安裝環境就花了兩個晚上,所以每個步驟都要小心不要遺漏。最後會有些我實際遇到的一些安裝問題與解決辦法。 參考書籍:Python機器學習超進化 著:文淵閣工作室 ## CUDA安裝 版本確認:https://medium.com/ching-i/win10-%E5%AE%89%E8%A3%9D-cuda-cudnn-%E6%95%99%E5%AD%B8-c617b3b76deb 官網:https://developer.nvidia.com/cuda-11-7-0-download-archive?target_os=Windows&target_arch=x86_64&target_version=10&target_type=exe_local ![](https://i.imgur.com/i4pKHzH.png =80%x) 下載完後開啟下載檔案(.exe)全部預設安裝就可。 --- ## cuDNN安裝 作業系統不要選錯win10就按10。 官網:https://developer.nvidia.com/rdp/cudnn-download 下載最新版本(這邊是下載11.7) ![](https://i.imgur.com/E6bqVD3.png =80%x) ![](https://i.imgur.com/EcPwF5C.png =80%x) 解壓縮後將檔案改名為'cuda'。 在C槽建立一資料夾名稱為:cudnn-11.7-windows10-64-v8.5.0.96(依照你下載的版本不同下去調整),將剛剛的'cuda'資料夾移至裡面。 ![](https://i.imgur.com/bGs1XtL.png =80%x) - 把 C:\<username>\cuda\bin\ <font color="#f00">cudnn64_8.dll</font> 複製到 C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7.0\bin - 把 C:\<username>\cuda\include\ <font color="#f00">cudnn.h</font> 複製到 C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\include - 把 C:\<username>\cuda\lib\x64\ <font color="#f00">cudnn.lib</font> 複製到 C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\lib\x64 ![](https://i.imgur.com/UnYhwYg.png =80%x) 按Windows鍵輸入'編輯系統環境變數' -> '環境變數' 編輯 Path ![](https://i.imgur.com/7ogqwrq.png =40%x) 新增 剛剛在C槽鍵的資料夾名稱\cuda\bin ![](https://i.imgur.com/NCEsko6.png =40%x) --- ## CMake安裝 yolo系統需要CMake的編譯才能使用。 下載網址:https://cmake.org/download/ 下載最新版 ![](https://i.imgur.com/veAWCAX.png =80%x) 在D或其他磁碟裡新增一資料夾'dartnetYolo' ![](https://i.imgur.com/KRTCEyI.png =40%x) 將下載完並解壓縮完的檔案丟入資料夾'dartnetYolo'中 ![](https://i.imgur.com/8LNX8or.png =40%x) --- ## OpenCV安裝 下載網址:https://opencv.org/releases 下載最新版本 ![](https://i.imgur.com/iDnUddP.png =80%x) 解壓縮後將檔案移至資料夾'dartnetYolo'中 --- ## Visual Studio安裝 下載網址:https://visualstudio.microsoft.com/zh-hant/vs/ 勾選.NET桌面開發、使用C++的桌面開發、通用Windows平台開發 ![](https://i.imgur.com/dxugmQl.png =80%x) --- ## darknet架構 下載網址:http://github.com/AlexeyAB/darknet.git download整個資料夾並改名為'darknet'。 放至資料夾'dartnetYolo'中 ![](https://i.imgur.com/wxFFHo8.png =40%x) --- ## msvcr100.dll 下載網址:http://wikidll.com/microsoft/msvcr100-dll 下載64位元最新版本。 下載完解壓縮後將檔案移至資料夾'darknet'中 ![](https://i.imgur.com/c5vUxOe.png =40%x) --- ## yolo權重檔 下載yolov3網址:http://pjreddie.com/media/files/yolov3.weights yolov4網址:http://github.com/AlexeyAB/darknet/release/download/darknet_yolo_v3_optimal/yolov4.weights 解壓縮後都移至資料夾'darknet'中 ![](https://i.imgur.com/O1rXZwj.png =40%x) --- ## 建立OPENCV_DIR環境變數 按Windows鍵輸入'編輯系統環境變數' -> '環境變數' -> 系統變數按新增 變數值填opencv資料夾內的build位置 ![](https://i.imgur.com/j98RqrN.png =40%x) --- ## 編譯Yolo 開啟cmake資料夾bin裡面有執行檔,開啟後填入darknet位置 ![](https://i.imgur.com/XaiVl9T.png =40%x) 選取visual studio版本 位元數選x64 ![](https://i.imgur.com/H83pL93.png =40%x) 之後按finish,之後按Configure,執行結束後按Generate,執行結束後按Open project自動開啟VS VS屬性設定:https://ithelp.ithome.com.tw/articles/10231950 將上方點選'Release'及'x64' ![](https://i.imgur.com/2655hD8.png =80%x) 將ALL_BUILD建置 ![](https://i.imgur.com/ahEs60W.png =40%x) 將INSTALL建置 ![](https://i.imgur.com/TahBVSw.png =40%x) 按Windows鍵輸入'編輯系統環境變數' -> '環境變數' 編輯Path -> 新增 這三個新增至Path裡 ![](https://i.imgur.com/zpgQC26.png =80%x) --- ## 側試 開啟電腦命令 提示字元 開啟dartnetYolo\darknet資料夾輸入 darknet.exe detect cfg\yolov3.cfg yolov3.weights data\dog.jpg ![](https://i.imgur.com/b9tIUte.png =80%x) 成功! --- ## 錯誤排解 錯誤一,'cublasLt64_10.dll'檔案遺失 下載網址:https://www.dll4free.com/cublaslt64_10.dll.html ![](https://i.imgur.com/tQel0bK.png) 錯誤二,'cublase64_10.dll'檔案遺失 下載網址:https://www.dll-files.com/download/c60b6c0edebdb1d297caee408ef1764c/cublas64_10.dll.html?c=azBKYzNmSFJGMmZrUTU5MG13MDJtUT09 ![](https://i.imgur.com/1h5nVpv.png) 分別下載後,開啟C槽資料夾'cudnn-11.7-windows10-64-v8.5.0.96'(依照你下載的版本不同下去調整),將兩個.dll丟至'cuda/bin'資料夾內。 ![](https://i.imgur.com/Yp94NGb.png =80%x) 補齊缺失檔案後就可成功執行。