Home
Journal-2025
1.8
uv安装有特殊要求的包
uv add flash-attn --no-build-isolation
uv add --editable ./path/to/package
切换CUDA版本
首选使用update-alternatives
,如果不能使用,则可以通过指定环境变量的方式:
cuda_path="/usr/local/cuda-11.7" # or other
export CUDA_HOME="${cuda_path}"
export CUDA_ROOT="${cuda_path}"
export LD_LIBRARY_PATH="${cuda_path}/lib64:${cuda_path}/lib:${LD_LIBRARY_PATH}"
export PATH="${cuda_path}/bin:${PATH}"
uv安装PyTorch最佳实践
-
在系统中安装所需CUDA版本
-
根据PyTorch和CUDA版本需求,在PyTorch官网确定要使用的index
-
在
pyproject.toml
中添加相应源,并指定explicit = true
使得仅torch
相关包使用该源。 例如:
```toml [tool.uv.sources] torch = [{ index = "pytorch-cu121" }] torchvision = [{ index = "pytorch-cu121" }]
[[tool.uv.index]] url = "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple" default = true
[[tool.uv.index]] name = "pytorch-cu121" url = "https://download.pytorch.org/whl/cu121" explicit = true ```
- 执行
uv sync
同步环境
1.7
git打包文件
git可以将工作区打包为压缩包,只包含被跟踪的文件
git archive --output "./output.tar.gz" master # 文件类型通过--output自动推断
对Gradio应用进行反向代理
反代gradio应用时(例如example.com/gradio-demo -> localhost:7860
),由于gradio无法感知到外部url路径,会给出错误的资源url,可以通过设置GRADIO_ROOT_PATH
环境变量解决。ref
server {
listen 80;
server_name example.com www.example.com; # Change this to your domain name
location /gradio-demo/ { # Change this if you'd like to server your Gradio app on a different path
proxy_pass http://127.0.0.1:7860/; # Change this if your Gradio app will be running on a different port
proxy_buffering off;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
1.6
Shell在管道中间复制一份到错误流
command1 | command2 # original
command1 | tee /dev/stderr | command2 # for debug
1.1
\(\text{The Best Year Ever!}\)