参考文献
下载网址
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启动盘
1.选择ultraiso,右键单击,选择“以管理员身份运行”;
2.点击左上角“文件”,选择“打开”,最后选择需要的操作系统文件,点击“打开”;
3.选择“启动”,再选择“写入硬盘映像”;
4.选择u盘,写入方式选择“USB-HDD+”,最后点击“写入”;
5.等待u盘写入操作系统镜像完成即可。
输入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
安装五笔
ubuntu20.04
john@john-HP-Laptop:~/Desktop$ sudo apt-get install ibus-rime
john@john-HP-Laptop:~/Desktop$ sudo apt-get install librime-data-wubi librime-data-pinyin-simp
john@john-HP-Laptop:~$ ibus restart
shift直接切换五笔和拼音英文模式。
任何模式下直接回车可输入英文,但长英文只能是拼音模式。
任何模式下直接shift加回车就是大写字母。点击+号
再选择WuBi和Pinyin两种输入法
ubuntu18.04
sudo apt install freewb
左右手错位
左右手的切换花了一个小时解决问题
光标自动触发
镜像源
把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://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 # 休眠,内存中内容拷入硬盘
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
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=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
调出五笔
快捷键设置
版本选择
tensorflow版本与cuda和cudnn的对应关系:
https://tensorflow.google.cn/install/source
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:
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
鼠标复位
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】