uv add flash-attn --no-build-isolation
uv add --editable ./path/to/package
首选使用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}"
-
在系统中安装所需CUDA版本
-
根据PyTorch和CUDA版本需求,在PyTorch官网确定要使用的index
-
在
pyproject.toml
中添加相应源,并指定explicit = true
使得仅torch
相关包使用该源。 例如:[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
同步环境
git可以将工作区打包为压缩包,只包含被跟踪的文件
git archive --output "./output.tar.gz" master # 文件类型通过--output自动推断
反代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;
}
}
command1 | command2 # original
command1 | tee /dev/stderr | command2 # for debug