Ubuntu系统---NVIDIA 驱动安装
<p style="text-align: center"><span style="font-size: 14pt"><strong>Ubuntu系统---NVIDIA 驱动安装</strong></span></p><p> 第一次安装“<strong>NVIDIA 驱动</strong>”,小小的激动,因为终于可以玩GPU了。预想一块GPU,盼望太久,差点放弃,感谢J姐让我捡个漏。但是,第一次新的试错过程,网上的教程太多了,踩了很多坑,这里必须记录一下。</p>
<p> 实践认识:同样的安装步骤、电脑配置,不一样的系统,可能出现的错误不一样,采用的解决方法一样,从坑里爬出来的方法确实不一样的。</p>
<p> 当前电脑有 win7(暂不好用) + win10 + Ubuntu18.04.1 +Ubuntu16.04.5。 对于Ubuntu14.04、 Ubuntu16.04、Ubuntu18.04,几个版本都比较熟悉, 在校用了两年Ubuntu14.04,后来用近一年Ubuntu16.04,Ubuntu18.04确实好用,至少装东西少的不费劲。这几天又练习装系统了, 原本win10 + Ubuntu18.04.1,为了统一,需要改换win7 + Ubuntu16.04 。</p>
<p> 本机环境:<strong>win10 64位专业版</strong> (i7、64G内存、250 SSD + 4T HDD) + <strong>Ubuntu 16.04.5</strong> + <strong>GeForce RTx2080 TI 11G</strong></p>
<p> 说明:安装完系统之后,如果没有安装显卡驱动,字体看起来会很怪异,大大的,这是一方面的不便;最主要的是研究深度学习,需要安装NVIDIA 驱动让2080 TI发挥它的价值,所以必须安装NVIDIA 驱动。</p>
<p><span style="font-size: 14pt"><strong>一、安装NVIDIA 驱动教程 选择</strong></span></p>
<p> 网上资源,安装NVIDIA 驱动教程太多了,总结为三种:</p>
<p>(1)<strong>软件和更新</strong> 中修改。在设置->软件和更新->附加驱动(倒数第二个选项)里面选择安装(可能显卡驱动版本比较老)。</p>
<p><img src="https://img2018.cnblogs.com/blog/843408/201907/843408-20190725134623069-1309231860.png"></p>
<p> </p>
<p>(2)tty模式中用ppa源安装。</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)">例如,当我们需要安装410的驱动时:
进入tty 命令行登录模式(Ctrl</span>+Alt+<span style="color: rgba(0, 0, 0, 1)">F1 或者 <span style="color: rgba(0, 0, 0, 1)">Ctrl+Alt+<span style="color: rgba(0, 0, 0, 1)">F2</span></span>),执行下列语句:
sudo apt</span>-<span style="color: rgba(0, 0, 255, 1)">get</span> purge nvidia-*<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">删除可能存在的已有驱动</span>
sudo add-apt-repository ppa:graphics-drivers/<span style="color: rgba(0, 0, 0, 1)">ppa
sudo apt</span>-<span style="color: rgba(0, 0, 255, 1)">get</span><span style="color: rgba(0, 0, 0, 1)"> update
sudo apt</span>-<span style="color: rgba(0, 0, 255, 1)">get</span> install nvidia-<span style="color: rgba(128, 0, 128, 1)">410</span><span style="color: rgba(0, 0, 0, 1)">
sudo reboot </span><span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">重启12345</span>
<span style="color: rgba(0, 0, 0, 1)">
测试nvidia 驱动是否成功安装,使用以下命令:
nvidia</span>-<span style="color: rgba(0, 0, 0, 1)">smi
nvidia</span>-settings</pre>
</div>
<p> 也看到有网友,出现了:sudo apt-get install nvidia-*安装方式造成登录界面循环。我是踩坑之后,才看到.....</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)">#或者<br>#查看显卡设备和显卡驱动
ubuntu</span>-<span style="color: rgba(0, 0, 0, 1)">drivers devices
#自动安装合适显卡驱动
sudo ubuntu</span>-drivers autoinstall</pre>
</div>
<p> </p>
<p> </p>
<p>(3)NVIDIA 驱动官网中下载相应版本的.run,手动安装。</p>
<p> NVIDIA 驱动官网 https://www.geforce.cn/drivers (https://www.nvidia.com/Download/index.aspx?lang=en-us)</p>
<p><img src="https://img2018.cnblogs.com/blog/843408/201907/843408-20190725134920242-8370176.png"></p>
<p> </p>
<p><span style="font-size: 14pt"><strong>二、安装NVIDIA 驱动<br></strong></span></p>
<p><span style="font-size: 14px"> 在《一、安装NVIDIA 驱动教程选择》中尝试(1)和(2)都不好用,应该是版本安装的不清确,也就是版本不对,所以重启电脑之后,导致结果有:</span></p>
<p><span style="font-size: 14px">(2.1)进入ubuntu系统之后,黑屏,只有一个光标一直闪烁,进不去系统。</span></p>
<p><span style="font-size: 14px">(2.2)<span style="font-size: 14px">进入ubuntu系统之后</span>,登录与否,一直停留在登录页面,进不去桌面。</span></p>
<p><span style="font-size: 14px"> 进入tty模式下,会循环提示:pkcs #7 signature not signed with a trusted key </span></p>
<p><span style="font-size: 14px">因<span style="font-size: 14px">(1)和(2)不好用</span>,最后选择<span style="font-size: 14px">《一、安装NVIDIA 驱动教程选择》中(3)手动下载.run文件,然后进行安装。在Ubuntu18.04中一把好使,在Ubuntu14.04中出现了一点小插曲,不过也很快解决了。</span></span></p>
<p> </p>
<p><span style="font-size: 14px"><span style="font-size: 14px">按照(3)这种方法,需要注意:</span></span></p>
<p><span style="font-size: 14px"><span style="font-size: 14px"><strong><span style="font-size: 14px"><span style="font-size: 14px">(3.0)<span style="color: rgba(0, 0, 0, 1)">下载适合的NVIDIA驱动。</span></span></span></strong></span></span></p>
<p><span style="font-size: 14px"><span style="font-size: 14px"><strong><span style="font-size: 14px"><span style="font-size: 14px"><span style="color: rgba(0, 0, 0, 1)"> </span></span></span></strong><span style="font-size: 14px"><span style="font-size: 14px"><span style="color: rgba(0, 0, 0, 1)">记住放的位置,这里是/home/setup/下。</span></span></span></span></span></p>
<p><strong><span style="font-size: 14px"><span style="font-size: 14px">(3.1)<span style="color: rgba(0, 0, 0, 1)">卸载所有原驱动</span></span></span></strong></p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)">#<span style="font-size: 14px"><span style="font-size: 14px">如之前安装过</span></span>,卸载所有原驱动
sudo apt</span>-<span style="color: rgba(0, 0, 255, 1)">get</span> purge nvidia*</pre>
</div>
<p><strong><span style="font-size: 14px"><span style="font-size: 14px">(3.2)禁用系统默认显卡驱动nouveau</span></span></strong></p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)">方法一:<br>
打开系统黑名单:
sudo gedit </span>/etc/modprobe.d/<span style="color: rgba(0, 0, 0, 1)">blacklist.conf
文件末尾填入:
#</span><span style="color: rgba(0, 0, 255, 1)">for</span><span style="color: rgba(0, 0, 0, 1)"> nvidia display device install
blacklist vga16fb
blacklist nouveau
blacklist rivafb
blacklist rivatv
blacklist nvidiafb
保存,然后更新initramfs:
sudo update</span>-initramfs -u</pre>
<pre><span style="color: rgba(0, 0, 0, 1)"><span style="color: rgba(255, 0, 0, 1)">重启电脑后输入:
lsmod | grep nouveau<br>没有任何输出说明禁用成功。<br><br>一定要重启电脑。。。。。。。。。。。。<br>本文选择的是这种方法~~<br></span></span></pre>
</div>
<p> </p>
<div class="cnblogs_code">
<pre></pre>
<pre><span style="color: rgba(0, 0, 0, 1)">方法二:<br><br>安装NVIDIA需要把系统自带的驱动禁用,打开文件:
sudo gedit </span>/etc/modprobe.d/<span style="color: rgba(0, 0, 0, 1)">blacklist.conf<br>
在文本最后添加以下内容:
blacklist nouveau
option nouveau modeset</span>=<span style="color: rgba(128, 0, 128, 1)">0</span><span style="color: rgba(0, 0, 0, 1)">
命令窗口会提示warn,无视之。
保存退出,执行以下命令生效:
sudo update</span>-initramfs -<span style="color: rgba(0, 0, 0, 1)">u<br>
<span style="color: rgba(255, 0, 0, 1)">重启电脑后输入:</span>
lsmod </span>| grep nouveau<br>没有任何输出说明禁用成功。</pre>
</div>
<p><strong><span style="font-size: 14px"><span style="font-size: 14px"><img src="https://img2018.cnblogs.com/blog/843408/201907/843408-20190725143754033-1605171611.png"></span></span></strong></p>
<p> </p>
<p><strong><span style="font-size: 14px"><span style="font-size: 14px">(3.3)正式安装<span style="color: rgba(0, 0, 0, 1)">NVIDIA</span>驱动</span></span></strong></p>
<p> </p>
<div class="cnblogs_code">
<pre><strong>在ubuntu18.04下,一把好使:<br></strong><br>cd setup <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">进入NVIDIA的.run文件放的目录下</span><span style="color: rgba(0, 128, 0, 1)"> <br><br><span style="color: rgba(0, 0, 0, 1)">sudo chmod +x NVIDIA-Linux-x86_64-410.93.run</span><br><span style="color: rgba(0, 0, 0, 1)">sudo ./NVIDIA-Linux-x86_64-410.93.run</span><br><span style="color: rgba(0, 0, 0, 1)"><br>更新内核,重启电脑</span><br><span style="color: rgba(0, 0, 0, 1)">sudo update-initramfs -u</span><br><span style="color: rgba(0, 0, 0, 1)">sudo reboot now</span><br><span style="color: rgba(0, 0, 0, 1)"><br>运行命令:nvidia-smi,如果有输出则说明安装成功</span><br></span></pre>
</div>
<p> <img src="https://img2018.cnblogs.com/blog/843408/201907/843408-20190725145010223-983855038.png"></p>
<p> </p>
<p> <strong>在ubuntu16.04下,一把未好使,出现了点小插曲:</strong></p>
<p> <img src="https://img2018.cnblogs.com/blog/843408/201907/843408-20190725145516632-1099461147.png"></p>
<div class="cnblogs_code">
<pre></pre>
<p> <strong>在ubuntu16.04下,一把未好使:</strong></p>
<pre><span style="color: rgba(0, 0, 0, 1)"><br>先到NVIDIA 官网上下载驱动文件(.run 格式)
</span>按住CTRL+ALT+<span style="color: rgba(0, 0, 0, 1)">F2 进入命令行界面,输入用户名和密码登录命令行界面。<br><br>Login : 安装ubuntu的用户名<br>紧接着输入密码
</span><span style="color: rgba(0, 0, 0, 1)">sudo service lightdm stop 或者 sudo stop lightdm//<code class="language-bash hljs"><span class="hljs-comment"># 这会关闭图形界面</span></code>,禁用X服务
</span>sudo init <span style="color: rgba(128, 0, 128, 1)">3</span>
<br>cd setup //进入NVIDIA的.run文件目录下<br>
sudo ./NVIDIA-Linux-x86_64-<span style="color: rgba(128, 0, 128, 1)">177.67</span>-pkg2.run <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">当前目录下执行NVIDIA驱动程序。</span></pre>
<pre><span style="color: rgba(0, 0, 0, 1)">sudo service lightdm start<span style="color: rgba(0, 0, 0, 1)">//开启桌面“<span style="color: rgba(0, 0, 0, 1)"><span style="color: rgba(0, 0, 0, 1)">注意:在命令行输入:<code>sudo service lightdm start</code> ,然后按<code>Ctrl-Alt+F7</code>即可恢复到图形界面。</span></span>”</span></span></pre>
<pre>sudo reboot //<span style="color: rgba(128, 0, 128, 1)">按照提示安装完成,简单方法重启就好了 </span></pre>
</div>
<p><img src="https://img2018.cnblogs.com/blog/843408/201907/843408-20190725155119987-1838208814.png"></p>
<p> <img src="https://img2018.cnblogs.com/blog/843408/201907/843408-20190725145817220-2134281621.png"></p>
<p><img src="https://img2018.cnblogs.com/blog/843408/201907/843408-20190725145852577-1230696602.png"></p>
<p> </p>
<p> <img src="https://img2018.cnblogs.com/blog/843408/201907/843408-20190725145912051-1095662384.png"></p>
<p><img src="https://img2018.cnblogs.com/blog/843408/201907/843408-20190725145939458-1953749856.png"></p>
<p><img src="https://img2018.cnblogs.com/blog/843408/201907/843408-20190725145956300-1509018176.png"></p>
<p> </p>
<p> </p>
<p> </p>
<p><span style="font-size: 14px"> 提示安装基本上都是accept,yes,当提示你nvidia-xconfig时,就视自己的电脑情况而定,如果电脑是双显卡(双独显、集显和独显)就选择不安装,如果只有一个显卡就选择安装。</span></p>
<p><span style="font-size: 14px">安装完毕后重启验证是否安装成功:</span><span style="font-size: 14px"><code class="language-html hljs xml">nvidia-smi</code></span></p>
<p><img src="https://img2018.cnblogs.com/blog/843408/201907/843408-20190725153147298-1018682990.png"></p>
<p> </p>
<p> 三<span style="font-size: 14pt"><strong>、安装NVIDIA 驱动完毕</strong></span></p>
<p><span style="font-size: 14px"> 安装完驱动,再次进入系统,就会发现字体正常了,也不会有刚安装完驱动使用的卡顿现象了。接下来,继续CUDA、CUDNN的安装配置之旅。</span></p>
<p> CUDA的版本选择依据,https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html</p>
<p><img src="https://img2018.cnblogs.com/i-beta/843408/202002/843408-20200219162225755-178912981.png"></p>
<p> </p>
</div>
<div id="MySignature" role="contentinfo">
【. . . . . .本博客仅作个人生活、工作、学习等的日常记录。说明: (1)内容有参考其他博主、网页等,有因“懒”直接粘贴来,会备注出处。若遇雷同,或忘备注,并无故意抄袭之意,请诸“原主”谅解,很感谢您的辛勤"笔记"可供本人参考学习。(2)如遇同行,有参考学习者,因个人学识有限,不保证所写内容完全正确。您对本博文有任何的意见或建议,欢迎留言,感谢指正。 (3)若您认为本主的全博客还不错,可以点击关注,便于互相学习。 (4)感谢您的阅读,希望对您有一定的帮助。欢迎转载或分享,但请注明出处,谢谢。. . . . . .】
【作者: Carole0904; 出处: https://www.cnblogs.com/carle-09/】<br><br>
来源:https://www.cnblogs.com/carle-09/p/11244396.html
頁:
[1]