UV 
安装 
Linux 和 macOS 使用 curl 安装:
bash
curl -LsSf https://astral.sh/uv/install.sh | shWindows 使用 powershell 安装:
powershell
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"也可以使用 pip 安装:
bash
pip install uv配置 
在 Windows 上 UV 默认缓存在 C 盘,这样会导致安装的包无法使用硬链接,影响效率并无法使用 UV 节省空间的优势,可以将缓存目录设置到工作用的盘符上。例如配置环境变量,将缓存目录设置到 D 盘:
ini
UV_CACHE_DIR=D:\.uv-cache用例 
安装 PyTorch:
toml
dependencies = [
    "torch==2.7.0+cu128; sys_platform != 'darwin'",
    "torch==2.7.0+cpu; sys_platform == 'darwin'",
    "torchaudio==2.7.0+cu128; sys_platform != 'darwin'",
    "torchaudio==2.7.0+cpu; sys_platform == 'darwin'",
    "torchvision==0.22.0+cu128; sys_platform != 'darwin'",
    "torchvision==0.22.0+cpu; sys_platform == 'darwin'",
]
[tool.uv.sources]
torch = [
    { index = "pytorch-cpu", marker = "sys_platform == 'darwin'" },
    { index = "pytorch-cu128", marker = "sys_platform != 'darwin'" },
]
torchaudio = [
    { index = "pytorch-cpu", marker = "sys_platform == 'darwin'" },
    { index = "pytorch-cu128", marker = "sys_platform != 'darwin'" },
]
torchvision = [
    { index = "pytorch-cpu", marker = "sys_platform == 'darwin'" },
    { index = "pytorch-cu128", marker = "sys_platform != 'darwin'" },
]
[[tool.uv.index]]
name = "pytorch-cu128"
url = "https://download.pytorch.org/whl/cu128"
explicit = true
[[tool.uv.index]]
name = "pytorch-cpu"
url = "https://download.pytorch.org/whl/cpu"
explicit = true