日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Ubuntu >内容正文

Ubuntu

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

發布時間:2024/3/12 Ubuntu 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 科研工具|Ubuntu 装机那些事(更新中)☺️ 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

目錄

    • Ubuntu 16.04版本,顯卡:GeForce GTX 1070
      • 1.系統安裝
      • 2.顯卡驅動
      • 3.安裝cuda和cudnn
      • 4.更換清華鏡像源
      • 5.安裝anaconda3
      • 6.安裝搜狗輸入法
      • 7. 安裝teamviewer
      • 8.安裝有道詞典
    • Ubuntu18.04版本,顯卡:GeForce GTX 1080Ti
      • 1. 安裝VNC遠程桌面
      • 2、雙網卡不能聯網問題
      • 3. 安裝matlab2018
    • Ubuntu 16.04版本,顯卡:Tesla k40c
      • 1. 顯卡驅動
    • 裝機小tips
      • 1. 裝機時輸入法設置成中文,改成英文。
      • 2. 本地打開服務器端Tensorboard
      • 3.使用阿里云(外網)服務器配置反向端口轉發
            • (1)ssh 參數
            • (2)配置步驟
            • (3)免密碼登錄到A
            • (4)建立穩定隧道
            • (5)配置開機自啟
      • 4. 掛載硬盤

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官網下載驅動

    這里我選擇了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_10.0.130_410.48_linux.run
sudo sh cuda_10.0.130_410.48_linux.run

安裝過程中出現下列選項:

  • 剩余安裝步驟參考教程
  • 最后需要重啟后,再輸入nvcc -V和nvcc --version出現下列界面,安裝成功

    對應cudnn(官網需注冊賬號)下載的7.4.2版本,下載地址:https://developer.nvidia.com/rdp/cudnn-archive

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

  • 教程:https://blog.csdn.net/huangjuegeek/article/details/73556763
  • 在安裝anaconda3之后,默認鏡像還是國外的官方進行,這里換成國內鏡像速度會快很多。鏡像地址和命令:https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/
  • 在jupyter notebook中添加conda環境 https://blog.csdn.net/qq_29936933/article/details/83089198
  • 有時候需要拷貝虛擬環境到別的機器或者新裝好的anaconda3 中,但使用pip時,會出現下面問題
-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/pipwhich python /home/zh/miniconda3/envs/py35/bin/pythonvim /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

  • 官方下載網址https://www.teamviewer.cn/cn/download/linux/,找到相應版本下載,要下載最新版,不然之后總會讓你更新。

  • 32位系統需要添加依賴包(64位不用添加)

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

安裝過程中出現下圖所示錯誤,缺少依賴關系。
執行下面命令修復

sudo apt-get install -f

再執行sudo dpkg -i teamviewer_amd64.deb,顯示如下即安裝成功。

  • 停止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。下載具體信息:

這里下載了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 infowill 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/advantage171 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/路徑下

總結

以上是生活随笔為你收集整理的科研工具|Ubuntu 装机那些事(更新中)☺️的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。