0%

常见命令

记录了常见的一些命令,包括docker,git,ssh,proxy,scp等。

docker

基础命令

1
2
3
4
5
docker run --gpus all --name LM -it --security-opt seccomp=unconfined -v /home/sunyuanxu/code:/workspace/code -v /raid/sunyuanxu:/workspace/raid nvcr.io/nvidia/pytorch:24.05-py3

docker start <container_id_or_name>

docker exec -it <container_id_or_name> /bin/bash

git

基础命令

Init

1
2
3
4
5
6
git init
git remote add origin url
git add .
git commit -m "Initial commit"
git checkout -b new-branch
git push -u origin new-branch

Branch

1
2
git branch
git branch -r(remote)

Checkout

1
2
git checkout branch_name
git checkout -b local_branch_name origin/remote_branch_name

LFS

处理文件过大问题

1
2
git lfs install
git lfs track "file"
# ssh ## 常见命令

这个命令通过 ssh 进行远程连接,并设置了一个反向代理通道。详细解释如下:

1
ssh -R 7890:localhost:7890 username@ip -p port -A -i ~/.ssh/id_rsa

1. 命令结构

ssh 是用于通过 SSH(Secure Shell)协议进行远程连接的命令。这个命令的各个选项含义如下:

-R 7890:localhost:7890

  • 反向端口转发-R 选项用于创建一个反向端口转发。
    • 7890(左边的部分):这是远程主机(username@ip 这台主机)上的端口号。
    • localhost:这是指向 SSH 客户端机器的主机名,即本地主机(你正在运行这个命令的机器)。
    • 7890(右边的部分):这是本地机器上开放的端口号。
    功能
    • 当你连接到远程主机 username@ip 后,远程主机上的 7890 端口就会被绑定到你的本地机器的 7890 端口。
    • 任何连接到远程主机的 7890 端口的数据流都会通过 SSH 隧道安全地传递到本地主机的 7890 端口。这通常用于在远程主机上通过本地资源进行网络请求。

username@ip

  • 用户名和 IP 地址
    • username:远程主机上的用户名,表示你要用哪个用户身份登录到远程服务器。
    • ip:远程主机的 IP 地址或域名。你通过该地址来连接到远程服务器。

-p port

  • 指定端口
    • -p 用于指定远程主机上的 SSH 服务端口号。默认情况下,SSH 服务器使用端口 22,但有时会改为其他端口以提高安全性。

-A

  • 代理转发
    • -A 选项表示启用 SSH 代理转发(agent forwarding)。代理转发使得你可以在登录远程主机后,通过该远程主机来访问其他服务器而不需要再次输入密码。
    • 这样,当你通过该远程主机再连接其他服务器时,会自动使用你本地的 SSH 密钥,简化连接过程。

-i ~/.ssh/id_rsa

  • 指定私钥文件
    • -i 用于指定一个 SSH 私钥文件路径。
    • ~/.ssh/id_rsa 是存储在你本地的私钥文件,用于身份验证。如果你使用其他名字的私钥文件,你需要修改这里的路径。

安装flash-attn

Install the pre-build wheel list in release page works for me, in my case:

1
pip install https://github.com/Dao-AILab/flash-attention/releases/download/v2.3.3/flash_attn-2.3.3+cu118torch2.0cxx11abiFALSE-cp38-cp38-linux_x86_64.whl

Mac终端代理

  1. 修改!/.zshrc,加入下面的命令
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    # where proxy
    proxy () {
    export http_proxy="http://127.0.0.1:7890"
    export https_proxy="http://127.0.0.1:7890"
    echo "HTTP Proxy on"
    }

    # where noproxy
    noproxy () {
    unset http_proxy
    unset https_proxy
    echo "HTTP Proxy off"
    }
  2. source ~/.zshrc
  3. proxy(you will see "HTTP Proxy on")
  4. curl ipinfo.io(查看当前的IP)

scp

两个服务器之间传输

1
scp -3 sun:/raid/sunyuanxu/jsonl_sum/sum.jsonl code:/share/sunyuanxu/maxcoverage(配合~/.ssh/config使用)