build_windows_wheels.ps1 1.6 KB
Newer Older
muyangli's avatar
muyangli committed
1
2
3
4
5
6
7
param (
    [string]$PYTHON_VERSION,
    [string]$TORCH_VERSION,
    [string]$CUDA_VERSION,
    [string]$MAX_JOBS = ""
)

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Check if TORCH_VERSION is 2.5 or 2.6 and set the corresponding versions for TORCHVISION and TORCHAUDIO
if ($TORCH_VERSION -eq "2.5") {
    $TORCHVISION_VERSION = "0.20"
    $TORCHAUDIO_VERSION = "2.5"
    Write-Output "TORCH_VERSION is 2.5, setting TORCHVISION_VERSION to $TORCHVISION_VERSION and TORCHAUDIO_VERSION to $TORCHAUDIO_VERSION"
}
elseif ($TORCH_VERSION -eq "2.6") {
    $TORCHVISION_VERSION = "0.21"
    $TORCHAUDIO_VERSION = "2.6"
    Write-Output "TORCH_VERSION is 2.6, setting TORCHVISION_VERSION to $TORCHVISION_VERSION and TORCHAUDIO_VERSION to $TORCHAUDIO_VERSION"
}
else {
    Write-Output "TORCH_VERSION is not 2.5 or 2.6, no changes to versions."
}

muyangli's avatar
muyangli committed
23
# Conda 环境名称
24
$ENV_NAME = "build_env_$PYTHON_VERSION_$TORCH_VERSION"
muyangli's avatar
muyangli committed
25
26
27
28
29
30
31

# 创建 Conda 环境
conda create -y -n $ENV_NAME python=$PYTHON_VERSION
conda activate $ENV_NAME

# 安装依赖
conda install -y ninja setuptools wheel pip
32
pip install --no-cache-dir torch==$TORCH_VERSION torchvision==$TORCHVISION_VERSION torchaudio==$TORCHAUDIO_VERSION --index-url "https://download.pytorch.org/whl/cu$($CUDA_VERSION.Substring(0,2))/"
muyangli's avatar
muyangli committed
33
34
35
36
37
38
39

# 设置环境变量
$env:NUNCHAKU_INSTALL_MODE="ALL"
$env:NUNCHAKU_BUILD_WHEELS="1"
$env:MAX_JOBS=$MAX_JOBS

# 进入当前脚本所在目录并构建 wheels
40
Set-Location -Path "$PSScriptRoot\.."
muyangli's avatar
muyangli committed
41
42
43
44
45
46
if (Test-Path "build") { Remove-Item -Recurse -Force "build" }

python -m build --wheel --no-isolation

# 退出 Conda 环境
conda deactivate
47
conda remove -y -n $ENV_NAME --all
muyangli's avatar
muyangli committed
48
Write-Output "Build complete!"