Ubuntu20.04沉浸式装机

Ubuntu20.04沉浸式装机

文章目录

  • Ubuntu20.04沉浸式装机
    • 前言
    • 1.装机之后系统更新,设置软件源
    • 2.安装系统驱动
      • Notice
    • 3 安装CUDA及CuDNN
    • 4 常用软件安装
      • 4.1 常用软件安装
      • 4.2 Typora安装
      • 4.3 docker安装
      • 4.4 nvidia-docker 安装
      • 4.5 pypcd 安装
      • 4.6 PCL安装
        • 环境安装
      • 4.7 Eigen安装
      • 4.8 yaml安装
      • 4.9 卸载libreoffice

前言

最近重装系统比较头疼,反复安装驱动版本都会告警。

每次解决办法都是重装操作系统。

因此,甚是头疼。

痛定思痛,遂整理沉浸式装机shell脚本,可操作操作几个shell脚本,就能轻松完成系统大部分软配置,提高 摸鱼 工作效率!

1.装机之后系统更新,设置软件源

首先进行系统更新,以及设置软件更新源

可以按下列配置设置setup_part1.sh并运行。

因为后面要安装显卡驱动,所以将系统自带的nouveau驱动屏蔽,否则Nvidia驱动无法安装。

#!/usr/bin/env bash

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade


SelectOS()
{
  echo -e "\e[1;35mselect OS:\e[0m"
  echo -e "     1) Ubuntu18.04"
  echo -e "     2) Ubuntu20.04"
}

# 修改软件源
echo -e "\e[1;32m修改软件源\e[0m"
# sudo gedit /etc/apt/sources.list
SelectOS
read -p "Choose OS system, please: " sysType
if [ sysType == 1 ]; then
    sudo echo "deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse" > /etc/apt/sources.list
    sudo echo "deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse" >> /etc/apt/sources.list
    sudo echo "deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse" >> /etc/apt/sources.list
    sudo echo "deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse" >> /etc/apt/sources.list
    sudo echo "deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse" >> /etc/apt/sources.list
    sudo echo "deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse" >> /etc/apt/sources.list
    sudo echo "deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse" >> /etc/apt/sources.list
    sudo echo "deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse" >> /etc/apt/sources.list
    sudo echo "deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse" >> /etc/apt/sources.list
    sudo echo "deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse" >> /etc/apt/sources.list
elif [ sysType == 2 ]; then
    sudo echo "deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse" > /etc/apt/sources.list
    sudo echo "deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse" >> /etc/apt/sources.list
    sudo echo "deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse" >> /etc/apt/sources.list
    sudo echo "deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse" >> /etc/apt/sources.list
    sudo echo "deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse" >> /etc/apt/sources.list
    sudo echo "deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse" >> /etc/apt/sources.list
    sudo echo "deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse" >> /etc/apt/sources.list
    sudo echo "deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse" >> /etc/apt/sources.list
    sudo echo "deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse" >> /etc/apt/sources.list
    sudo echo "deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse" >> /etc/apt/sources.list
fi

# 安装驱动
echo "QCJ-Randy"
echo -e "\e[1;32m禁用系统自带驱动nouveau\e[0m"
# sudo gedit /etc/modprobe.d/blacklist.conf
sudo echo "blacklist nouveau" >> /etc/modprobe.d/blacklist.conf
sudo echo "options nouveau modeset=0" >> /etc/modprobe.d/blacklist.conf
sudo echo "alias nouveau off" >> /etc/modprobe.d/blacklist.conf
sudo echo "alias lbm-nouveau off" >> /etc/modprobe.d/blacklist.conf

sudo update-initramfs -u

echo -e "\e[1;32m请重启电脑:reboot\e[0m"

2.安装系统驱动

可通过ubuntu Software & Updates中的Additional Drivers安装

比如可选择460或470驱动,笔者选择了460。此步骤不装也行,CUDA安装包中包含安装驱动。选择的时候不要选择tested版本,不稳定。

Ubuntu20.04沉浸式装机_第1张图片

点击Apply Changes可进行安装,安装完可输入下面命令查看是否安装成功

# 查看驱动是否安装成功
nvidia-smi

# 10s显示一次
watch -n 10 nvidia-smi

nvidia-smi -l

Ubuntu20.04沉浸式装机_第2张图片

Notice

同一大版本系统(如Ubuntu20.04),不同小版本的系统安装包,会导致系统推荐的显卡驱动也不尽相同,驱动的版本号不一致。

3 安装CUDA及CuDNN

根据自己电脑显卡配置及功能需要安装对应版本的CUDA,如果需要神经网络处理,就安装CuDNN。

相关版本下载脚本:

#!/usr/bin/env bash

wget https://developer.download.nvidia.com/compute/cuda/11.4.0/local_installers/cuda_11.4.0_470.42.01_linux.run
wget https://developer.download.nvidia.com/compute/cuda/11.6.0/local_installers/cuda_11.6.0_510.39.01_linux.run
wget https://developer.download.nvidia.com/compute/cuda/11.7.0/local_installers/cuda_11.7.0_515.43.04_linux.run

具体安装方法,可参考【Ubuntu20.04安装CUDA、cuDNN】:https://blog.csdn.net/weixin_42483745/article/details/124742013

4 常用软件安装

4.1 常用软件安装

首先安装搜狗输入法,提前下好安装包sogoupinyin_4.0.1.2800_x86_64.deb ,再通过下面的脚本一键到底,沉浸式享受基本程序安装。

基本程序包括:搜狗输入法、git、locate、cmake、flameshot、axel、nfs、cloudcompare、clang、filezilla、pcap环境等。

*setup_part2.sh*

#!/usr/bin/env bash

# 常用软件
## 搜狗输入法
sudo apt-get install fcitx
sudo dpkg -i sogoupinyin_4.0.1.2800_x86_64.deb 
sudo cp /usr/share/applications/fcitx.desktop /etc/xdg/autostart/
sudo apt purge ibus
sudo apt install libqt5qml5 libqt5quick5 libqt5quickwidgets5 qml-module-qtquick2
sudo apt install libgsettings-qt1

echo -e  "\e[1;32msetup git\e[0m"
sudo apt install git -y

echo -e "\e[1;32msetup mlocate\e[0m"
sudo apt install mlocate

echo -e "\e[1;32msetup cmake\e[0m"
sudo apt  install cmake -y

echo -e "\e[1;32msetup flameshot\e[0m"
sudo apt-get install flameshot
echo "QCJ-Randy"

echo -e "\e[1;32msetup axel\e[0m"
sudo apt-get install axel

echo -e "\e[1;32msetup nfs\e[0m"
sudo apt-get install nfs-common -y

echo -e "\e[1;32msetup cloudcompare\e[0m"
snap install cloudcompare

echo -e "\e[1;32msetup clang-format\e[0m"
sudo apt-get install clang-format

echo -e "\e[1;32msetup filezilla\e[0m"
sudo apt-get install filezilla
echo "QCJ-Randy"

echo -e "\e[1;32msetup pcap\e[0m"
sudo apt-get install libpcap-dev

4.2 Typora安装

setup_typora.sh

#!/usr/bin/env bash

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BA300B7755AFCFAE
# or use wget -qO - https://typora.io/linux/public-key.asc | sudo apt-key add -

sudo add-apt-repository 'deb http://typora.io linux/'
sudo apt-get update
sudo apt-get install typora
sudo snap install typora
echo "QCJ-Randy"

4.3 docker安装

setup_docker.sh

#!/usr/bin/env bash

green="\e[1;32m"
reset="\e[0m"
purple="\e[1;35m"
bold="\e[1m"
yellow="\e[1;33m"


echo -e "${green}卸载掉系统里的docker${reset}"
sudo apt-get remove docker docker-engine docker.io containerd runc
sudo rm -rf /var/lib/docker

sudo apt-get update
echo -e "${green}添加HTTPS协议和CA证书${reset}"
sudo apt-get install  apt-transport-https  ca-certificates curl  software-properties-common

echo -e "${green}Add Docker’s official GPG key:${reset}"
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

 echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null


sudo chmod a+r /etc/apt/keyrings/docker.gpg
sudo apt-get update
echo "QCJ-Randy"

echo -e "${green}Install Docker Engine, containerd, and Docker Compose${reset}"
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin


echo -e "${yellow}下列语句写入 /etc/docker/daemon.json 文件中。如文件不存在,则创建一个${reset}"
echo "{"
echo "  \"registry-mirrors\": [\"https://docker.mirrors.ustc.edu.cn\"]"
echo "}"

read -p "modify the file  from upper tips, then input any key." user_status

echo -e "${green}建立docker用户组${reset}"
sudo groupadd docker
echo -e "${green}将当前用户加入 docker 组${reset}"
sudo usermod -aG docker $USER
sudo gpasswd -a $USER docker
echo "QCJ-Randy"
echo -e "${green}更新用户组${reset}"
newgrp docker

echo -e "${green}修改docker权限${reset}"
sudo chmod a+rw /var/run/docker.sock

echo -e "${green}重启终端或重启docker${reset}"
sudo systemctl restart docker

echo -e "${green}查看docker版本${reset}"
echo "QCJ-Randy"
docker version

4.4 nvidia-docker 安装

setup_nvidia-docker.sh

#!/usr/bin/env bash

echo -e "\e[1;32m安装NVIDIA Docker2:\e[0m"

curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
curl -s -L https://nvidia.github.io/nvidia-docker/ubuntu18.04/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update
echo "QCJ-Randy"

echo -e "e[1;32m安装2.0\e[0m"
sudo apt-get install nvidia-docker2

echo -e "e[1;32m重新加载docker守护进程配置\e[0m"
sudo pkill -SIGHUP dockerd

echo -e "e[1;32mnvidia-docker version\e[0m"
echo "QCJ-Randy"
nvidia-docker --version

4.5 pypcd 安装

setup_pypcd.sh

#!/usr/bin/env bash
git clone https://github.com/dimatura/pypcd
cd pypcd
git fetch origin pull/9/head:python3
git checkout python3
python setup.py install
echo "QCJ-Randy"

4.6 PCL安装

环境安装

setup_pcl.sh

#!/usr/bin/env bash
echo "setup pcl environment of pcl"
sudo apt-get update  
sudo apt-get install git build-essential linux-libc-dev
sudo apt-get install cmake cmake-gui
sudo apt-get install libusb-1.0-0-dev libusb-dev libudev-dev
sudo apt-get install mpi-default-dev openmpi-bin openmpi-common 
sudo apt-get install libflann1.9 libflann-dev
sudo apt-get install libeigen3-dev
sudo apt-get install libboost-all-dev
sudo apt-get install libvtk7.1p-qt
sudo apt-get install libvtk7.1p 
sudo apt-get install libvtk7-qt-dev
sudo apt-get install libqhull* libgtest-dev
sudo apt-get install freeglut3-dev pkg-config
sudo apt-get install libxmu-dev libxi-dev
sudo apt-get install mono-complete
sudo apt-get install openjdk-8-jdk openjdk-8-jre
echo "QCJ-Randy"

echo "下载pcl代码"
git clone https://github.com/PointCloudLibrary/pcl.git 
echo "QCJ-Randy"
cd pcl 
mkdir release 
cd release

echo "compile"
cmake -DCMAKE_BUILD_TYPE=None -DCMAKE_INSTALL_PREFIX=/usr \ -DBUILD_GPU=ON-DBUILD_apps=ON -DBUILD_examples=ON \ -DCMAKE_INSTALL_PREFIX=/usr .. 
make  
echo "QCJ-Randy"

4.7 Eigen安装

setup_eigen.sh

git clone https://github.com/eigenteam/eigen-git-mirror
cd eigen-git-mirror
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr ..
sudo make install
echo "QCJ-Randy"

4.8 yaml安装

setup_yaml.sh

git clone https://github.com/jbeder/yaml-cpp
mkdir build
cd build
cmake ..
echo "QCJ-Randy"

cmake -DBUILD_SHARED_LIBS=ON ..
echo "QCJ-Randy"

make
make install

sudo make install
sudo ldconfig
echo "QCJ-Randy"

4.9 卸载libreoffice

remove_libreoffice.sh

#!/usr/bin/env bash

sudo apt remove libreoffice-calc
sudo apt remove libreoffice-draw
sudo apt remove libreoffice-impress
sudo apt remove libreoffice-writer
sudo apt remove libreoffice*
sudo apt  purge libreoffice*
echo "QCJ-Randy"

你可能感兴趣的:(Linux,ubuntu,linux,服务器)