Ubuntu 16.04配置CUDA 9.0+cudnn 7.0以及解决Nvidia显卡导致黑屏问题

之前已经尝试过几次配置深度学习的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.
    Add nouveau.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.
    Add nouveau.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

 
原文地址:https://www.cnblogs.com/sparkzxw/p/9715966.html