从零开始安装一台Ubuntu 18.04 + NVIDIA GPU机器的过程

根据印象更新一下从零开始安装 Ubuntu 18.04 + Nvidia GPU 的过程

December 14, 2019 -
备忘
-

配置清单

主板:Z390

CPU:i9-9900K

GPU:RTX2080Ti

内存条:16G×4

固态:512G

机械:2T

以及剩下水冷、电源、机箱之类的

装机

  1. 先插内存条到主板上
  2. 装固态到主板上
  3. 装CPU
  4. 固定主板到机箱上,先弄好IO口然后再固定
  5. 装水冷,先把散热片固定好,然后把背板固定住,涂胶,按上去
  6. 插线,RGB/sys fan/机箱线
  7. 固定机械硬盘位置
  8. 电源插线,同时插GPU的电源
  9. 固定GPU到主板
  10. 装上WiFi天线
  11. 插liveCD开机,按F11

分区

SSD:50G给/,1G给boot,256M给EFI,不要swap,剩下给/home

HDD:全部/data

注意不要连wifi,不然慢的要死……

配环境

  • 修改 /etc/apt/sources.list 为tuna镜像源,并添加 deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/ /装nv驱动

  • sudo apt remove libreoffice* thunderbird* && sudo apt update && sudo apt upgrade && sudo apt autoremove

  • 注意先配好一下ssh和ifconfig查看ip,方便出锅能够抢救回来:sudo apt install net-tools openssh-server

  • 安装驱动+cuda:sudo apt install cuda-10-1 xserver-xorg-input-all ,然后重启。如果装完驱动之后输入挂掉的话,ssh进去,sudo apt install --reinstall xserver-xorg-input-all

  • sudo apt install git htop zsh vim tmux cmake curl axel texlive-full gummi proxychains python-pip python3-pip libopencv-dev libboost-dev gnome-tweak-tool openvpn openssl mpv xclip enca apache2 php7.2 unrar ruby gnome-shell-extensions dos2unix icdiff openjdk-11-jdk libglew-dev libcanberra-gtk-module libcanberra-gtk3-module tlp freeglut3 freeglut3-dev patchelf libgconf-2-4 pandoc lolcat figlet ttf-mscorefonts-installer binwalk chrome-gnome-shell 并安装oh-my-zsh 和.tmux

# 如果是第一次
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
cd
git clone https://github.com/gpakosz/.tmux.git
ln -s -f .tmux/.tmux.conf
cp .tmux/.tmux.conf.local .
# 如果装过了
chsh -s /usr/bin/zsh
  • 安装 chrome、typora、sublime、teamviewer、wps-office、sogoupinyin、vmware(15.5)、cudnn、netease-cloud-music,注意搜狗安装完之后要修改成fcitx:设置-区域和语言-管理已安装语言-键盘输入法系统,然后把候选改成9

  • 升级pip之后pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple,然后 pip3 install torch torchvision opencv-python tensorflow-gpu jupyter matplotlib ipython mitmproxy bs4 gpustat scikit-image tqdm "gym[atari]" ansible --upgrade --user ,还有个pip3 install git+https://github.com/shadowsocks/shadowsocks.git@master --user

  • 同时安装macbuntu

sudo add-apt-repository ppa:noobslab/macbuntu
sudo apt install macbuntu-os-icons-v1804 macbuntu-os-ithemes-v1804
  • 修改~/.zshrc:添加
export PATH=$PATH:/home/trinkle/.local/bin:/usr/local/cuda/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/home/trinkle/.mujoco/mujoco200/bin
export LD_PRELOAD=$LD_PRELOAD:/usr/lib/x86_64-linux-gnu/libGLEW.so
  • 修改gnome-tweaks:应用程序MacBuntu-Sierra-light,光标MacBuntu-OSX-cursors,图标MacBuntu-OSX,字体-窗口标题Ubuntu-Italic 11,桌面-显示图标-全部关掉,顶栏看情况调整

  • 修改背景,然后把登录界面也给改了:sudo vim /etc/alternatives/gdm3.css

#lockDialogGroup {
    background: #2c001e url(file:///home/trinkle/pic/Wallpapers/ball_p2.png);
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
}
  • 修改terminal首选项:内置方案自定义,默认颜色-背景-#300924,使用透明背景,文本-光标形状-下划线

  • 修改gnome-extension,访问https://extensions.gnome.org/,安装vitals、openweather、NVIDIA GPU Stats Tool,间隔2s

  • 配置文件服务器,详见https://github.com/Trinkle23897/LAP-server

  • 安装完chrome之后删掉密钥环:rm -rf ~/.local/share/keyrings/*

  • 修改/etc/proxychains.conf/etc/ansible/hosts/etc/ssh/sshd_config~/.ssh/config~/.zshrc~/.gitconfig,并添加开机启动ss选项

  • 删除wps-pdf并取消自动关联:pdf文件-右键-属性-打开方式-默认应用程序,改为文档查看器,并且取消wps-pdf关联;然后 cd /usr/share/mime; sudo rm application/wps-office.pdf.xml packages/wps-office-pdf.xml; sudo update-mime-database -V .

UnixBench跑分结果

========================================================================
   BYTE UNIX Benchmarks (Version 5.1.3)

   System: MS-7B17: GNU/Linux
   OS: GNU/Linux -- 5.3.0-25-generic -- #27~18.04.2-Ubuntu SMP Thu Dec 12 17:32:44 UTC 2019
   Machine: x86_64 (x86_64)
   Language: en_US.utf8 (charmap="UTF-8", collate="UTF-8")
   CPU 0: Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz (7200.0 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization
   CPU 1: Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz (7200.0 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization
   CPU 2: Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz (7200.0 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization
   CPU 3: Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz (7200.0 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization
   CPU 4: Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz (7200.0 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization
   CPU 5: Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz (7200.0 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization
   CPU 6: Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz (7200.0 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization
   CPU 7: Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz (7200.0 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization
   CPU 8: Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz (7200.0 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization
   CPU 9: Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz (7200.0 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization
   CPU 10: Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz (7200.0 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization
   CPU 11: Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz (7200.0 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization
   CPU 12: Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz (7200.0 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization
   CPU 13: Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz (7200.0 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization
   CPU 14: Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz (7200.0 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization
   CPU 15: Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz (7200.0 bogomips)
          Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT, SYSCALL/SYSRET, Intel virtualization
   19:50:21 up 1 day,  7:34,  3 users,  load average: 0.03, 0.08, 0.08; runlevel 5

------------------------------------------------------------------------
Benchmark Run: 一 12月 16 2019 19:50:21 - 20:20:31
16 CPUs in system; running 1 parallel copy of tests

Dhrystone 2 using register variables       60316842.0 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                     3611.7 MWIPS (22.9 s, 7 samples)
Execl Throughput                               8559.4 lps   (29.9 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks       1735187.3 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks          459604.5 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks       4776228.8 KBps  (30.0 s, 2 samples)
Pipe Throughput                             2959668.6 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                 335394.6 lps   (10.0 s, 7 samples)
Process Creation                               5709.9 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                   4227.4 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                   7985.8 lpm   (60.0 s, 2 samples)
System Call Overhead                        3789789.9 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0   60316842.0   5168.5
Double-Precision Whetstone                       55.0       3611.7    656.7
Execl Throughput                                 43.0       8559.4   1990.6
File Copy 1024 bufsize 2000 maxblocks          3960.0    1735187.3   4381.8
File Copy 256 bufsize 500 maxblocks            1655.0     459604.5   2777.1
File Copy 4096 bufsize 8000 maxblocks          5800.0    4776228.8   8234.9
Pipe Throughput                               12440.0    2959668.6   2379.2
Pipe-based Context Switching                   4000.0     335394.6    838.5
Process Creation                                126.0       5709.9    453.2
Shell Scripts (1 concurrent)                     42.4       4227.4    997.0
Shell Scripts (8 concurrent)                      6.0       7985.8  13309.6
System Call Overhead                          15000.0    3789789.9   2526.5
                                                                   ========
System Benchmarks Index Score                                        2287.4

------------------------------------------------------------------------
Benchmark Run: 一 12月 16 2019 20:20:31 - 20:51:41
16 CPUs in system; running 16 parallel copies of tests

Dhrystone 2 using register variables      644938503.8 lps   (10.0 s, 7 samples)
Double-Precision Whetstone                    38756.9 MWIPS (28.6 s, 7 samples)
Execl Throughput                              72928.9 lps   (30.0 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks       1592603.4 KBps  (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks          410084.6 KBps  (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks       5161291.3 KBps  (30.0 s, 2 samples)
Pipe Throughput                            28935863.5 lps   (10.0 s, 7 samples)
Pipe-based Context Switching                3575636.7 lps   (10.0 s, 7 samples)
Process Creation                             137862.0 lps   (30.0 s, 2 samples)
Shell Scripts (1 concurrent)                 120933.9 lpm   (60.0 s, 2 samples)
Shell Scripts (8 concurrent)                  17602.6 lpm   (60.0 s, 2 samples)
System Call Overhead                       11032314.4 lps   (10.0 s, 7 samples)

System Benchmarks Index Values               BASELINE       RESULT    INDEX
Dhrystone 2 using register variables         116700.0  644938503.8  55264.7
Double-Precision Whetstone                       55.0      38756.9   7046.7
Execl Throughput                                 43.0      72928.9  16960.2
File Copy 1024 bufsize 2000 maxblocks          3960.0    1592603.4   4021.7
File Copy 256 bufsize 500 maxblocks            1655.0     410084.6   2477.9
File Copy 4096 bufsize 8000 maxblocks          5800.0    5161291.3   8898.8
Pipe Throughput                               12440.0   28935863.5  23260.3
Pipe-based Context Switching                   4000.0    3575636.7   8939.1
Process Creation                                126.0     137862.0  10941.4
Shell Scripts (1 concurrent)                     42.4     120933.9  28522.2
Shell Scripts (8 concurrent)                      6.0      17602.6  29337.6
System Call Overhead                          15000.0   11032314.4   7354.9
                                                                   ========
System Benchmarks Index Score                                       11916.6



======= Script description and score comparison completed! =======

效果图

Sample image

Sample image