conda cache clean & pip cache purge
在 bash 里面,ctrl+z 后可以用 fg 返回。
Python 环境篇
uv 环境转 conda 环境
uv 由于有 uv.lock 在,所以其能够完美的把握所有库的信息(甚至可以指定 whl 的 url 和平台信息),而 python 标准的 pyproject.toml 只能粗略的估计依赖。
无论 uv 是装在系统的还是在 conda 环境里面的,uv sync 都只会根据 uv.lock 的信息在 pwd 生成 .venv 文件(local python 环境),不符合我们想要的要求。
而 uv pip install xxx 则是会根据具体情况安装道具体环境里面,如果在本地则安装道本地的 python 解释器,如果在 conda 则安装道 conda 环境。所以我们可以先用 uv 把 uv.lock 导出为 requirements.txt 格式的信息,然后用 uv pip install 安装。
uv export --format requirements.txt --output-file <your_file_name>.txt
uv pip install -r <your_file_name>.txt
这里你导出的 txt 文件很大概率无法用 pip install 安装,因为其包含 hash code,且有一些东西 pip 处理不了。
Conda 静止自启动
conda config --set auto_activate_base false
Conda 装 gcc & g++
可以在 conda 官网找对应的版本下载。
conda install -c conda-forge gcc_linux-64 gxx_linux-64
之后在环境变量下面添加软连接到对应的可执行文件即可。
# 查找 gcc 相关的可执行文件
ls $CONDA_PREFIX/bin | grep gcc
# 找到之后
ln -s <path to gcc> <your path foler>/gcc
但是我非常不推荐这种方法,因为其在编译其他库的时候链接器经常出问题。(如果之后解决了,就在这里填坑,否则感觉真不如直接找管理员要他把 gcc 和 g++ 装上)
代理篇
为了能够快速的设置代理,这里列出我经常用的代理:
Bash 代理设置
proxy_set() {
local port="${1:-7890}"
export http_proxy="http://127.0.0.1:${port}"
export https_proxy="http://127.0.0.1:${port}"
export all_proxy="socks5://127.0.0.1:${port}"
echo -e "Proxy Enabled:"
echo -e "http_proxy=${http_proxy}"
echo -e "https_proxy=${https_proxy}"
echo -e "all_proxy=${all_proxy}"
}
proxy_unset() {
unset http_proxy
unset https_proxy
unset all_proxy
echo "Unset all proxy setting."
}
git_proxy_set() {
local port="${1:-7890}"
git config --global http.proxy "http://127.0.0.1:${port}"
echo -e "Git proxy enabled: port=$(git config --global --get http.proxy)"
}
git_proxy_unset() {
git config --global --unset http.proxy
echo "Unset git proxy"
}
proxy_test() {
curl https://www.google.com.hk
}
Github 代理
Anaconda 代理
在 .condarc 文件中
channels:
- conda-forge
- pytorch
- defaults
show_channel_urls: true
default_channels:
- https://mirrors.bfsu.edu.cn/anaconda/pkgs/main
- https://mirrors.bfsu.edu.cn/anaconda/pkgs/free
- https://mirrors.bfsu.edu.cn/anaconda/pkgs/r
- https://mirrors.bfsu.edu.cn/anaconda/pkgs/msys2
custom_channels:
# For <channel_name> , write /cloud,not /cloud/<channel_name>
conda-forge: https://mirrors.bfsu.edu.cn/anaconda/cloud
pytorch: https://mirrors.bfsu.edu.cn/anaconda/cloud
bioconda: https://mirrors.bfsu.edu.cn/anaconda/cloud
menpo: https://mirrors.bfsu.edu.cn/anaconda/cloud
msys2: https://mirrors.bfsu.edu.cn/anaconda/cloud
peterjc123: https://mirrors.bfsu.edu.cn/anaconda/cloud
nvidia: https://mirrors.zju.edu.cn/anaconda-r
记得 conda clean -i 来清理 index。
Pypi 代理设置
设置中科大镜像
pip config set global.index-url https://mirrors.ustc.edu.cn/pypi/simple
cuda 源,阿里和清华源在 cuda whl 上面都是很久没更新了,南京大学镜像站里面有:
https://mirrors.nju.edu.cn/pytorch/whl/
Docker 代理设置
docker 分为 docker client 和 docker daemon,docker daemon 执行核心操作,所以需要设置的是 docker daemon,让它走代理。
sudo mkdir -p /etc/systemd/system/docker.service.d/
sudo tee /etc/systemd/system/docker.service.d/http-proxy.conf <<EOF
[Service]
Environment="HTTP_PROXY=http://127.0.0.1:7890"
Environment="HTTPS_PROXY=http://127.0.0.1:7890"
Environment="NO_PROXY=localhost,127.0.0.1,.local"
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
其他环境篇
Git
设置 git 默认编辑器
git config --global core.editor "code --wait"
Vim
设置 tab 缩减四格
" show existing tab with 4 spaces width
set tabstop=4
" when indenting with '>', use 4 spaces width
set shiftwidth=4
" On pressing tab, insert 4 spaces
set expandtab
" Enable file type detection and plugin/indent scripts
filetype plugin indent on
" Optional: enable smart indentation for C-like languages
set smartindent
Tmux
这个内容比较多,见我的 github 仓库,背景图片来自 BiliBili 勇者_AAAAA
