Ubuntu 18.04/16.04/14.04 + RTX 2070 + CUDA + cuDNN环境配置

1、英伟达显卡驱动

1.1、第一种安装方法:

对于新出Nvidia显卡,本人并不建议大家到官网手动下载安装NVIDIA的显卡驱动,有可能因为缺少显卡安装包的依赖条件导致最后没有办法安装成功。特别是我刚换上的RTX2070显卡,官方的显卡驱动总是一直安装不成功,这种情况使得我在Ubuntu18.04和Ubuntu18.10系统之间来回折腾了一天,我是依据NVIDIA官方文档在Disabling the Nouveau drivers的情况下也没有办法安装成功,可能是RTX 2070显卡版本比较新,Ubuntu识别不出正确显卡型号,所以要按照以下方式操作安装,否则会有意上不到的坑让你稳稳踩上。

1.1、添加Graphic Drivers PPA

$ sudo add-apt-repository ppa:graphics-drivers/ppa
$ sudo apt-get update

1.2、查询驱动型号,最好就安装recommended的驱动版本型号。

$ ubuntu-drivers devices

在这里插入图片描述
1.3、安装nvidia-driver-418

$ sudo apt-get install nvidia-418

1.4、安装成功之后,请重新启动电脑

$ sudo reboot

1.5、检查驱动是否安装成功

$ nvidia-smi

在这里插入图片描述
如果安装完之后,重启无法进入ubuntu系统,这种情况多见于笔记本,可以关机再重新启动,并执行这条命令software-properties-gtk再重启就能进入ubuntu系统。

1.2、第二种安装方法

卸载之前安装的显卡驱动,并重启
sudo apt-get remove --purge nvidia*
sudo reboot

先关闭x-server,否则无法安装英伟达显卡
sudo service lightdm stop
sudo nvidia.run --uninstall
sudo NVIDIA-Linux-x86_64-418.56.run --no-opengl-files
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
此处一定要选择yes
在这里插入图片描述
安装程序问你是否使用nvidia的xconfig文件,这里一定要选yes,否则在启动x-window时不会使用nvidia的驱动。

gcc、g++版本升级安装和多版本切换
https://blog.csdn.net/jiangjiang_jian/article/details/80694799
https://blog.csdn.net/zhuiqiuk/article/details/76099917
https://blog.csdn.net/betty13006159467/article/details/78394974

2、CUDA的安装和多个CUDA版本的切换

CUDA(Compute Unified Device Architecture)是一种用于GPU 通用计算的并行计算平台和编程模型。它以C语言为基础,并对C语言进行了扩展,能够在显卡芯片上执行程序。

官方安装文档https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html
CUDA下载https://developer.nvidia.com/cuda-toolkit-archive

查看cuda版本的方法
cat /usr/local/cuda/version.txt

建议不要使用以下方式安装,默认安装显卡驱动,会把原来的驱动版本覆盖导致显卡驱动工作不正常。

sudo dpkg -i cuda-repo-ubuntu1604-8-0-local-ga2_8.0.61-1_amd64.deb
sudo apt-get update
sudo apt-get install cuda

推荐Base Installer
sudo sh cuda_8.0.61_375.26_linux.run

Do you accept the previously read EULA? (accept/decline/quit):
accept

Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 375.26?
(y)es/(n)o/(q)uit:no

Install the CUDA 8.0 Toolkit?
(y)es/(n)o/(q)uit: yes

Enter Toolkit Location
[ default is /usr/local/cuda-8.0 ]:默认回车

Do you want to install a symbolic link at /usr/local/cuda?
(y)es/(n)o/(q)uit: yes

Install the CUDA 8.0 Samples?
(y)es/(n)o/(q)uit: yes

Enter CUDA Samples Location
[ default is /home/zhoujianwen ]:默认回车

Logfile is /tmp/cuda_install_3426.log

sudo vi ~/.bashrc

export CUDA_HOME=/usr/local/cuda
export PATH= P A T H : PATH: PATH:CUDA_HOME/bin
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64KaTeX parse error: Expected '}', got 'EOF' at end of input: …LIBRARY_PATH:+:{LD_LIBRARY_PATH}}

source ~/.bashrc

nvcc --version

cp /home/ U S E R / N V I D I A C U D A − 8. 0 S a m p l e s / / h o m e / USER/NVIDIA_CUDA-8.0_Samples/ /home/ USER/NVIDIACUDA8.0Samples//home/USER/NVIDIA_CUDA-8.0_Samples2

cd /home/$USER/NVIDIA_CUDA-8.0_Samples2

make -f Makefile

cd /home/$USER/NVIDIA_CUDA-8.0_Samples2/bin/x86_64/linux/release

./deviceQuery
在这里插入图片描述
至此cuda安装成功了


卸载CUDA Toolkit和显卡驱动

sudo apt-get --purge remove "*cublas*" "cuda*"
sudo apt-get --purge remove "*nvidia*"

参考
多版本 cuda 和 cudnn 切换
https://blog.csdn.net/u010925447/article/details/86617741

Ubuntu16.04下cuda9.0+cudnn7.0安装指南
http://www.twistedwg.com//2018/06/15/cuda9_cudnn7.html

ubuntu16.04安装多个CUDA、cuDNN版本并自由切换
https://blog.csdn.net/qq_30683995/article/details/82745246

在ubuntu上安装多个版本的CUDA,并且可以随时切换
https://blog.csdn.net/ksws0292756/article/details/80120561

[ubuntu 18.04 + RTX 2070] Anaconda3 - 5.2.0 + CUDA10.0 + cuDNN 7.4.1 + bazel 0.17 + tensorRT 5 + Tensorflow(GPU)
https://www.cnblogs.com/shiyublog/p/10011803.html#_label1

Ubuntu16.04安装Nvidia驱动cuda,cudnn和tensorflow-gpu
https://blog.csdn.net/u013082989/article/details/83382230

[专业亲测]Ubuntu16.04安装Nvidia显卡驱动(cuda)–解决你的所有困惑
https://blog.csdn.net/ghw15221836342/article/details/79571559

Ubuntu 16.04借助Conda安装Pytorch的GPU版本详细非常详细
https://blog.csdn.net/yimingsilence/article/details/79631567?utm_source=blogxgwz3

3、cuDNN的安装和多个cuDNN版本的切换

CUDA提供了一个深度神经网络的GPU加速库cuDNN(CUDA Deep Neural Network),完成了对卷积、池化、归一化和激活函数层等标准操作的快速实现。
cuDNN下载https://developer.nvidia.com/rdp/cudnn-archive
测试mnistCUDNN的依赖包,ldd mnistCUDNN

查看cudnn版本的方法
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2

更改动态文件链接
https://www.cnblogs.com/adong7639/p/7231383.html
https://blog.csdn.net/weixin_40695510/article/details/81564866

正确删除软链接方法
https://www.cnblogs.com/cartsp/p/6437046.html

官方下载通道
https://developer.nvidia.com/cuda-toolkit
https://developer.nvidia.com/deep-learning-software
https://developer.nvidia.com/cudnn

4、Ubuntu18.04 备份与恢复

由于Ubuntu不同版本的系统环境在备份操作上会略有不同,所以我建议直接还是使用ghost11.5版本来备份Ubuntu系统,它能正确备份ext3/etx2的系统分区,ext4并不支持。一旦Linux系统遇到不可逆或未知的错误就可以快速利用U盘引导恢复,这样能回滚到之前的系统环境。

5、双系统引导

单硬盘安装双系统和双硬盘安装双系统在分区引导上是有区域的。
双硬盘双系统的情况。如果你的Windwos10和Ubuntu18.04系统都是UEFI引导的,那么在开机的时候直接按F8就可以显示Windwos10和Ubuntu系统的启动项,就不用安装EasyBCD之类的引导编辑工具。
单硬盘双系统,那就建议使用EasyBCD之类的引导编辑工具。

6、Ubuntu多重引导

6.1 N硬盘N系统安装

一开始分别将Windows10和Ubuntu18.04安装到各自的硬盘当中,可以在开机的时候按F8键使用UEFI方式选择其中一个系统启动,但是在安装完Ubuntu14.04并重启之后无法进入Ubuntu14.04,出现这种情况通常是因为在安装第二个 Ubuntu14.04.6系统时没有将引导写入到/boot目录文件中。
Ubuntu14.04.6 根目录下的/boot文件夹里面空空如也。造成这种现象可能是该系统无法加载boot文件目录引导的相关资源文件。
在这里插入图片描述
Ubuntu18.04 根目录下的/boot文件夹里面是一些引导资源文件,
在这里插入图片描述
解决的办法是直接开机F8键使用UEFI方式启动进入Ubuntu18.04系统,Ctrl+Alt+T输入命令sudo update-grub
在这里插入图片描述
此时Ubuntu18.04系统的grub找到Ubuntu14.04.06系统,重新启动就能可以看到引导菜单的多个操作系统。在不修改的情况下,我这里默认第一个选项Ubuntu进入Ubuntu18.04系统,第三个选项是Ubuntu 14.04.6 LTS。
在这里插入图片描述
如果要修改它们之间的启动顺序,那么就要直接进入Ubuntu18.04 /boot/grub/grub.cfg修改而并非在Ubuntu14.04系统中修改,最后sudo update-grub

6.2 单硬盘N系统安装

7、 Ubuntu14.04 安装intel无线网卡驱动(含升级内核)

无线网关是9560,硬件太新了,没办法驱动
请参考https://blog.csdn.net/zhhp1001/article/details/80877040

新安装ubuntu系统因版本比较低是有可能无法识别比较新的硬件,特别是新出的显卡驱动,即使安装官方原生驱动也因为各种问题而无法驱动成功,只需更新ubuntu内核版本即可识别,然后再安装官方的驱动。

查看内核版本uname -sr

7.1 下载内核相关文件,主要是headers、headers-generic、image共3个文件。

下载链接https://kernel.ubuntu.com/~kernel-ppa/mainline/v4.14.30/
在这里插入图片描述

7.2 安装完成后重启,然后检查Ubuntu内核版本

$ sudo dpkg -i *.deb
$ sudo reboot
$ uname -sr

到这一步实际上内核还没有更新,具体执行步骤
sudo update-grub && reboot 是在ubuntu18.04系统下执行。

查看一下可以更新的内核版本

sudo dpkg --get-selections | grep linux

选择启用指定版本version的内核
https://warjiang.github.io/devcat/2016/11/22/ubuntu14-04%E4%B8%8B%E6%9B%B4%E6%8D%A2%E5%86%85%E6%A0%B8/

删除多余内核版本操作
https://blog.csdn.net/u010073981/article/details/78988853
https://www.2cto.com/kf/201708/669823.html

Linux升级内核的正确姿势
https://blog.csdn.net/wf19930209/article/details/81879777

ubantu apt update更新异常APT::Update::Post-Invoke-Success
https://www.jianshu.com/p/c2e5b752c68e

7.3 下载好的驱动复制到lib的firmware中

$ sudo cp -i iwlwifi-你选的那个驱动文件.ucode /lib/firmware

Intel® Wireless-AC 9560下载链接
https://www.intel.com/content/www/us/en/support/articles/000005511/network-and-i-o/wireless-networking.html

7.4 更新grub并重启

$ sudo update-grub
$ sudo reboot

others
CondaHTTPError: HTTP 000 CONNECTION FAILED for url
https://blog.csdn.net/weixin_40355324/article/details/81238427
https://www.jianshu.com/p/2a237ba0e4d1
https://blog.csdn.net/ling_xiobai/article/details/78659981
https://www.cnblogs.com/medsci/p/8041602.html
*https://blog.csdn.net/feilong_csdn/article/details/87902504

ubuntu使用shadowsocks
https://www.sundabao.com/ubuntu%E4%BD%BF%E7%94%A8shadowsocks/

双系统引导参考资料
https://linoxide.com/distros/install-ubuntu-18-04-dual-boot-windows-10/
https://blog.csdn.net/zouguo1211/article/details/81200628
https://wiki.ubuntu.com/Kernel/KernelBootParameters?_ga=2.11420532.1546133584.1552891541-1679853072.1546926858
https://help.ubuntu.com/community/Boot-Repair
https://www.jianshu.com/p/227f5e2ceed3
https://blog.csdn.net/u011507599/article/details/52537846

Ubuntu18.04备份与还原
https://bbs.qunyingkeji.com/1421
在这里插入图片描述


CUDA8 examples not finding libGLU , libGL , or libX11

WARNING - libGL.so not found, refer to CUDA Getting Started Guide for how to find and install them. <<<
WARNING - libGLU.so not found, refer to CUDA Getting Started Guide for how to find and install them. <<<
WARNING - libX11.so not found, refer to CUDA Getting Started Guide for how to find and install them. <<<

sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev libglfw3-dev libgles2-mesa-dev

使用GLPATH=/usr/lib make 代替 make 构建内容

https://stackoverflow.com/questions/42427061/cuda-8-examples-on-ubuntu-16-not-finding-libglu-libgl-or-libx11/42428296

CUDA缺少libGL.so libGLU.so和libX11.so
https://stackoverflow.com/questions/34617236/cuda-missing-libgl-so-libglu-so-and-libx11-so

https://devtalk.nvidia.com/default/topic/993862/cuda-setup-and-installation/cuda-8-0-missing-required-libraries-on-ubuntu-16-04/c

sudo ln -s 源文件 目标文件,其实就是目标文件指向源文件
lrwxrwxrwx 1 root root 28 3月 31 23:17 libGL.so -> /usr/lib/nvidia-418/libGL.so

ln的链接分软链接和硬链接两种:

1、软链接就是:“ln –s 源文件 目标文件”,只会在选定的位置上生成一个文件的镜像,不会占用磁盘空间,类似与windows的快捷方式。
2、硬链接ln源文件目标文件,没有参数-s, 会在选定的位置上生成一个和源文件大小相同的文件,无论是软链接还是硬链接,文件都保持同步变化。
在这里插入图片描述


安装google chrome和teamviewer
sudo apt-get -f install google-chrome-stable
sudo apt-get -f install teamviewer

解决Ubuntu 16.04睡眠唤醒后无网络连接问题
sudo systemctl restart network-manager

sudo service network-manager restart

解决Ubuntu无法获得锁 /var/lib/dpkg/lock - open (11: 资源暂时不可用)
无法锁定管理目录(/var/lib/dpkg/),是否有其他进程正占用它?
1。终端输入 ps aux | grep apt-get,找到含有apt-get的进程,直接sudo kill PID。
2。强制解锁,命令
sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock


安装torch-opencv
https://www.cnblogs.com/YiXiaoZhou/p/6849619.html

安装opencv3.2.0 cmake出现 CMakeFiles/Makefile2:1264: recipe for target 'modules/cudev/test/CMakeFiles/o
https://blog.csdn.net/qq_33202928/article/details/80079485

Ubuntu16.04下安装OpenCV3.2.0
https://www.cnblogs.com/arkenstone/p/6490017.html

CUDA GPUs
https://developer.nvidia.com/cuda-gpus

Ubuntu 16.04: How to install OpenCV
https://www.pyimagesearch.com/2016/10/24/ubuntu-16-04-how-to-install-opencv/

在Ubuntu上安装OpenCV 3.0和Python 2.7+
https://www.pyimagesearch.com/2015/06/22/install-opencv-3-0-and-python-2-7-on-ubuntu/

https://stackoverflow.com/questions/40322301/compile-opencv-3-on-ubuntu-16-04-linking-error-usr-lib-x86-64-linux-gnu-libsox

安装torch-opencv
https://www.cnblogs.com/YiXiaoZhou/p/6849619.html


https://caltong.com/158
https://www.cnblogs.com/shiyublog/p/10011803.html
https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html

ubuntu 16.04
https://blog.csdn.net/u013082989/article/details/83382230
https://blog.csdn.net/ghw15221836342/article/details/79571559
https://www.cnblogs.com/matthewli/p/6715553.html

写于2019-03-17 19:54

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值