科研工具|Ubuntu 装机那些事(更新中)☺️

Ubuntu 16.04版本,显卡:GeForce GTX 1070

1.系统安装

  • 参考:https://blog.csdn.net/gent__chen/article/details/48713991
  • 硬盘500G分区方案:
    根目录:102400MB
    交换空间:10240MB
    /boot:10240MB(boot文件用于存放系统引导文件和内核,Linux内核更新后,可释放磁盘空间
    /home: 389120MB

2.显卡驱动

  • 一种方法是通过ppa源安装,但这种方法对我来说不管用,我使用了高版本和低版本驱动都不行🤔。
  • 使用run方式安装,成功,仅限跟我同版本的服务器。
    (1)从NVIDIA官网下载驱动
    手动搜索.png
    这里我选择了NVIDIA-Linux-x86_64-410.78.run下载,可以尝试更高版本。
    (2)终端卸载已经存在的驱动
sudo apt-get purge nvidia*

这种方法卸载不了,可以使用一下语句卸载

sudo service lightdm stop
sh ./NVIDIA-Linux-x86_64-410.78.run --uninstall
sudo service lightdm start

参考:https://blog.csdn.net/WILLIAMMMS/article/details/80791756
(3)禁用第三方开源的驱动程序nouveau
打开

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

在文件末端加入

blacklist nouveau  
options nouveau modeset=0

更新系统,使禁用 nouveau 真正生效

sudo update-initramfs -u

最后重启系统。
重启系统后,在终端输入命令lsmod | grep nouveau查看是否被禁用(输入命令后,没有打印任何信息,即禁用成功)。

(4)关闭桌面服务
图形化界面按住ctrl+alt+(F1~F6的其中一个)进入命令行模式输入用户名和密码,然后在输入sudo service lightdm stop
如果出现Failed to stop lightdm.service: Unit lightdm.service not loaded. ,则先安装LightDm: sudo apt install lightdm。
(5)安装驱动run文件
赋予执行权限sudo chmod a+x NVIDIA-Linux-x86_64-410.78.run
安装sudo ./NVIDIA-Linux-x86_64-410.78.run
安装最好使用 sudo ./NVIDIA-Linux-x86_64-410.78.run -no-x-check -no-nouveau-check -no-opengl-files (避免循环登录)
在安装过程中,出现的问题,参考:https://blog.csdn.net/lihe4151021/article/details/90083431。
(6)重启后,nvidia-smi命令检查是否安装成功,出现下图,证明驱动安装成功。

  • 安装新版本的驱动后,可能会出现如下问题,原因可能是kernel mod 的 Nvidia driver 的版本没有更新,参考
Failed to initialize NVML: Driver/library version mismatch

一般情况下,重启系统就可以解决,但不想重启的话可以按照下面操作:

lsmod | grep nvidia
sudo rmmod nvidia_drm
sudo rmmod nvidia_modeset
sudo rmmod nvidia_uvm
sudo rmmod nvidia

如果出现rmmod: ERROR: Module nvidia is in use,输入:

sudo lsof /dev/nvidia*

3.安装cuda和cudnn

参考教程:https://blog.csdn.net/j879159541/article/details/93590342
cuda就是下载的教程中的10.0版本,下载地址https://developer.nvidia.com/cuda-toolkit-archive

  • 进入官方下载界面,选择:
    cuda
  • 安装cuda_10.0.130_410.48_linux.run
sudo sh cuda_10.0.130_410.48_linux.run

安装过程中出现下列选项:
安装选项

4.更换清华镜像源

  • 首先备份原配置文件
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup

-将sources.list中内容注释掉,换成清华镜像源
https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/

  • 更新
sudo apt-get update

5.安装anaconda3

-bash: /home/zh/miniconda3/envs/pytorch_11/bin/pip: /media/disk/miniconda3/envs/pytorch_11/bin/python: bad interpreter: No such file or directory

解决办法:

which pip
/home/zh/miniconda3/envs/py36/bin/pip

which python
/home/zh/miniconda3/envs/py35/bin/python

vim /home/zh/miniconda3/envs/py35/bin/pip

把#!后面的改成python的路径就好了。

6.安装搜狗输入法

sudo apt-get upgrade 这个指令千万别乱用啊,都是泪😭
参考:
https://zhuanlan.zhihu.com/p/57868480
https://www.jianshu.com/p/cafe12618293
https://blog.csdn.net/areigninhell/article/details/79696751

7. 安装teamviewer

sudo apt-get install libjpeg62:i386 libxinerama1:i386 libxrandr2:i386 libxtst6:i386 ca-certificates
  • 安装deb软件包
sudo dpkg -i teamviewer_amd64.deb

安装过程中出现下图所示错误,缺少依赖关系。安装错误.png
执行下面命令修复

sudo apt-get install -f

再执行sudo dpkg -i teamviewer_amd64.deb,显示如下即安装成功。
安装成功.png

  • 停止teamviewer
sudo teamviewer --daemon stop
  • 修改配置文件
vim /opt/teamviewer/config/global.conf

在配置文件末尾添加:

[int32] EulaAccepted = 1 
[int32] EulaAcceptedRevision = 6

保存退出(wq)后,cat global.conf查看是否修改成功。

  • 启动teamviewer
sudo teamviewer --daemon start
  • 获取Teamviewer ID
teamviewer --info print id
  • 设置teamviewer 密码
 sudo teamviewer --passwd [PASSWORD]

8.安装有道词典

参考教程:https://www.cnblogs.com/TooyLee/p/7750002.html

Ubuntu18.04版本,显卡:GeForce GTX 1080Ti

1. 安装VNC远程桌面

在学校局域网内,使用VNC速度快,使用流畅,但只能在同一局域网内使用。
对于Ubuntu18.04的安装过程如下:

  • 安装xfce4远程桌面
sudo apt-get install xfce4 
  • 安装VNCServer
sudo apt-get install vnc4server 
  • 安装成功后,设置登录密码
vncpasswd
  • 运行vncserver,系统默认创建了VNC的xstartup配置文件
vncserver
  • 通过ps -ef | grep vnc查看已用端口(刚刚开启的端口),并杀死
vncserver -kill :2
  • 修改~/.vnc/xstartup配置文件vim ~/.vnc/xstartup
#!/bin/bash
xrdb $HOME/.Xresources
startxfce4 &
  • 重新启动
vncserver
  • 修改分辨率(先要杀死相应端口vncserver -kill :5)
vncserver -geometry 1920x1080 :5

为避免重启后失效,可以修改配置文件vi /usr/bin/vncserver

$geometry = "1920x1080";      #可以修改分辨率
$depth = 16;

2、双网卡不能联网问题

  • 查看已有以太网端口
ifconfig
  • 确定连接外网的端口,我的是eno1,执行
sudo dhclient eno1

出现RTNETLINK answers: File exist

  • 更新
sudo apt-get update && sudo apt-get -y upgrade
sudo apt-get install vim
  • sudo vim /etc/network/interfaces中添加:
auto lo
iface lo inet loopback
  • 接下来执行
sudo ifdown eno1 && sudo ifup eno1

最后用ifconfig检查新的网址是否工作。

3. 安装matlab2018

参考网址: https://www.jianshu.com/p/2648a5c5c691

Ubuntu 16.04版本,显卡:Tesla k40c

1. 显卡驱动

Tesla k40c 需要在NVIDIA官网下载驱动,网址:https://www.nvidia.cn/Download/index.aspx?lang=cn。下载具体信息:
image.png
这里下载了NVIDIA-Linux-x86_64-440.33.01.run,440的显卡自带CUDA,不需要再重新安装。

装机小tips

1. 装机时输入法设置成中文,改成英文。

  • Ctrl+Alt+T 进入终端

  • cd /etc/default

  • sudo vim locale

LANG="zh_CN.UTF-8"

LANGUAGE="zh_CN:zh"

改为

LANG="en_US.UTF-8"

LANGUAGE="en_US:en"
  • reboot

2. 本地打开服务器端Tensorboard

  • 首先在服务器端tensorboard --logdir=logs一下,查看端口号(一般为6006)。
  • 本地终端输入
ssh -L 16006:127.0.0.1:6006 user@XXX.XXX.XX.XX 

即将远程服务器端的6006端口转发到本地的16006端口,在本地对16006端口的访问即是对远程6006端口的访问。之后在远程服务器端输入

tensorboard --logdir=logs
  • 本地访问地址http://127.0.0.1:16006/
  • 当然了,你也可以自己指定端口哦,步骤在下面,本地登录
ssh -L 16005:127.0.0.1:6005 user@XXX.XXX.XX.XX 

远程服务器端输入

tensorboard --logdir=logs --port=6005
  • 本地访问地址http://127.0.0.1:16005/

3.使用阿里云(外网)服务器配置反向端口转发

机器IP用户名
A(外网阿里云服务器)remote-hostzhr
B(内网实验室服务器)inner-hostouc02
(1)ssh 参数
-f 后台执行ssh指令
-C 允许压缩数据
-N 不执行远程指令
-R 将远程主机(服务器)的某个端口转发到本地端指定机器的指定端口
-L 将本地机(客户机)的某个端口转发到远端指定机器的指定端口
-p 指定远程主机的端口

反向代理ssh -fCNR

正向代理ssh -fCNL

(2)配置步骤
  • 在阿里云端开启几个端口,这里绑定了7280,7281,7282三个。
  • 在B上建立内网到外网的反向代理
    在B(内网实验室服务器)上输入ssh -fCNR 7280:localhost:22 zhr@remote-host,其中7280是阿里云服务器绑定端口号,22是实验室服务器固定端口号。
    在B上输入ps aux | grep ssh查看是否启动。
    在A阿里云端输入netstat -tln或者netstat -anltp |grep 7280查看反向代理连接是否成功。
ouc02@ouc02-X10SRA:~$ ssh -fCNR 7280:localhost:22 zhr@remote-host
ouc02@ouc02-X10SRA:~$ ps aux | grep ssh
root      1206  0.0  0.0  65512  6184 ?        Ss   Mar27   0:00 /usr/sbin/sshd -D
root     10484  0.0  0.0  94928  6884 ?        Ss   20:42   0:00 sshd: ouc02 [priv]
ouc02    10551  0.0  0.0  94928  3384 ?        S    20:42   0:00 sshd: ouc02@pts/20
root     11169  0.0  0.0  95016  7124 ?        Ss   20:58   0:00 sshd: ouc02 [priv]
ouc02    11263  0.0  0.0  95016  3324 ?        S    20:58   0:00 sshd: ouc02@pts/27
root     11770  0.0  0.0  95016  7044 ?        Ss   21:07   0:00 sshd: ouc02 [priv]
ouc02    11795  0.0  0.0  95016  3416 ?        S    21:08   0:00 sshd: ouc02@pts/26
ouc02     2137  0.0  0.0  45340  3780 ?        Ss   Mar27   0:06 ssh -fCNR 7280:localhost:22 zhr@remote-host
root     14272  0.0  0.0  94928  6860 ?        Ss   Mar28   0:00 sshd: sqw [priv]
sqw      14341  0.0  0.0  94928  3180 ?        S    Mar28   0:00 sshd: sqw@pts/13
root     14697  0.0  0.0  94928  6924 ?        Ss   Mar28   0:00 sshd: sqw [priv]
sqw      14767  0.0  0.0  94928  3188 ?        S    Mar28   0:00 sshd: sqw@pts/17
root     17631  0.0  0.0  94904  6848 ?        Ss   Mar28   0:00 sshd: sqw [priv]
sqw      17662  0.0  0.0  94904  3996 ?        S    Mar28   0:00 sshd: sqw@pts/22
zhr@iZ2ze37:~$ netstat -tln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 127.0.0.1:7280          0.0.0.0:*               LISTEN  
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
zhr@iZ2ze37:~$ netstat -anltp |grep 7280
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 127.0.0.1:7280          0.0.0.0:*               LISTEN      - 
  • 在A上建立正向代理,用来做转发
    在A(阿里云服务器)上输入ssh -fCNL *:7281:localhost:7280 localhost,其中7281是A负责监听外网的端口,即外网通过7281端口访问;7280是A用以转发请求的端口,内网的B服务器连接到该接口并接受A的转发数据,实现从其他机器访问。
zhr@iZ2ze37:~$ ssh -fCNL *:7281:localhost:7280 
zhr@iZ2ze37:~$ ps aux | grep ssh
root       816  0.0  0.3  59432  6188 ?        Ss   Mar29   0:00 /usr/sbin/sshd -D
root      1058  0.0  0.3  96032  6752 ?        Ss   Mar29   0:00 sshd: zhr [priv]
zhr       1077  0.1  0.2  96488  5592 ?        S    Mar29   1:52 sshd: zhr
root     16004  0.0  0.3  96000  6800 ?        Ss   Mar29   0:00 sshd: zhr [priv]
zhr      16022  0.2  0.2  97080  6000 ?        S    Mar29   2:57 sshd: zhr
root     17792  0.0  0.3  96032  6792 ?        Ss   Mar29   0:00 sshd: zhr [priv]
zhr      17794  0.0  0.1  37640  3312 ?        Ss   Mar29   0:02 ssh -fCNL *:7281:localhost:7280 localhost
zhr      17811  0.0  0.2  96304  5476 ?        S    Mar29   0:02 sshd: zhr
root     17992  0.0  0.3  96004  6896 ?        Ss   Mar29   0:00 sshd: zhr [priv]
zhr      18010  0.0  0.2  96556  5536 ?        S    Mar29   0:02 sshd: zhr
root     18775  0.0  0.3  96032  6752 ?        Ss   10:23   0:00 sshd: zhr [priv]
zhr      18793  0.0  0.1  96032  3324 ?        S    10:23   0:00 sshd: zhr@pts/2
root     18824  0.0  0.3  96032  6968 ?        Ss   10:49   0:00 sshd: zhr [priv]
zhr      18842  0.0  0.1  96032  3416 ?        S    10:49   0:00 sshd: zhr@pts/3
zhr      18865  0.0  0.0  14196   936 pts/3    S+   10:49   0:00 grep --color=auto ssh
  • 连接
    配置好A和B机器,就可以从任意一部外网电脑登陆到B(内网实验室机器)了。这里我直接从A阿里云外网服务器连接到B。
zhr@iZ2ze37:~$ ssh -p7281 ouc02@remote-host  
ouc02@remote-host's password: 
Welcome to Ubuntu 16.04.4 LTS (GNU/Linux 4.15.0-91-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

171 packages can be updated.
0 updates are security updates.

Last login: Sun Mar 29 22:15:45 2020 from 127.0.0.1
(3)免密码登录到A

设置免密码登录到外网服务器
在B上设置ssh-copy-id zhr@remote-host

(4)建立稳定隧道

上述方法并不稳定,超时就会断开。故通过autossh建立稳定隧道,防止超时断开。
注意: ssh认第一个输入指令,autossh前清掉之前的ssh命令(直到连接不上),否则连接会断。

  • 在B(内网实验室服务器)安装autossh(已安装的略过)
    sudo apt-get -y install autossh
  • B终端输入autossh -M 7282 -fCNR 7280:localhost:22 -o ServerAliveInterval=60 -o TCPKeepAlive=yes zhr@remote-host
ouc02@ouc02-X10SRA:~$ autossh -M 7282 -fCNR 7280:localhost:22 -o ServerAliveInterval=60 -o TCPKeepAlive=yes zhr@remote-host
ouc02@ouc02-X10SRA:~$ ps aux | grep ssh
root      1206  0.0  0.0  65512  6184 ?        Ss   Mar27   0:00 /usr/sbin/sshd -D
root      5894  0.0  0.0  95016  6880 ?        Ss   04:13   0:00 sshd: ouc02 [priv]
ouc02     5923  0.0  0.0  95016  3432 ?        S    04:13   0:00 sshd: ouc02@pts/19
ouc02     6775  0.0  0.0   4372    84 ?        Ss   05:32   0:00 /usr/lib/autossh/autossh -M 7282 -CNR  7280:localhost:22 -o ServerAliveInterval=60 -o TCPKeepAlive=yes zhr@remote-host
ouc02     6776  0.0  0.0  45556  6176 ?        S    05:32   0:03 /usr/bin/ssh -L 7282:127.0.0.1:7282 -R 7282:127.0.0.1:7283 -CNR 7280:localhost:22 -o ServerAliveInterval=60 -o TCPKeepAlive=yes zhr@remote-host
root      8252  0.0  0.0  94928  6756 ?        Ss   09:51   0:00 sshd: ouc02 [priv]
ouc02     8277  0.0  0.0  94928  3252 ?        S    09:51   0:00 sshd: ouc02@pts/23
root      8684  0.0  0.0  94928  6816 ?        Ss   09:56   0:00 sshd: ouc02 [priv]
ouc02     8709  0.0  0.0  94928  3388 ?        S    09:56   0:00 sshd: ouc02@pts/24
root      8882  0.0  0.0  94928  6904 ?        Ss   10:05   0:00 sshd: ouc02 [priv]
ouc02     8907  0.0  0.0  94928  3292 ?        S    10:05   0:00 sshd: ouc02@pts/25
ouc02    11795  0.0  0.0  95016  3416 ?        S    21:08   0:00 sshd: ouc02@pts/28
root     11971  0.0  0.0  94928  6892 ?        Ss   21:22   0:00 sshd: ouc02 [priv]
ouc02    14054  0.0  0.0  94928  3312 ?        S    23:31   0:00 sshd: ouc02@pts/34
root     14098  0.0  0.0  94928  6744 ?        Ss   23:33   0:00 sshd: ouc02 [priv]
ouc02    14123  0.0  0.0  94928  3392 ?        S    23:34   0:00 sshd: ouc02@pts/35
ouc02    14171  0.0  0.0  21264   968 pts/35   S+   23:34   0:00 grep --color=auto ssh
(5)配置开机自启

以下写入 /etc/rc.local 的 exit 0 之前

su - lab-user -c autossh -M 7281 -fCNR 7280:localhost:22 -o ServerAliveInterval=60 -o TCPKeepAlive=yes zhr@remote-host

赋予可执行权限

sudo chmod +x /etc/rc.local

参考:https://www.jianshu.com/p/abeb63711e37
http://www.fanyingjie.com/cn/2019/11/ssh_proxy/

4. 挂载硬盘

(1) 命令行中输入sudo fdisk -l
查看挂载的磁盘名字, 比如我要挂载的是/dev/sda。

(2) 输入sudo mount /dev/sda /media/disk1/ 将硬盘挂载到/media/disk1/路径下

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小涵涵

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值