ubuntu系统(八):ubuntu18.04双系统安装+ros安装+各种软件安装+深度学习环境配置全家桶

0 说明

1.安装ubuntu18.04系统

1.1 ubuntu18.04镜像地址(可以用迅雷等下载):

1.2 下载Rufus:

1.3 制作镜像:

1.4 磁盘分区

1.5 关闭win11快速启动:

1.6 设置BIOS:

1.7 安装ubuntu18.04

2 安装ros-melodic

2.1  源问题:Connection failed [IP: 91.189.91.39 80]

2.2 包冲突问题 E: Unable to correct problems, you have held broken packages

2.3 rosdep :command not found

2.4 sudo rosdep init 

3 安装sogou输入法

4 Anaconda安装

5 好用的截图工具flameshot

6 深度学习环境配置--显卡驱动、cuda11.3、cudnn

6.1 命令行安装显卡驱动--失败

6.2 .run安装显卡驱动--失败--成功

6.2.1 下载驱动文件

6.2.2 禁用nouveau驱动

6.2.3 更新并重启

6.2.4 验证nouveau是否被禁用

6.2.5 获取Kernel source

6.2.6 关闭图形界面/停止显示桌面

6.2.7 安装驱动

6.3 安装cuda11.3

6.3.1 下载

  6.3.2 安装及选项

 6.3.3 测试

6.3.4 配置cuda到~/.bashrc(可选)

6.4 配置cudnn

6.4.1 下载

 6.4.2 配置

6.5 重装cuda+cudnn

6.5.1 卸载cuda-11.3

6.5.2 安装cuda-11.0

6.5.3 配置cudnn

7 实时内存、网速检测

7.1 配置源

7.2 启动system monitor

7.3 配置preference

8 压缩工具

8.1 rar

9 vscode

参考链接:


0 说明

        拯救者刃7000K主机 i9-11900F RTX3070

        主机的bios和笔记本的拯救者不同。

        有问题请留言

1.安装ubuntu18.04系统

         说明:win11+ubuntu18.04

1.1 ubuntu18.04镜像地址(可以用迅雷等下载):

        Alternative downloads | Ubuntu

        得到文件:ubuntu-18.04.6-desktop-amd64.iso

1.2 下载Rufus:

        Rufus下载地址:Index of /downloads

        https://github.com/pbatard/rufus/releases

        得到文件:rufus-3.17.exe(版本不固定)

1.3 制作镜像:

        查看win11的BIOS模式:

        键盘按win+r,输入msinfo32,可以看出本机为:UEFI

        双击打开rufus软件,进行如下选择:(u盘会被格式化,注意备份)

        

         准备就绪后弹出u盘,准备插到新电脑上。

1.4 磁盘分区

        win11的:搜索--磁盘管理,给win11留100G

1.5 关闭win11快速启动:

        搜索--控制面板--硬件和声音--更改电源按钮功能--更改当前不可用设置--(取消勾选)启用快速启动--保存修改。

1.6 设置BIOS:

        插入准备好的u盘;

        重启,按下F1,进入界面:

        选择More Settings

        secure boot从disabled改为enabled

         First Boot Device由Boot Order改为USB HDD。

        修改这两处后,按下F10,保存并退出。

1.7 安装ubuntu18.04

        上面保存并退出后会进入安装界面

         选择第一个Try Ubuntu without installing或第二个Install ubuntu均可;选择第一个之后会进入ubuntu界面,在桌面上就有一个指向“install ubuntu”的快捷方式,同样可以进行安装。

        这里选择第二个 install ubuntu,接下来是安装步骤

        选择英语(也可以选择chinese),安装完成后也可以调整系统语言 

         选择正常安装:Normal installation和Download updates while installing Ubuntu

        选择something else,和win11所在磁盘分开。 

        下面是进行磁盘分区,考虑到/boot和/swap是必须的分区,这里将共分为三个分区/boot、/swap、/。

        这里/home是存储用户个人文件的,一般意义上的“/”分区是存放计算机文件的,这里没有进行区分,具有较大的灵活性。能够让避免一开始给/home分区分的空间太小后来不够用且“/”分区有较大空闲----导致的空间利用率不高问题。

        选中win11系统下划分的空闲磁盘分区:

        点击左下角的“+”号,创建/boot分区。选Logical+Beginning of this space+/boot。

        有的博客说的100MB够用,这里主要存放ubuntu系统的引导文件,有时候不小心点到的ubuntu更新,就会增加一些内核在这个位置,到时如果/boot分区满了,可以删除不必要的文件。我这里设置了500MB,一般200-300MB应该够用。

        点击"+"创建/swap即交换空间分区,一般设为内存的2倍(让内存有时间休息下来,类似一半干活一般休息的意思)。我的内存为16GB,这里分区设为32GB=32768MB。选 Logical+Beginning of this space+swap area。

        点击"+"创建“/”,将剩下所有空间都给“/”。选Primary+Beginning of this area+/

         选择ubuntu安装引导分区即前面分的/boot分区,在下图的最后一行。弹出窗口后选择continue

         选择地区,这里选了上海,其他地方应该也行

         设置用户名、主机名和密码。注意用户名/主机名可以不一样,因为安装完系统后不容易修改,尽量这里设置一个比较合适的名称;密码尽量不要太长,因为进入系统后有很多需要输入密码的地方,太长容易耽误时间。 

        接下来就是等待安装了:

 

         安装完成后会弹出这个界面,不要重启,“×”掉,然后选择关机;关机后将u盘拔掉,再开机。 

         开机界面如下,说明安装成功了

 

2 安装ros-melodic

        安装主要参考:ubuntu18.04安装ROS Melodic(最详细配置)_抚琴弹出情凋零的博客-CSDN博客_ubuntu18.04安装ros

        下面是我安装过程遇到的问题:

2.1  源问题:Connection failed [IP: 91.189.91.39 80]

sudo apt-get install ros-melodic-desktop-full
Need to get 25.7 MB/559 MB of archives.
After this operation, 2,403 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Ign:1 http://cn.archive.ubuntu.com/ubuntu bionic/universe amd64 fltk1.3-doc all 1.3.4-6
Err:2 http://cn.archive.ubuntu.com/ubuntu bionic/universe amd64 libfltk1.3 amd64 1.3.4-6
  Connection failed [IP: 91.189.91.39 80]
Err:3 http://cn.archive.ubuntu.com/ubuntu bionic/universe amd64 libfltk-forms1.3 amd64 1.3.4-6
  Connection failed [IP: 2001:67c:1562::15 80]
Err:4 http://cn.archive.ubuntu.com/ubuntu bionic/universe amd64 libfltk-images1.3 amd64 1.3.4-6
  Connection failed [IP: 91.189.91.39 80]
Err:5 http://cn.archive.ubuntu.com/ubuntu bionic/universe amd64 fluid amd64 1.3.4-6
  Connection failed [IP: 2001:67c:1562::15 80]
Err:6 http://cn.archive.ubuntu.com/ubuntu bionic/universe amd64 freeglut3 amd64 2.8.1-3
  Connection failed [IP: 91.189.91.39 80]
Err:7 http://cn.archive.ubuntu.com/ubuntu bionic/universe amd64 freeglut3-dev amd64 2.8.1-3
  Connection failed [IP: 2001:67c:1562::15 80]
Err:8 http://cn.archive.ubuntu.com/ubuntu bionic/main amd64 libboost-program-options1.65.1 amd64 1.65.1+dfsg-0ubuntu5
  Connection failed [IP: 91.189.91.39 80]
Err:9 http://cn.archive.ubuntu.com/ubuntu bionic/universe amd64 libfreexl1 amd64 1.0.5-1
  Connection failed [IP: 2001:67c:1562::15 80]
Err:10 http://cn.archive.ubuntu.com/ubuntu bionic/universe amd64 libfyba0 amd64 4.1.1-3
  Connection failed [IP: 91.189.91.39 80]
Err:11 http://cn.archive.ubuntu.com/ubuntu bionic/universe amd64 libflite1 amd64 2.1-release-1
  Connection failed [IP: 2001:67c:1562::15 80]
Err:12 http://cn.archive.ubuntu.com/ubuntu bionic/universe amd64 librubberband2 amd64 1.8.1-7ubuntu2
  Connection failed [IP: 91.189.91.39 80]
Err:13 http://cn.archive.ubuntu.com/ubuntu bionic/universe amd64 libflann1.9 amd64 1.9.1+dfsg-2
  Connection failed [IP: 2001:67c:1562::15 80]
Err:14 http://cn.archive.ubuntu.com/ubuntu bionic/universe amd64 libflann-dev amd64 1.9.1+dfsg-2
  Connection failed [IP: 91.189.91.39 80]
Err:15 http://cn.archive.ubuntu.com/ubuntu bionic/universe amd64 libfltk-cairo1.3 amd64 1.3.4-6
  Connection failed [IP: 2001:67c:1562::15 80]
Err:16 http://cn.archive.ubuntu.com/ubuntu bionic/universe amd64 libfltk-gl1.3 amd64 1.3.4-6
  Connection failed [IP: 91.189.91.39 80]
Err:17 http://cn.archive.ubuntu.com/ubuntu bionic/universe amd64 libfltk1.3-dev amd64 1.3.4-6
  Connection failed [IP: 2001:67c:1562::15 80]
Err:18 http://cn.archive.ubuntu.com/ubuntu bionic/universe amd64 libfyba-dev amd64 4.1.1-3
  Connection failed [IP: 91.189.91.39 80]
Ign:19 http://cn.archive.ubuntu.com/ubuntu bionic/universe amd64 ttf-dejavu-core all 2.37-1
Err:20 http://cn.archive.ubuntu.com/ubuntu bionic/universe amd64 libfreexl-dev amd64 1.0.5-1
  Connection failed [IP: 91.189.91.39 80]
Err:1 http://cn.archive.ubuntu.com/ubuntu bionic/universe amd64 fltk1.3-doc all 1.3.4-6
  Connection failed [IP: 2001:67c:1562::15 80]
Err:19 http://cn.archive.ubuntu.com/ubuntu bionic/universe amd64 ttf-dejavu-core all 2.37-1
  Connection failed [IP: 2001:67c:1562::15 80]
E: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/pool/universe/f/fltk1.3/fltk1.3-doc_1.3.4-6_all.deb  Connection failed [IP: 2001:67c:1562::15 80]
E: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/pool/universe/f/fltk1.3/libfltk1.3_1.3.4-6_amd64.deb  Connection failed [IP: 91.189.91.39 80]
E: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/pool/universe/f/fltk1.3/libfltk-forms1.3_1.3.4-6_amd64.deb  Connection failed [IP: 2001:67c:1562::15 80]
E: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/pool/universe/f/fltk1.3/libfltk-images1.3_1.3.4-6_amd64.deb  Connection failed [IP: 91.189.91.39 80]
E: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/pool/universe/f/fltk1.3/fluid_1.3.4-6_amd64.deb  Connection failed [IP: 2001:67c:1562::15 80]
E: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/pool/universe/f/freeglut/freeglut3_2.8.1-3_amd64.deb  Connection failed [IP: 91.189.91.39 80]
E: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/pool/universe/f/freeglut/freeglut3-dev_2.8.1-3_amd64.deb  Connection failed [IP: 2001:67c:1562::15 80]
E: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/pool/main/b/boost1.65.1/libboost-program-options1.65.1_1.65.1+dfsg-0ubuntu5_amd64.deb  Connection failed [IP: 91.189.91.39 80]
E: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/pool/universe/f/freexl/libfreexl1_1.0.5-1_amd64.deb  Connection failed [IP: 2001:67c:1562::15 80]
E: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/pool/universe/f/fyba/libfyba0_4.1.1-3_amd64.deb  Connection failed [IP: 91.189.91.39 80]
E: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/pool/universe/f/flite/libflite1_2.1-release-1_amd64.deb  Connection failed [IP: 2001:67c:1562::15 80]
E: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/pool/universe/r/rubberband/librubberband2_1.8.1-7ubuntu2_amd64.deb  Connection failed [IP: 91.189.91.39 80]
E: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/pool/universe/f/flann/libflann1.9_1.9.1+dfsg-2_amd64.deb  Connection failed [IP: 2001:67c:1562::15 80]
E: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/pool/universe/f/flann/libflann-dev_1.9.1+dfsg-2_amd64.deb  Connection failed [IP: 91.189.91.39 80]
E: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/pool/universe/f/fltk1.3/libfltk-cairo1.3_1.3.4-6_amd64.deb  Connection failed [IP: 2001:67c:1562::15 80]
E: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/pool/universe/f/fltk1.3/libfltk-gl1.3_1.3.4-6_amd64.deb  Connection failed [IP: 91.189.91.39 80]
E: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/pool/universe/f/fltk1.3/libfltk1.3-dev_1.3.4-6_amd64.deb  Connection failed [IP: 2001:67c:1562::15 80]
E: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/pool/universe/f/fyba/libfyba-dev_4.1.1-3_amd64.deb  Connection failed [IP: 91.189.91.39 80]
E: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/pool/universe/f/fonts-dejavu/ttf-dejavu-core_2.37-1_all.deb  Connection failed [IP: 2001:67c:1562::15 80]
E: Failed to fetch http://cn.archive.ubuntu.com/ubuntu/pool/universe/f/freexl/libfreexl-dev_1.0.5-1_amd64.deb  Connection failed [IP: 91.189.91.39 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

          我尝试了换源,最终阿里源成功了//也可以手动在“软件和更新”进行配置

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
#官方源

sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
#中科大源

sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
#清华源

sudo sh -c '. /etc/lsb-release && echo "deb https://mirrors.aliyun.com/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
#阿里源

2.2 包冲突问题 E: Unable to correct problems, you have held broken packages

sudo apt-get install ros-melodic-rqt*
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 ros-melodic-rqt-gui-cpp-dbgsym : Depends: ros-melodic-rqt-gui-cpp (= 0.5.2-1bionic.20210505.022126) but 0.5.2-1bionic.20210921.200406 is to be installed
 ros-melodic-rqt-image-view-dbgsym : Depends: ros-melodic-rqt-image-view (= 0.4.16-1bionic.20210505.032821) but 0.4.16-1bionic.20210921.210433 is to be installed
 ros-melodic-rqt-rviz-dbgsym : Depends: ros-melodic-rqt-rviz (= 0.6.0-0bionic.20210505.050255) but 0.7.0-1bionic.20211216.191229 is to be installed
E: Unable to correct problems, you have held broken packages
#输入下面几条命令,尽管终端没有反应,但再次apt-get install就可以了
#也可能是网络的问题
sudo apt-get install aptitude
aptitude why-not ros-melodic-rqt*
dpkg -l | grep ros-melodic-rqt



sudo apt-get install ros-melodic-rqt*

2.3 rosdep :command not found

meng@meng:~$ sudo rosdep init
sudo: rosdep: command not found


sudo apt install python-rosdep2

 最后安装上了

2.4 sudo rosdep init 

bit@ubuntu:~$ sudo rosdep init
ERROR: cannot download default sources list from:
https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list
Website may be down.

       解决方案见另一篇博客:ros(14):sudo rosdep init和rosdep update报错解决与理论分析----应该绝对好用_biter0088的博客-CSDN博客

3 安装sogou输入法

        下载地址,记得下那个安装包大一些的,下图这个“立即下载64bit”

搜狗输入法 for linux

        安装的话参考下面的官方链接,应该没问题

搜狗输入法 for linux 安装指南

---------------------------------------------------------------------------------------------------------- 

         安装时报错:

bit@bit-desktop:~/下载$ sudo dpkg -i sogoupinyin_4.0.0.1540_arm64.deb 
dpkg: 关于含有 sogoupinyin 的 sogoupinyin_4.0.0.1540_arm64.deb:
 sogoupinyin 会破坏 fcitx-ui-qimpanel
  fcitx-ui-qimpanel (版本为 2.1.3-1)已存在并且 已安装。

dpkg: 处理归档 sogoupinyin_4.0.0.1540_arm64.deb (--install)时出错:
 安装 sogoupinyin 将破坏 fcitx-ui-qimpanel,并且
不允许反配置(--auto-deconfigure 也许会有帮助)
在处理时有错误发生:
 sogoupinyin_4.0.0.1540_arm64.deb

        原因是sogou的安装包里面带这个组件,卸载并安装即可

sudo apt-get remove fcitx-ui-qimpanel

4 Anaconda安装

bash Anaconda3-5.3.1-Linux-x86_64.sh

下图依次:按下Enter、按下Q、输入yes、按下Enter

         下面依次:输入no、输入no

         配置~/.bashrc

sudo gedit ~/.bashrc

        在打开的文件中添加
    --------------------------注意修改用户名
        alias condaenv="export PATH="/home/meng/anaconda3/bin:$PATH"
        . /home/meng/anaconda3/etc/profile.d/conda.sh"
    -----------------------------

 source ~/.bashrc

            

          相关使用及优点:

python学习实践(1) ububtu系统采用anaconda搭建python环境_biter0088的博客-CSDN博客

 

ubuntu anaconda删除不用的包

参考:清理Anaconda占用空间_anaconda清理缓存_雕刻刀的博客-CSDN博客

参考:一篇文章教你清理 Anaconda 的 pkgs_conda clean -p_Robin_Pi的博客-CSDN博客

命令:

conda clean -p

conda clean -p 这个命令会检查哪些包没有在包缓存中被硬依赖到其他地方,并删除它们

Remove unused packages from writable package caches. WARNING: This does not check for packages installed using symlinks back to the package cache.
 

我们在配置环境中会自动下载一些包文件到本地,我的目录为 /home/xxx/anaconda3/pkgs,可以到该目录下查看,发现包基本上为压缩包形式,其中一部分包不被换将依赖,故可以删除,只是下次配置相同包的时候需要再次联网下载

5 好用的截图工具flameshot

ubuntu系统(五):截图工具flameshot ubuntu18.04和ubuntu16.04均可_biter0088的博客-CSDN博客

 

6 深度学习环境配置--显卡驱动、cuda11.3、cudnn

       Release Notes :: CUDA Toolkit Documentation

6.1 命令行安装显卡驱动--失败

ubuntu-drivers devices
meng@meng:~$ ubuntu-drivers devices
== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
modalias : pci:v000010DEd00002484sv00001462sd00003906bc03sc00i00
vendor   : NVIDIA Corporation
driver   : nvidia-driver-470-server - distro non-free
driver   : nvidia-driver-470 - distro non-free
driver   : nvidia-driver-510 - distro non-free recommended
driver   : xserver-xorg-video-nouveau - distro free builtin

== /sys/devices/pci0000:00/0000:00:14.3 ==
modalias : pci:v00008086d000043F0sv00008086sd00000074bc02sc80i00
vendor   : Intel Corporation
manual_install: True
driver   : backport-iwlwifi-dkms - distro free

        得到系统推荐的显卡驱动版本为recommended,输入下述命令安装推荐版本。

sudo ubuntu-drivers autoinstall

        报错如下,意思是缺少两个文件。

W: Possible missing firmware /lib/firmware/rtl_nic/rtl8125a-3.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8168fp-3.fw for module r8169

正在处理用于 initramfs-tools (0.130ubuntu3.13) 的触发器 ...
update-initramfs: Generating /boot/initrd.img-5.4.0-104-generic
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8125a-3.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8168fp-3.fw for module r8169
I: The initramfs will attempt to resume from /dev/nvme0n1p6
I: (UUID=8814a1a7-97ca-48c0-be51-bd745ff423ee)
I: Set the RESUME variable to override this.
正在处理用于 linux-image-5.4.0-104-generic (5.4.0-104.118~18.04.1) 的触发器 ...
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-5.4.0-104-generic
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8125a-3.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8168fp-3.fw for module r8169
I: The initramfs will attempt to resume from /dev/nvme0n1p6
I: (UUID=8814a1a7-97ca-48c0-be51-bd745ff423ee)
I: Set the RESUME variable to override this.
/etc/kernel/postinst.d/zz-update-grub:
Sourcing file '/etc/default/grub'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.4.0-104-generic
Found initrd image: /boot/initrd.img-5.4.0-104-generic
Found linux image: /boot/vmlinuz-5.4.0-84-generic
Found initrd image: /boot/initrd.img-5.4.0-84-generic
Found Windows Boot Manager on /dev/nvme0n1p1@/EFI/Microsoft/Boot/bootmgfw.efi
Adding boot menu entry for EFI firmware configuration
done
Trying to select the on-demand PRIME profile
Info: selecting the on-demand profile
Writing /lib/modprobe.d/nvidia-runtimepm.conf
Updating the initramfs. Please wait for the operation to complete:
\W: Possible missing firmware /lib/firmware/rtl_nic/rtl8125a-3.fw for module r8169
W: Possible missing firmware /lib/firmware/rtl_nic/rtl8168fp-3.fw for module r8169
|I: The initramfs will attempt to resume from /dev/nvme0n1p6
I: (UUID=8814a1a7-97ca-48c0-be51-bd745ff423ee)
I: Set the RESUME variable to override this.

        单独下载这两个文件

cd /lib/firmware/rtl_nic/

sudo wget https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/rtl_nic/rtl8125a-3.fw
https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/rtl_nic/rtl8168fp-3.fw

        卸载安装的驱动:

sudo apt-get remove --purge nvidia*

6.2 .run安装显卡驱动--失败--成功

        参考下面的ubuntu16.04链接的过程进行安装:

Ubuntu 16.04 Nvidia驱动安装(run方式)_lihe的博客-CSDN博客_nvidia驱动安装

        其中有关于图形话界面的参考师兄的一篇文章:

Ubuntu配置Nvidia显卡驱动_一只小菜鸟的博客-CSDN博客

        最后又参考了这位大神的

Ubuntu 18.04 NVIDIA驱动安装总结_TJU YanMing-CSDN博客_ubuntu18.04安装驱动

6.2.1 下载驱动文件

        官网:官方 GeForce 驱动程序 | NVIDIA

        先进行选择,然后搜索:

        搜索里面选了第一个下载

        在6.1的末尾已经卸载原有驱动了

6.2.2 禁用nouveau驱动

sudo gedit /etc/modprobe.d/blacklist.conf

         在打开的文件末尾添加:

blacklist nouveau
blacklist lbm-nouveau
options nouveau modeset=0
alias nouveau off
alias lbm-nouveau off

         保存 ,退出

        关闭nouveau:

echo options nouveau modeset=0 | sudo tee -a /etc/modprobe.d/nouveau-kms.conf

6.2.3 更新并重启

#更新
sudo update-initramfs -u
#重启
reboot

6.2.4 验证nouveau是否被禁用

lsmod | grep nouveau

        没有输出就已经被禁用了

6.2.5 获取Kernel source

sudo apt-get install linux-source

        终端输出:

##省略-------------------------------
正在选中未选择的软件包 linux-source-4.15.0。
(正在读取数据库 ... 系统当前共安装有 258028 个文件和目录。)
正准备解包 .../linux-source-4.15.0_4.15.0-171.180_all.deb  ...
正在解包 linux-source-4.15.0 (4.15.0-171.180) ...
正在选中未选择的软件包 linux-source。
正准备解包 .../linux-source_4.15.0.171.160_all.deb  ...
正在解包 linux-source (4.15.0.171.160) ...
正在设置 linux-source-4.15.0 (4.15.0-171.180) ...
正在设置 linux-source (4.15.0.171.160) ...

        说明安装的是4.15.0-171版本,下面命令会用到

#sudo apt-get install linux-headers-x.x.x-x-generic
sudo apt-get install linux-headers-4.15.0-171-generic

6.2.6 关闭图形界面/停止显示桌面

        ubuntu18.04按下Ctrl+Alt+F1没有进入控制台,下面发现没有影响

        没进入控制台就不要操作了,多按几次Ctrl+Alt+F1,或者重启(刚才安装完后重启电脑一直进不了图形化界面。。。。。)

        使用下面停止显示桌面

sudo telinit 3

分隔符:也可以吧------------------------------------------------------------------------------------------------------

sudo systemctl set-default multi-user.target

分隔符:也可以使用下面的关闭图形界面吧---------------------------------------------------------------------------------------------------------------------------

meng@meng:~$ sudo service lightdm stop
Failed to stop lightdm.service: Unit lightdm.service not loaded.

         安装一个工具lightdm再次执行命令,安装过程:“确定”--“lightdm”

sudo apt install lightdm

sudo service lightdm stop

 -------------------------------------------------------------------------------------------------------------------------

6.2.7 安装驱动

        这里的截图为第一次尝试部分,但过程和控制台一样,作为示意

#赋予权限
sudo chmod a+x NVIDIA-Linux-x86_64-510.54.run
sudo ./NVIDIA-Linux-x86_64-510.54.run 


#sudo ./NVIDIA-Linux-x86_64-396.18.run -no-x-check -no-nouveau-check -no-opengl-files
#下面是最后依次成功尝试的,没有加任何选项
#sudo ./NVIDIA-Linux-x86_64-396.18.run 

安装过程选项如下:

         重启

sudo reboot

6.3 安装cuda11.3

        根据师兄建议,选择了一个不是很新的11.3版本,下载链接:

CUDA Toolkit 11.3 Downloads | NVIDIA Developer

6.3.1 下载

         选择类型进行下载

  6.3.2 安装及选项

         下载完成后安装:

chmod +x cuda-xxx.run
sudo sh ./cuda_11.3.0_465.19.01_linux.run

         安装选项如下:

continue

 accept

按下enter,勾选掉Driver

 

选中install并按下enter

安装后的目录等如下:

 6.3.3 测试

cd /usr/local/cuda/samples/1_Utilities/deviceQuery #由自己电脑目录决定
sudo make
sudo ./deviceQuery

6.3.4 配置cuda到~/.bashrc

       找到下面两个目录,配置到~/.bashrc文件里

sudo gedit ~/.bashrc

export CUDA_HOME=$CUDA_HOME:/usr/local/cuda-11.3
export PATH=/usr/local/cuda-11.3/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-11.3/lib64:$LD_LIBRARY_PATH

 source ~/.bashrc

参考链接:Ubuntu如何查看计算机安装好Cuda_Steven_ycs的博客-CSDN博客_ubuntu怎么查看cuda是否安装成功

6.4 配置cudnn

6.4.1 下载

链接:cuDNN Archive | NVIDIA Developer

        前面安装了cuda11.3,在上面网页中没找到,于是下载了一个for cuda 11.x

        没想到下载下来的文件名里面居然有11.3,不知道为什么

 6.4.2 配置

        将下载文件解压,进入解压目录

sudo cp ./include/cudnn*.h /usr/local/cuda-11.3/include
sudo cp ./lib/libcudnn* /usr/local/cuda-11.3/lib64
 
sudo chmod a+r /usr/local/cuda-11.3/include/cudnn*.h 
sudo chmod a+r /usr/local/cuda-11.3/lib64/libcudnn*

6.5 重装cuda+cudnn

        因为cupy-cuda113版本过高不能适应一个网络问题,重装cuda为cuda-11.0。

6.5.1 卸载cuda-11.3

        卸载cuda

cd /usr/local/cuda-11.3/bin/
ls  #查找卸载工具

sudo ./cuda-uninstaller

        删除文件:

cd
sudo rm -rf /usr/local/cuda-11.3/

6.5.2 安装cuda-11.0

        过程参考:6.3

chmod +x cuda_xxxx.run
sudo sh ./cuda_11.0-xxxxxx.run
#xxxx代表版本号

6.5.3 配置cudnn

        过程参考:6.4.2

6.6 安装TensorRT

6.6.1 查看基本配置

可以使用 nvcc -v 查看 cuda 版本

nvcc -v和nvidia-smi显示的版本不一样是一个常见现象,主要由以下几个原因造成:

  1. 不同的显示内容

    • nvcc -v 显示的是CUDA编译工具(NVCC)的版本,它与CUDA开发工具包(SDK)相关,包括编译器、库和工具,用于开发和运行CUDA应用。12
    • nvidia-smi 显示的是GPU驱动支持的CUDA版本。这个版本指的是NVIDIA驱动能够支持的最高CUDA版本。1

也可以使用如下查看cuda和cudnn版本

cat /usr/local/cuda/version.txt
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
# 或(新版使用以下命令查看)
cat /usr/local/cuda/version.json
cat /usr/local/cuda/include/cudnn_version.h | grep CUDNN_MAJOR -A 2

得到本机为cuda 11.3 + ubuntu18.04

tensorrt支持矩阵(我理解为支持产品列表)查询,下图箭头为8.6.1支持的矩阵,其他的可以查看archive。Support Matrix :: NVIDIA Deep Learning TensorRT Documentation

6.6.2 安装pycuda

pip3 install pycuda -i https://mirrors.aliyun.com/pypi/simple

6.6.3 下载、安装与测试tensorrt

官网:Log in | NVIDIA Developer

 选了个不是最新,也不老的版本https://developer.nvidia.com/nvidia-tensorrt-8x-download

依次选 TensorRT 8、TensorRT 8.6 GA


 

大部分教程(教程1教程2)都是使用tar,不是deb,这里也使用tar(下图第一个箭头)

解压:

tar -zxvf TensorRT-8.6.1.6.Linux.x86_64-gnu.cuda-11.8.tar.gz

添加环境变量:

sudo gedit ~/.basrc
# 添加:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/biter/software/TensorRT-8.6.1.6/lib
export LIBRARY_PATH=$LIBRARY_PATH:/home/biter/software/TensorRT-8.6.1.6/lib
#保存:
source ~/.bashrc

复制到默认位置(暂时不知道是不是必要的)

sudo cp -rP /home/biter/software/TensorRT-8.6.1.6/lib/* /usr/lib/
sudo cp -rP /home/biter/software/TensorRT-8.6.1.6/include/* /usr/include/

测试:

#在TensorRt目录文件夹下,cd到sample文件夹下
sudo make
cd ../bin
# ./sample_mnist 不行
# 可以直接看该目录下有啥,我这里用的是下面的:
./sample_onnx_mnist

进入自己配的python环境(python为3.9),安装解压文件中的whl
 

conda activate multinerf

pip3 install tensorrt-8.6.1-cp39-none-linux_x86_64.whl

6.7 安装TensorFlow

使用pip install tensorflow默认安装的是最新版(2024年7月13日,安装的版本为2.17.1),版本较高,报错:

2024-07-13 15:49:02.938910: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:485] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
2024-07-13 15:49:02.947549: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:8454] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
2024-07-13 15:49:02.950165: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1452] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered

2024-07-13 15:49:03.875961: W tensorflow/core/common_runtime/gpu/gpu_device.cc:2343] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.

参考官方给的配置:从源代码构建  |  TensorFlow

本机cuda为11.3,这里没有测试版本。进一步参考我需要测试代码的issue,选择了2.9.2

pip install tensorflow==2.9.2

7 实时内存、网速检测

        参考链接:How to Install Indicator SysMonitor on Ubuntu & Debian - TecAdmin

7.1 配置源

sudo add-apt-repository ppa:fossfreedom/indicator-sysmonitor
sudo apt-get update
sudo apt-get install indicator-sysmonitor

7.2 启动system monitor

        然后就在右上角出现这个使用率

7.3 配置preference

        将鼠标放到上面箭头指的cpu位置,会出现一个下拉框,点击preference,选择advanced,添加 net:{net},即可(下图第一个箭头处有空格)

        最后配置效果如图所示:

8 压缩工具

8.1 rar

        格式为.rar的文件直接解压缩会提示错误,需要安装包:

sudo apt-get install rar
sudo apt-get install unrar

        解压缩效果如下

9 vscode

          执行下面的命令安装即可

sduo dpkg -i xxx.deb

        如运行python文件,在扩展里面搜索“python”,安装,可以实现python代码的补齐和跳转

        vscode撤销上一步操作:Ctrl+z

        vscode恢复上一步撤销的操作:Ctrl+shift+z        

        vscode回到上一步所在位置:ctrl + alt +  -

参考链接:

ubuntu18.04操作系统安装详细过程 - wangzuoli - 博客园

(1条消息) Windows11安装Ubuntu 20.04.3 LTS双系统(详细过程)_学习随笔-CSDN博客_win11安装ubuntu系统

Ubuntu18.04完整新手安装教程和分区设置_chencaw的专栏-CSDN博客_ubuntu 分区
安装ROS时执行到sudo rosdep init时出现sudo: rosdep:找不到命令提示_年少策马且长歌的博客-CSDN博客_rosdep找不到命令
E: Unable to correct problems, you have held broken packages 解决方法 - Jerry.Kwan - 博客园

解决elementaryos下报错W: Possible missing firmware /lib/firmware/rtl_nic/rtl8125a-3.fw for module r8169_KangJiayin的博客-CSDN博客Ubuntu 18.04安装CUDA和cuDNN - 知乎解决elementaryos下报错W: Possible missing firmware /lib/firmware/rtl_nic/rtl8125a-3.fw for module r8169_KangJiayin的博客-CSDN博客

  • 57
    点赞
  • 299
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值