Ubuntu 18.04双系统,含GPU、Linux Docker、Vitis-AI、休眠省电、五笔,以及安装问题USB启动、左右手错位、cudnn bug、Tweak tool

34 篇文章 8 订阅
29 篇文章 2 订阅

参考文献

Windows10安装ubuntu18.04双系统教程 - 不妨不妨,来日方长 - 博客园 https://www.cnblogs.com/masbay/p/11627727.html

下载网址

https://developer.nvidia.com/cuda-downloads
https://developer.nvidia.com/rdp/form/cudnn-download-survey

DiskGenius分区

用DiskGenius进行分区调整和新分区,为Linux预留下空间。
https://www.diskgenius.cn/help/createpartex.php
在这里插入图片描述

用UltraISO做USB启动盘

在这里插入图片描述
输入WIN R,然后输入diskmgmt.msc,按回车键名即可打开磁盘管理, C盘留300M, 最后一个盘留500G给Linux。这些空间必须是未分配状态。

选中较快的SSD硬盘作为Linux分区,后续要进行AI计算
在这里插入图片描述
SSD就是磁盘0,预留了500G
在这里插入图片描述

设置BIOS USB启动

设置Secure Boot Control Disabled, USB Preboot mode Enabled
在这里插入图片描述

在这里插入图片描述

BIOS无USB启动

F2进入Bios, 没有USB启动,中文无解,查外文

• USB device is plugged in
• F2 to BIOS
• Switch to “Boot” and set “FastBoot” to Disabled
• Switch to “Security” and set “Secure Boot Control” to Disabled
• F10 to save and exit and immediately press F2 to BIOS
• Only then could I switch to “Boot” and set “Launch CSM” to Enabled
• F10 to save and exit and immediately press F2 to BIOS
• Now select a boot option. My USB option didn’t say USB, it was just [ 8.0.7]
• F10 to save and exit – booted right to USB

设置成功
在这里插入图片描述

Ubuntu 安装, 选something else

在这里插入图片描述

安装五笔

在这里插入图片描述
在这里插入图片描述

左右手错位

左右手的切换花了一个小时解决问题
在这里插入图片描述

光标自动触发

在这里插入图片描述

镜像源

把Ubuntu的服务器source.list换成清华源
/etc/apt/sources.list

创建文件/home/.pip/pip.conf, 内容如下:
[global]
timeout = 6000
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn

因为许多的科学软件及其数据都在境外,但该网站限制VPN工具的介绍,关于如何安装VPN,也只好请大家自行搜索安装。

启用Ubuntu的休眠模式

sudo apt install gnome-tweak-tool
gnome-shell --version
Ubuntu 18.04下电源菜单中添加(Hibernate)休眠选项
https://ywnz.com/linuxjc/1577.html
https://blog.csdn.net/RayMonD_D/article/details/104968207
https://extensions.gnome.org/extension/755/hibernate-status-button/
在这里插入图片描述
/dev/nvme0n1p5 373108736 388732927 15624192 7.5G Linux swap
sudo systemctl suspend or the hibernate option: sudo systemctl hibernate
open /etc/default/grub
find GRUB_CMDLINE_LINUX_DEFAULT= line - these are the option added to the regular boot menu choices
add the resume=/dev/nvme0n1p5 option to the list (with correct swap partition path) like this:
Before: GRUB_CMDLINE_LINUX_DEFAULT=“nosplash enable_mtrr_cleanup=1”
After: GRUB_CMDLINE_LINUX_DEFAULT=“nosplash enable_mtrr_cleanup=1 resume=/dev/sda6”
save file
in the terminal execute command (to actually enable the new configuration settings)
sudo update-grub2
在经历以上惨痛经历后,仍未获成功

省电设置

Ubuntu通过命令睡眠、休眠
$ sudo apt-get install laptop-mode-tools  # 安装laptop-mode,否则直接用挂起命令会导致系统down掉,只能强制关机
$ cat /proc/sys/vm/laptop_mode        # 命令查看当前laptop-mode情况,若为0,则说明没开启
$ sudo gedit /etc/laptop-mode/laptop-mode.conf # 修改配置文件
修改ENABLE_LAPTOP_MODE_ON_AC为 1,即插上电源时可以用命令挂起(没插时就直接合上盖子吧)
$ sudo laptop_mode start            # 启动laptop_mode
$ cat /proc/sys/vm/laptop_mode         # 查看是否成功启动,不为0则成功;按上面的配置是2
$ systemctl suspend               # 挂起电脑,与合上盖子一个效果
$ systemctl hibernate              # 休眠,内存中内容拷入硬盘
https://www.cnblogs.com/grainrain/p/13377515.html
Ubuntu 18.04下电源菜单中添加(Hibernate)休眠选项
https://ywnz.com/linuxjc/1577.html

Vitis-AI 要求

The GPU docker has been tested with GPU machines with Docker 19.03.1, NVIDIA driver 410.xx (to work with CUDA 10.0) and nvidia-docker 2.2.2.

Nvidia驱动

禁止自带的nouveau nvidia驱动
打开配置文件
sudo vim /etc/modprobe.d/blacklist-nouveau.conf
填写禁止配置的内容:
blacklist nouveau
options nouveau modeset=0
更新配置文件,
sudo update-initramfs -u

john@john-wang:~/Vitis-AI/docker$ ubuntu-drivers devices
== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
modalias : pci:v000010DEd0000139Asv00001043sd00001A8Dbc03sc02i00
vendor : NVIDIA Corporation
model : GM107M [GeForce GTX 950M]
driver : nvidia-driver-440 - distro non-free recommended
driver : nvidia-driver-435 - distro non-free
driver : nvidia-driver-390 - distro non-free
driver : xserver-xorg-video-nouveau - distro free builtin

如果遇到上面的命令没有回显,选中下面的第三项,再更新后就有了
在这里插入图片描述

依赖库安装

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

Cuda Install

Installation Instructions:
sudo apt-key add /var/cuda-repo-10-0-local-10.0.130-410.48/7fa2af80.pub
sudo dpkg -i cuda-repo-ubuntu1804-10-0-local-10.0.130-410.48_1.0-1_amd64.deb
sudo apt-get update
sudo apt-get install cuda

https://blog.csdn.net/u010532666/article/details/103451377
sudo dpkg -i cuda-repo-ubuntu1804-10-0-local-nvjpeg-update-1_1.0-1_amd64.deb

sudo vim /etc/proflie

#set nvidia cuda env
export CUDA_HOME=/usr/local/cuda
export PATH= P A T H : PATH: PATH:CUDA_HOME/bin
export LD_LIBRARY_PATH=/usr/local/cuda/lib64KaTeX parse error: Expected '}', got 'EOF' at end of input: …LIBRARY_PATH:+:{LD_LIBRARY_PATH}}
在这里插入图片描述
source ~/.bashrc
sudo apt install nvidia-cuda-toolkit

测试CUDA是否安装成功,终端输入命令:nvcc -V
在这里插入图片描述
cd /usr/local/cuda-10.0/samples/1_Utilities/deviceQuery
sudo make
./deviceQuery
在这里插入图片描述
若出现下面的错误,
cudaGetDeviceCount returned 30 -> unknown error
输入命令
nvidia-smi
可能出现:
failed to initialize NVML: Driver/library version mismatch
重启系统即可

安装Cudnn

https://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html

john@john-wang:~/Downloads$ sudo dpkg -i libcudnn7_7.6.5.32-1+cuda10.0_amd64.deb
john@john-wang:~/Downloads$ sudo dpkg -i libcudnn7-dev_7.6.5.32-1+cuda10.0_amd64.deb
john@john-wang:~/Downloads$ sudo dpkg -i libcudnn7-doc_7.6.5.32-1+cuda10.0_amd64.deb

验证cudnn
cudnn本身的bug
Editing /usr/include/cudnn.h, changing the line:
sudo vim /usr/include/cudnn.h
#include “driver_types.h” to #include <driver_types.h>

john@john-wang:~/Downloads$ cp -r /usr/src/cudnn_samples_v7/ $HOME
john@john-wang:~/Downloads$ cd  $HOME/cudnn_samples_v7/mnistCUDNN
john@john-wang:~/cudnn_samples_v7/mnistCUDNN$ make clean && make
john@john-wang:~/cudnn_samples_v7/mnistCUDNN$ ./mnistCUDNN

在这里插入图片描述

调出五笔

在这里插入图片描述
https://blog.csdn.net/lihengchang0212/article/details/89844120?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase

快捷键设置

在这里插入图片描述
在这里插入图片描述

版本选择

tensorflow版本与cuda和cudnn的对应关系:
https://tensorflow.google.cn/install/source
https://blog.csdn.net/weixin_41863685/article/details/80303963

Anaconda安装

对于anaconda3 的安装非常简单,从官网中直接下载3.5版本的sh文件。然后执行如下命令对conda进行安装,我下载的是Anaconda3-5.1.0-Linux-x86_64.sh,过程直接yes、yes安装即可,对于不懂的可以看这个更详细的教程。
bash Anaconda3-5.1.0-Linux-x86_64.sh
安装完成后要重启电脑才能打开jupyter notebook。重启之后在终端输入一下命令进入notebook:
https://blog.csdn.net/weixin_41863685/article/details/80303963
jupyter notebook
打开notebook界面如下,是生成在浏览器中的.
.TensorFlow和Keras 安装
安装完anaconda 以后可以在终端直接用pip 对TensorFlow和Keras进行安装:

安装 gpu 版本的 tensorflow keras opencv

sudo pip3 install tensorflow-gpu==1.14.0 # 默认安装最新版本
sudo pip3 install keras==2.2.4
sudo pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow==1.14.0 
sudo pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple install keras==2.2.4

对于测试的代码可以使用手写数字识别进行测试,在GitHub这里可以找到。我用自己的项目跑了一下,是在jupyter notebook上运行的,使用的框架是Keras。

下面是使用keras opencv图片时的一通狂安装

pip3 install numpy
python3 -m pip install matplotlib
在这里插入图片描述
降级:
pip install h5py==2.10 -i https://pypi.tuna.tsinghua.edu.cn/simple/

安装opencv时,如果出现下面的问题,请依照下面的顺序安装
在这里插入图片描述

pip3 install --upgrade pip
pip3 install opencv-python

保存调试镜像

docker ps -l
docker commit ID repository
docker images

进入GPU镜像

容器内输入nvidia-smi,检查是否载入GPU驱动
docker run --runtime=nvidia \

Docker内图像显示

-v /tmp/.X11-unix:/tmp/.X11-unix \ #共享本地unix端口
-e DISPLAY=$DISPLAY \ #修改环境变量DISPLAY

https://www.cnblogs.com/ruiyang-/p/10185840.html

鼠标复位

dconf reset -f /org/mate/desktop/peripherals/mouse/

截图快捷键

在这里插入图片描述

双系统突变单系统

重新装引导区
sudo update-grub
sudo grub-install /dev/sda

锁屏

正常情况无法关闭锁屏时,用命令行
gsettings get org.gnome.desktop.lockdown disable-lock-screen
false

禁止更新

sudo gedit /etc/apt/apt.conf.d/10periodic

APT::Periodic::Update-Package-Lists "0";
APT::Periodic::Download-Upgradeable-Packages "0";
APT::Periodic::AutocleanInterval "0";
APT::Periodic::Unattended-Upgrade "0";

sudo gedit /etc/apt/apt.conf.d/20auto-upgrades

APT::Periodic::Update-Package-Lists "0";
APT::Periodic::Download-Upgradeable-Packages "0";
APT::Periodic::AutocleanInterval "0";
APT::Periodic::Unattended-Upgrade "0";

**

TWEAK TOOL

**
【sudo add-apt-repository universe】
回车再次键入命令:【sudo apt install gnome-tweak-tool】

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值