之前已經嘗試過幾次配置深度學習的GPU環境(即CUDA和cudnn),但是在安裝顯卡驅動總是出現問題,無法查找出來原因。因此,這次在配置CUDA和cudnn之前,選擇可重裝Ubuntu系統。
1. 重裝Ubuntu16.04同時安裝Nvidia驅動,以解決安裝后無法啟動的問題
重裝ubuntu系統與首次安裝Ubuntu系統步驟相似,選擇U盤安裝。但需要說明的是,按照正常的方法安裝后,nvidia的顯卡與nouveau顯卡沖突導致系統安裝后無法正常啟動(freeze)。參考教程之后,總的安裝步驟簡單歸納為:
- 首先到官網下載iso文件並使用ultraiso制作系統盤;
- 開機時按F12進入BIOS界面,選擇對應的U盤啟動;
- Highlight the option 'Try Ubuntu without installing' and press the E key.
Addnouveau.modeset=0
to the end of the linux line - press F10 to boot. - Install the Ubuntu operating system,我選擇格式化后重新安裝,注意分區;
- 安裝好后重啟(reboot)電腦;
- Highlight the Ubuntu entry in the GRUB boot menu and press the E key.
Addnouveau.modeset=0
to the end of the linux line - press F10 to boot. - 啟動后不要直接進入ubuntu,在登錄界面按 Ctrl+Alt+F1 進入shell界面,使用用戶名和密碼登錄;
- 執行以下代碼安裝nvidia顯卡驅動
sudo add-apt-repository ppa:graphics-drivers/ppa sudo apt-get update sudo apt-get install nvidia-*** # e.g nvidia-384 sudo reboot
- 重新啟動后顯卡驅動已經安裝完成。
2. 安裝CUDA和cudnn
參考如下文章:
Install CUDA 9.0 and cuDNN 7.0 for TensorFlow/PyTorch (GPU) on Ubuntu 16.04