From 23e0529461d2913e05d09689f820401d27b96c9a Mon Sep 17 00:00:00 2001 From: nite Date: Tue, 14 Jul 2026 15:30:53 +0800 Subject: [PATCH] fix: lock PyTorch CUDA builds for transcription --- SKILL.md | 2 +- references/windows-funasr-uv-setup.md | 24 +++++++++ scripts/transcription/pyproject.toml | 13 +++++ scripts/transcription/uv.lock | 77 +++++++++++++++++++++------ 4 files changed, 98 insertions(+), 18 deletions(-) diff --git a/SKILL.md b/SKILL.md index 47fe2d0..ecd2aea 100644 --- a/SKILL.md +++ b/SKILL.md @@ -291,7 +291,7 @@ Use whatever vision capability the agent's runtime provides to analyze extracted - **Which model** to use (depends on the agent's runtime and available vision capabilities). - **Batch size** — depends on the model's context window. See `references/frame-extraction-guide.md` for token cost estimates at different resolutions. -- **Windows setup troubleshooting** — see `references/windows-funasr-uv-setup.md` for Windows-host PowerShell transcription commands and uv/Python wheel issues such as `editdistance` source builds. +- **Windows setup troubleshooting** — see `references/windows-funasr-uv-setup.md` for Windows-host PowerShell transcription commands, Python wheel issues such as `editdistance` source builds, and PyTorch CUDA-vs-CPU build checks. - **How many frames** per analysis pass — use the binary-search approach from Step 6. **Completion criteria:** the agent has enough visual understanding to answer the user's question or produce the requested edit plan. diff --git a/references/windows-funasr-uv-setup.md b/references/windows-funasr-uv-setup.md index 139b505..ec4c0b9 100644 --- a/references/windows-funasr-uv-setup.md +++ b/references/windows-funasr-uv-setup.md @@ -36,6 +36,30 @@ Get-Content $Log -Tail 160 From WSL, wrap this in `powershell.exe -NoProfile -ExecutionPolicy Bypass -Command '...'`. +## PyTorch CUDA build pitfall + +If `funasr-nano` logs `on cpu` on a Windows NVIDIA machine, check PyTorch: + +```powershell +$TransDir = "$env:USERPROFILE\video-edit-planner-skill\scripts\transcription" +Set-Location $TransDir +uv run python -c "import torch; print(torch.__version__); print(torch.version.cuda); print(torch.cuda.is_available()); print(torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'no cuda')" +``` + +If this prints `+cpu`, `None`, and `False`, the environment has CPU-only PyTorch. Do **not** fix this with a one-off `uv pip install --torch-backend=auto` unless the project lock/config is also updated: `uv run` will sync from `uv.lock` and may immediately uninstall the CUDA build and reinstall the CPU build. + +This project configures `torch` and `torchaudio` to use the PyTorch `cu130` index on Linux/Windows via `[tool.uv.sources]`. After pulling a version that includes that configuration, rebuild the environment with: + +```powershell +$TransDir = "$env:USERPROFILE\video-edit-planner-skill\scripts\transcription" +Set-Location $TransDir +git pull +uv sync --reinstall +uv run python -c "import torch; print(torch.__version__); print(torch.version.cuda); print(torch.cuda.is_available()); print(torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'no cuda')" +``` + +Expected on an NVIDIA Windows host: `torch` version contains `+cu130`, `torch.version.cuda` is not `None`, and `torch.cuda.is_available()` is `True`. + ## `editdistance` / Python version pitfall Observed failure: diff --git a/scripts/transcription/pyproject.toml b/scripts/transcription/pyproject.toml index b9dc3a8..642a9bb 100644 --- a/scripts/transcription/pyproject.toml +++ b/scripts/transcription/pyproject.toml @@ -17,6 +17,19 @@ funasr-nano = "funasr_nano:main" funasr-fast = "funasr_fast:main" funasr-regular = "funasr_regular:main" +[[tool.uv.index]] +name = "pytorch-cu130" +url = "https://download.pytorch.org/whl/cu130" +explicit = true + +[tool.uv.sources] +torch = [ + { index = "pytorch-cu130", marker = "sys_platform == 'linux' or sys_platform == 'win32'" }, +] +torchaudio = [ + { index = "pytorch-cu130", marker = "sys_platform == 'linux' or sys_platform == 'win32'" }, +] + [build-system] requires = ["setuptools>=69"] build-backend = "setuptools.build_meta" diff --git a/scripts/transcription/uv.lock b/scripts/transcription/uv.lock index 0f3e2a7..da75d03 100644 --- a/scripts/transcription/uv.lock +++ b/scripts/transcription/uv.lock @@ -1,6 +1,10 @@ version = 1 revision = 3 requires-python = "==3.12.*" +resolution-markers = [ + "sys_platform == 'linux' or sys_platform == 'win32'", + "sys_platform != 'linux' and sys_platform != 'win32'", +] [[package]] name = "aliyun-python-sdk-core" @@ -336,16 +340,20 @@ source = { editable = "." } dependencies = [ { name = "funasr" }, { name = "soundfile" }, - { name = "torch" }, - { name = "torchaudio" }, + { name = "torch", version = "2.13.0", source = { registry = "https://pypi.org/simple" }, marker = "sys_platform != 'linux' and sys_platform != 'win32'" }, + { name = "torch", version = "2.13.0+cu130", source = { registry = "https://download.pytorch.org/whl/cu130" }, marker = "sys_platform == 'linux' or sys_platform == 'win32'" }, + { name = "torchaudio", version = "2.11.0", source = { registry = "https://pypi.org/simple" }, marker = "sys_platform != 'linux' and sys_platform != 'win32'" }, + { name = "torchaudio", version = "2.11.0+cu130", source = { registry = "https://download.pytorch.org/whl/cu130" }, marker = "sys_platform == 'linux' or sys_platform == 'win32'" }, ] [package.metadata] requires-dist = [ { name = "funasr", specifier = ">=1.3.14" }, { name = "soundfile", specifier = ">=0.13.1" }, - { name = "torch", specifier = ">=2.13.0" }, - { name = "torchaudio", specifier = ">=2.11.0" }, + { name = "torch", marker = "sys_platform != 'linux' and sys_platform != 'win32'", specifier = ">=2.13.0" }, + { name = "torch", marker = "sys_platform == 'linux' or sys_platform == 'win32'", specifier = ">=2.13.0", index = "https://download.pytorch.org/whl/cu130" }, + { name = "torchaudio", marker = "sys_platform != 'linux' and sys_platform != 'win32'", specifier = ">=2.11.0" }, + { name = "torchaudio", marker = "sys_platform == 'linux' or sys_platform == 'win32'", specifier = ">=2.11.0", index = "https://download.pytorch.org/whl/cu130" }, ] [[package]] @@ -1291,27 +1299,49 @@ wheels = [ name = "torch" version = "2.13.0" source = { registry = "https://pypi.org/simple" } +resolution-markers = [ + "sys_platform != 'linux' and sys_platform != 'win32'", +] dependencies = [ - { name = "cuda-bindings", marker = "sys_platform == 'linux'" }, - { name = "cuda-toolkit", extra = ["cublas", "cudart", "cufft", "cufile", "cupti", "curand", "cusolver", "cusparse", "nvjitlink", "nvrtc", "nvtx"], marker = "sys_platform == 'linux'" }, { name = "filelock" }, { name = "fsspec" }, { name = "jinja2" }, { name = "networkx" }, - { name = "nvidia-cudnn-cu13", marker = "sys_platform == 'linux'" }, - { name = "nvidia-cusparselt-cu13", marker = "sys_platform == 'linux'" }, - { name = "nvidia-nccl-cu13", marker = "sys_platform == 'linux'" }, - { name = "nvidia-nvshmem-cu13", marker = "sys_platform == 'linux'" }, { name = "setuptools" }, { name = "sympy" }, - { name = "triton", marker = "sys_platform == 'linux'" }, { name = "typing-extensions" }, ] wheels = [ { url = "https://files.pythonhosted.org/packages/c4/3a/ed0f4d4d1dcde03bced7aac9a28e800abcdc0cbd06b6775044c9fbd877b7/torch-2.13.0-cp312-cp312-macosx_14_0_arm64.whl", hash = "sha256:2fe228aba290d14b9f31b049be550dbd469c3fd3013d7a19705b30454da97027", size = 111213045, upload-time = "2026-07-08T16:05:22.997Z" }, - { url = "https://files.pythonhosted.org/packages/df/a9/f6a2a4d763ff1df02e9a64c477029db614295bc9367f4131223791ccc243/torch-2.13.0-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:572df8be8ffb4599c88cbd6a0726f1f854f4da65d2e3c09f0e2c2283333cd6d4", size = 427210998, upload-time = "2026-07-08T16:04:37.708Z" }, - { url = "https://files.pythonhosted.org/packages/f3/82/fea946351658e6534db52d2cc12bc53087cbf87f9440c5f180f367c1950b/torch-2.13.0-cp312-cp312-manylinux_2_28_x86_64.whl", hash = "sha256:796633c4cdf0fe2cdced72d8f88f22e73dbcfce83132763162f6d4bff13b820b", size = 526605292, upload-time = "2026-07-08T16:04:22.81Z" }, - { url = "https://files.pythonhosted.org/packages/21/d6/e8f3c6f7e01f626f77259de9860d2a78bc84c40539e28e79b7e98b0bb659/torch-2.13.0-cp312-cp312-win_amd64.whl", hash = "sha256:024c6cc0c1b085f2f91f20a3dc27b0471d021c31ce84b81be3afdc39f791fd9d", size = 122057313, upload-time = "2026-07-08T16:03:53.43Z" }, +] + +[[package]] +name = "torch" +version = "2.13.0+cu130" +source = { registry = "https://download.pytorch.org/whl/cu130" } +resolution-markers = [ + "sys_platform == 'linux' or sys_platform == 'win32'", +] +dependencies = [ + { name = "cuda-bindings", marker = "sys_platform != 'win32'" }, + { name = "cuda-toolkit", extra = ["cublas", "cudart", "cufft", "cufile", "cupti", "curand", "cusolver", "cusparse", "nvjitlink", "nvrtc", "nvtx"], marker = "sys_platform != 'win32'" }, + { name = "filelock" }, + { name = "fsspec" }, + { name = "jinja2" }, + { name = "networkx" }, + { name = "nvidia-cudnn-cu13", marker = "sys_platform != 'win32'" }, + { name = "nvidia-cusparselt-cu13", marker = "sys_platform != 'win32'" }, + { name = "nvidia-nccl-cu13", marker = "sys_platform != 'win32'" }, + { name = "nvidia-nvshmem-cu13", marker = "sys_platform != 'win32'" }, + { name = "setuptools" }, + { name = "sympy" }, + { name = "triton", marker = "sys_platform != 'win32'" }, + { name = "typing-extensions" }, +] +wheels = [ + { url = "https://download-r2.pytorch.org/whl/cu130/torch-2.13.0%2Bcu130-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:5ebd552c887e707c8e64927aceb8377ca2e81588c4e7494bcd23cb8ac0aca14d", upload-time = "2026-07-08T20:24:19Z" }, + { url = "https://download-r2.pytorch.org/whl/cu130/torch-2.13.0%2Bcu130-cp312-cp312-manylinux_2_28_x86_64.whl", hash = "sha256:8db7338e6895c3d4bd89a02ff4209507d1f0cf2ffeb3b898538b5a07d1ea8c1e", upload-time = "2026-07-08T20:24:52Z" }, + { url = "https://download-r2.pytorch.org/whl/cu130/torch-2.13.0%2Bcu130-cp312-cp312-win_amd64.whl", hash = "sha256:2efab1e83604ca628c6d85b9e188c153690980498d1297081a9dad704919303c", upload-time = "2026-07-08T20:26:27Z" }, ] [[package]] @@ -1331,11 +1361,24 @@ wheels = [ name = "torchaudio" version = "2.11.0" source = { registry = "https://pypi.org/simple" } +resolution-markers = [ + "sys_platform != 'linux' and sys_platform != 'win32'", +] wheels = [ { url = "https://files.pythonhosted.org/packages/f1/b1/77658817acacd01a72b714440c62f419efc4d90170e704e8e7a2c0918988/torchaudio-2.11.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:a1cf1acc883bee9cb906a933572fed6a8a933f86ef34e9ea7d803f72317e8c1b", size = 684226, upload-time = "2026-03-23T18:13:40.023Z" }, - { url = "https://files.pythonhosted.org/packages/78/28/c7adc053039f286c2aca0038b766cbe3294e66fec6b29a820e95128f9ede/torchaudio-2.11.0-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:bc653defca1c16154398517a1adc98d0fb7f1dd08e58ced217558d213c2c6e29", size = 1626670, upload-time = "2026-03-23T18:13:42.162Z" }, - { url = "https://files.pythonhosted.org/packages/88/d8/d6d0f896e064aa67377484efef4911cdcc07bce2929474e1417cc0af18c2/torchaudio-2.11.0-cp312-cp312-manylinux_2_28_x86_64.whl", hash = "sha256:6503c0bdb29daf2e6281bb70ea2dfe2c3553b782b619eb5d73bdadd8a3f7cecf", size = 1771992, upload-time = "2026-03-23T18:13:33.188Z" }, - { url = "https://files.pythonhosted.org/packages/23/a8/941277ecc39f7a0a169d554302a1f1afd87c1d94a8aec828891916cea59a/torchaudio-2.11.0-cp312-cp312-win_amd64.whl", hash = "sha256:478110f981e5d40a8d82221732c57a56c85a1d5895fb8fe646e86ee15eded3bd", size = 328663, upload-time = "2026-03-23T18:13:19.218Z" }, +] + +[[package]] +name = "torchaudio" +version = "2.11.0+cu130" +source = { registry = "https://download.pytorch.org/whl/cu130" } +resolution-markers = [ + "sys_platform == 'linux' or sys_platform == 'win32'", +] +wheels = [ + { url = "https://download-r2.pytorch.org/whl/cu130/torchaudio-2.11.0%2Bcu130-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:7171f810887e7cd1a4763974d5a1f2e1466692404315bb70705e0f49fb3a28e0", upload-time = "2026-03-23T15:50:26Z" }, + { url = "https://download-r2.pytorch.org/whl/cu130/torchaudio-2.11.0%2Bcu130-cp312-cp312-manylinux_2_28_x86_64.whl", hash = "sha256:3fba988f4301fe13547fe5e99c76d9ae36a27e19ded82eeffed9d2456e12edef", upload-time = "2026-03-23T15:50:26Z" }, + { url = "https://download-r2.pytorch.org/whl/cu130/torchaudio-2.11.0%2Bcu130-cp312-cp312-win_amd64.whl", hash = "sha256:f74949f9ace1e4a6cf9468bdb3211b9cfa0af6ea348125471ac71c8621d6c77d", upload-time = "2026-03-23T15:50:26Z" }, ] [[package]]