安裝 tensorflow 及 cuda cudnn 心得
安裝前置作業
檢查以下事項
- gpu 型號
- 欲使用的 tensorflow 版本
確認 GPU 支援的 CUDA 版本
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
以 Geforce RTX 3060 為例,其 CUDA 至少要 8.6 以上確認欲使用的 tf 版本後,到 tf 官方網站查看該安裝哪個版本的 python, CUDA, cuDNN
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
版本必須正確,否則 tf 有高機率無法執行安裝 CUDA 及 cuDNN
在 CUDA 找到對應的版本進行安裝
安裝期間,建議選擇自訂安裝,只安裝 CUDA 就好,完成後 CUDA 環境變數會加入你的電腦中
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
接著,下載 cuDNN 一樣要找到對應版本安裝
解壓縮後會看到 bin, include, lib
等資料夾,直接將其複製到 CUDA 安裝的目錄即可
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
將上面三個資料夾複製到 cuda 安裝的目錄
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
使用 conda 管理版本
安裝 anaconda 後,使用以下指令創建虛擬環境
conda create -n your_env_name python=x.x
切換到剛創建的環境
conda activate your_env_name
安裝對應的 tf
pip install tensorflow-gpu==x.x.x
走到這部就算完成了,若是不放心,可以用以下指令測試
python import tensorflow