修改apt源

(视网络情况而定,可选)

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak #backup
sudo vi /etc/apt/sources.list

修改/etc/apt/sources.list内容

deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ jammy-backports main restricted universe multiverse

更新

sudo apt-get update -y
sudo apt-get upgrade -y

常用软件安装

sudo apt install openssh-server qemu-guest-agent vim nfs-common nload htop -y

修改IP

sudo cp 01-network-manager-all.yaml 01-network-manager-all.yaml.bak #backup
sudo vi /etc/netplan/01-network-manager-all.yaml

修改/etc/netplan/01-network-manager-all.yaml内容

network:
    ethernets:
        ensX:                                                   #change as reality
            dhcp4: false
            addresses: [192.168.x.xx/24]                        #change as reality
            gateway4: 192.168.x.xx                              #change as reality
            nameservers:
              addresses: [192.168.x.1,114.114.114.114,8.8.8.8]  #change as reality
    version: 2

生效

sudo netplan apply

zsh

网络不好需要代理

#first run in bash
sudo apt install git curl zsh -y
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
#second run in zsh
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/agkozak/zsh-z $ZSH_CUSTOM/plugins/zsh-z
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install
sed -i 's/plugins=(git)/plugins=(git zsh-z zsh-autosuggestions)/' ~/.zshrc
sed -i 's/# DISABLE_AUTO_UPDATE="true"/DISABLE_AUTO_UPDATE="true"/' ~/.zshrc
echo "[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh" >> ~/.zshrc
echo "source ~/.oh-my-zsh/custom/themes/powerlevel10k/powerlevel10k.zsh-theme" >> ~/.zshrc
echo "bindkey ',' autosuggest-accept" >> ~/.zshrc
source ~/.zshrc

Nvidia

driver

sudo ubuntu-drivers autoinstall
sudo reboot now

cuda

安装cuda10.2

sudo sh cuda_10.2.89_440.33.01_linux.run --override --librarypath=/usr/local/cuda-10.2

shell配置文件添加

export CUDA_HOME=/usr/local/cuda
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64
export PATH=${CUDA_HOME}/bin:${PATH}

cudnn

安装cudnn-10.2

tar zxvf cudnn-10.2-linux-x64-v8.0.5.39.tgz
sudo cp cuda/include/cudnn*.h /usr/local/cuda/include 
sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda/lib64 
sudo chmod a+r /usr/local/cuda/include/cudnn*.h /usr/local/cuda/lib64/libcudnn*

挂载共享盘

nfs

sudo mount x.x.x.x:/mnt/data_pool1/share /mnt/share

开机自动挂载

sudo vim /etc/fstab #修改配置

添加一行

x.x.x.x:/mnt/data_pool1/share /mnt/share nfs rw 0 1

smb

#群晖
sudo mount -t cifs -o "username=用户名,password=密码,dir_mode=0777,file_mode=0777,vers=2.0" //x.x.x.x/soft /mnt/soft

docker

基础安装

官方脚本自动安装

curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

nvidia-docker安装

# If you have nvidia-docker 1.0 installed: we need to remove it and all existing GPU containers
docker volume ls -q -f driver=nvidia-docker | xargs -r -I{} -n1 docker ps -q -a -f volume={} | xargs -r docker rm -f
sudo apt-get purge -y nvidia-docker

# Add the package repositories
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
sudo apt-get update

# Install nvidia-docker2 and reload the Docker daemon configuration
sudo apt-get install -y nvidia-docker2
sudo pkill -SIGHUP dockerd

# Test nvidia-smi with the latest official CUDA image
sudo docker run --runtime=nvidia --rm nvidia/cuda:9.0-base nvidia-smi

授权

为当前用户授予docker的sudo执行权限

sudo usermod -aG docker $USER