创建 conda 环境

  1. 安装 anaconda 或 miniconda (linux)
1
2
3
4
5
6
7
8
# 下载
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
&& bash Miniconda3-latest-Linux-x86_64.sh -b -p /opt/conda \
&& rm Miniconda3-latest-Linux-x86_64.sh
# 激活
source /opt/conda/bin/activate
# 初始化从conda环境
conda init --all
  1. 创建虚拟环境
1
conda create -n train python=3.9 # 名字train + python 版本3.9
  1. 激活虚拟环境
1
2
3
conda activate train # 激活虚拟环境
conda deactivate # 退出当前虚拟环境到base
conda env list # 查看现有虚拟环境
  1. 设置 pip 路径 (若发现无法直接使用pip,将软件安装如虚拟环境中请输入如下代码)
1
2
alias pip='虚拟环境的位置/bin/pip'
alias pip='/opt/conda/envs/train/bin/pip'
  1. 安装 torch
1
pip install torch==2.3.0+cu121 -f https://download.pytorch.org/whl/torch_stable.html
  1. 配置需要的包
1
2
3
wget -O requirements.txt https://www.pan.hekaiyu.com.cn/d/file/python/env/requirements.txt?sign=SmPNzV5IjN2sZL9p4iDz675aiVM7M4ASiB7JNoq2ceo=:0
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install (包的名字)
  1. 预先下载好的包
1
2
3
4
5
6
7
8
9
10
# 先wget提取下载需要安装的包(或者本地下载上传)
# 后使用 pip 命令进行安装

# flash attention——link: https://github.com/Dao-AILab/flash-attention/releases
wget -O flash_attn.whl https://www.pan.hekaiyu.com.cn/d/file/python/env/flash_attn-2.5.9.post1%2Bcu122torch2.3cxx11abiFALSE-cp39-cp39-linux_x86_64.whl?sign=vLhTjFIATZySJXRgC-DKy1-QPsClehE3wwCL37FCTLs=:0
pip install flash_attn.whl

# deepspeed——link: https://github.com/deepspeedai/DeepSpeed/releases
wget -O deepspeed.whl https://www.pan.hekaiyu.com.cn/d/file/python/env/deepspeed-0.14.2%2Bcu121torch2.3-cp39-cp39-manylinux_2_24_x86_64.whl?sign=hye9A04XMevsNhCRCE1lBMDrsu-jVeWSDg6GvgjDIJc=:0
pip install deepspeed.whl

如何安装 docker

  1. 卸载过期的包
1
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done
  1. 安装必要的包
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

#Add the repository to Apt sources:

echo
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu
$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" |
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
  1. 下载 docker
1
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
  1. 添加用户组
1
sudo usermod -aG docker $USER
  1. 基本使用命令
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
docker images # 查看镜像

# 重启 docker
sudo systemctl daemon-reload
sudo systemctl restart docker

# 测试
docker run hello-world

# 拉去镜像
docker pull ubuntu:20.04 # docker pull [name]:[版本]
# 将制作好的镜像推送至仓库
docker push [name]:[版本]

# 删除镜像
docker rmi [name]

问题

1
docker: Error response from daemon: Get "https://registry-1.docker.io/v2/": EOF

网络无法连接

配置的源

1
sudo vim /etc/docker/daemon.json
1
2
3
4
5
6
7
8
9
{
"registry-mirrors":[
"https://registry.docker-cn.com",
"https://docker.mirrors.ustc.edu.cn",
"https://hub-mirror.c.163.com",
"https://mirror.baidubce.com",
"https://ccr.ccs.tencentyun.com"
]
}

如何设置代理

Github使用指南(待修改)

  1. 将 Git 与 Github 绑定
  • 获取 ssh key
1
cd ~/.ssh
  • 若返回 “no such file or directory” 表明电脑没有ssh key,创建ssh key
1
ssh-keygen -t rsa -C “git账号邮箱”
  • 在 .shh 目录下获取 id_rsa.pub 文件里面存储的是公钥并绑定到到自己的 GitHub 上
  • 在 Git bash 中,输入:
1
ssh -T git@github.com

检查是否绑定成功

  • 配置绑定信息
1
2
git config --global user.name “gitname”
git config --global user.email “git邮箱”
  1. 提交代码
1
2
3
4
5
6
cd /path/to/your/project # 进入本地项目目录
git remote add origin https://github.com/Kaiyu-He/env.git # 关联远程仓库
git init # 初始化 git 仓库
git add . # 提交代码
git commit -m "Local changes"
git push --force origin main # 推送代码
  1. 拉取项目
1
git pull origin main
  1. 获取 github 项目的代码
1
git clone https://github.com/Kaiyu-He/env.git