conda环境下cannot write keep file问题解决

1 问题描述

conda环境下执行如下命令报错:

pip install git+https://github.com/wenet-e2e/wenet.git

错误信息如下:

(pt) PS D:\code\ptcontainer> pip install git+https://github.com/wenet-e2e/wenet.git
Looking in indexes: http://pypi.douban.com/simple/
Collecting git+https://github.com/wenet-e2e/wenet.git
  Cloning https://github.com/wenet-e2e/wenet.git to c:\users\admin\appdata\local\temp\pip-req-build-r5q7hfto
  Running command git clone --filter=blob:none --quiet https://github.com/wenet-e2e/wenet.git 'C:\Users\Admin\AppData\Local\Temp\pip-req-build-r5q7hfto'
  Resolved https://github.com/wenet-e2e/wenet.git to commit bb199477e7796abb5aadf8ac61ed722d8f94e4c0
  Running command git submodule update --init --recursive -q
  fatal: cannot write keep file 'C:/Users/Admin/AppData/Local/Temp/pip-req-build-r5q7hfto/.git/modules/runtime/gpu/tensorrt_fastertransformer/FasterTransformer/modules/examples/pytorch/swin/Swin-Transformer-Quantization/SwinTransform
er/objects/pack/pack-dded9f2d76bacec32d64839e8151f21651dfadd4.keep': Filename too long
  fatal: fetch-pack: invalid index-pack output
  fatal: clone of 'https://github.com/microsoft/Swin-Transformer' into submodule path 'C:/Users/Admin/AppData/Local/Temp/pip-req-build-r5q7hfto/runtime/gpu/tensorrt_fastertransformer/FasterTransformer/examples/pytorch/swin/Swin-Trans
former-Quantization/SwinTransformer' failed
  Failed to clone 'examples/pytorch/swin/Swin-Transformer-Quantization/SwinTransformer'. Retry scheduled
  fatal: cannot write keep file 'C:/Users/Admin/AppData/Local/Temp/pip-req-build-r5q7hfto/.git/modules/runtime/gpu/tensorrt_fastertransformer/FasterTransformer/modules/examples/pytorch/swin/Swin-Transformer-Quantization/SwinTransform
er/objects/pack/pack-dded9f2d76bacec32d64839e8151f21651dfadd4.keep': Filename too long
  fatal: fetch-pack: invalid index-pack output
  fatal: clone of 'https://github.com/microsoft/Swin-Transformer' into submodule path 'C:/Users/Admin/AppData/Local/Temp/pip-req-build-r5q7hfto/runtime/gpu/tensorrt_fastertransformer/FasterTransformer/examples/pytorch/swin/Swin-Trans
former-Quantization/SwinTransformer' failed
  fatal: Failed to recurse into submodule path 'runtime/gpu/tensorrt_fastertransformer/FasterTransf
Traceback (most recent call last): File "/home/tongjinghui/miniconda3/envs/ldm/lib/python3.8/site-packages/urllib3/connection.py", line 199, in _new_conn sock = connection.create_connection( File "/home/tongjinghui/miniconda3/envs/ldm/lib/python3.8/site-packages/urllib3/util/connection.py", line 85, in create_connection raise err File "/home/tongjinghui/miniconda3/envs/ldm/lib/python3.8/site-packages/urllib3/util/connection.py", line 73, in create_connection sock.connect(sa) TimeoutError: [Errno 110] Connection timed out The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/tongjinghui/miniconda3/envs/ldm/lib/python3.8/site-packages/urllib3/connectionpool.py", line 789, in urlopen response = self._make_request( File "/home/tongjinghui/miniconda3/envs/ldm/lib/python3.8/site-packages/urllib3/connectionpool.py", line 490, in _make_request raise new_e File "/home/tongjinghui/miniconda3/envs/ldm/lib/python3.8/site-packages/urllib3/connectionpool.py", line 466, in _make_request self._validate_conn(conn) File "/home/tongjinghui/miniconda3/envs/ldm/lib/python3.8/site-packages/urllib3/connectionpool.py", line 1095, in _validate_conn conn.connect() File "/home/tongjinghui/miniconda3/envs/ldm/lib/python3.8/site-packages/urllib3/connection.py", line 693, in connect self.sock = sock = self._new_conn() File "/home/tongjinghui/miniconda3/envs/ldm/lib/python3.8/site-packages/urllib3/connection.py", line 214, in _new_conn raise NewConnectionError( urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x700e0108ca30>: Failed to establish a new connection: [Errno 110] Connection timed out The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/tongjinghui/miniconda3/envs/ldm/lib/python3.8/site-packages/requests/adapters.py", line 667, in send resp = conn.urlopen( File "/home/tongjinghui/miniconda3/envs/ldm/lib/python3.8/site-packages/urllib3/connectionpool.py", line 843, in urlopen retries = retries.increment( File "/home/tongjinghui/miniconda3/envs/ldm/lib/python3.8/site-packages/urllib3/util/retry.py", line 519, in increment raise MaxRetryError(_pool, url, reason) from reason # type: ignore[arg-type] urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /api/models/bert-base-uncased/revision/main (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x700e0108ca30>: Failed to establish a new connection: [Errno 110] Connection timed out')) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/tongjinghui/miniconda3/envs/ldm/lib/python3.8/site-packages/huggingface_hub/_snapshot_download.py", line 165, in snapshot_download repo_info = api.repo_info(repo_id=repo_id, repo_type=repo_type, revision=revision) File "/home/tongjinghui/miniconda3/envs/ldm/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn return fn(*args, **kwargs) File "/home/tongjinghui/miniconda3/envs/ldm/lib/python3.8/site-packages/huggingface_hub/hf_api.py", line 2867, in repo_info return method( File "/home/tongjinghui/miniconda3/envs/ldm/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn return fn(*args, **kwargs) File "/home/tongjinghui/miniconda3/envs/ldm/lib/python3.8/site-packages/huggingface_hub/hf_api.py", line 2660, in model_info r = get_session().get(path, headers=headers, timeout=timeout, params=params) File "/home/tongjinghui/miniconda3/envs/ldm/lib/python3.8/site-packages/requests/sessions.py", line 602, in get return self.request("GET", url, **kwargs) File "/home/tongjinghui/miniconda3/envs/ldm/lib/python3.8/site-packages/requests/sessions.py", line 589, in request resp = self.send(prep, **send_kwargs) File "/home/tongjinghui/miniconda3/envs/ldm/lib/python3.8/site-packages/requests/sessions.py", line 703, in send r = adapter.send(request, **kwargs) File "/home/tongjinghui/miniconda3/envs/ldm/lib/python3.8/site-packages/huggingface_hub/utils/_http.py", line 95, in send return super().send(request, *args, **kwargs) File "/home/tongjinghui/miniconda3/envs/ldm/lib/python3.8/site-packages/requests/adapters.py", line 700, in send raise ConnectionError(e, request=request) requests.exceptions.ConnectionError: (MaxRetryError("HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /api/models/bert-base-uncased/revision/main (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x700e0108ca30>: Failed to establish a new connection: [Errno 110] Connection timed out'))"), '(Request ID: 130540d9-ad3f-4c6a-b39d-5387379271c1)') The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/tongjinghui/miniconda3/envs/ldm/bin/hf", line 8, in <module> sys.exit(main()) File "/home/tongjinghui/miniconda3/envs/ldm/lib/python3.8/site-packages/huggingface_hub/cli/hf.py", line 59, in main service.run() File "/home/tongjinghui/miniconda3/envs/ldm/lib/python3.8/site-packages/huggingface_hub/cli/download.py", line 136, in run print(self._download()) # Print path to downloaded files File "/home/tongjinghui/miniconda3/envs/ldm/lib/python3.8/site-packages/huggingface_hub/cli/download.py", line 169, in _download return snapshot_download( File "/home/tongjinghui/miniconda3/envs/ldm/lib/python3.8/site-packages/huggingface_hub/utils/_validators.py", line 114, in _inner_fn return fn(*args, **kwargs) File "/home/tongjinghui/miniconda3/envs/ldm/lib/python3.8/site-packages/huggingface_hub/_snapshot_download.py", line 248, in snapshot_download raise LocalEntryNotFoundError( huggingface_hub.errors.LocalEntryNotFoundError: An error happened while trying to locate the files on the Hub and we cannot find the appropriate snapshot folder for the specified revision on the local disk. Please check your internet connection and try again.
最新发布
10-29
PowerShell 7 环境已加载 (版本: 7.5.2) PS C:\Users\Administrator\Desktop> cd E:\PyTorch_Build\pytorch PS E:\PyTorch_Build\pytorch> python -m venv rtx5070_env PS E:\PyTorch_Build\pytorch> .\rtx5070_env\Scripts\activate (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 创建终极修复脚本: build_absolute_fix.ps1 (rtx5070_env) PS E:\PyTorch_Build\pytorch> @' >> # ------ 初始化 ------ >> $ErrorActionPreference = "Stop" >> Write-Host "=== PyTorch 终极解决方案 ===" -ForegroundColor Cyan >> Write-Host "开始时间: $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" >> $logFile = "$PWD\build_log_$(Get-Date -Format 'yyyyMMdd_HHmmss').txt" >> Start-Transcript -Path $logFile -Append >> >> # ------ 强制设置开发环境 ------ >> $env:DeveloperMode = 1 >> $env:CMAKE_GENERATOR = "Ninja" >> >> # ------ 路径配置 ------ >> $pythonEnv = "E:\PyTorch_Build\pytorch\rtx5070_env" >> $cudaPath = "E:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0" >> $cudnnBasePath = "E:\Program Files\NVIDIA\CUNND\v9.12" >> $cudaVersion = "13.0" >> $vsPath = "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools" # 确保正确路径 >> >> # ------ 确保Visual Studio工具在PATH中 ------ >> $env:Path = ` >> "$vsPath\VC\Tools\MSVC\14.44.35207\bin\Hostx64\x64;" + ` >> "$vsPath\Common7\IDE;" + ` >> "$cudaPath\bin;" + ` >> $env:Path >> >> # ------ 修复cuDNN检测 ------ >> function Get-ProperCudnnPath { >> $headerPath = "E:\Program Files\NVIDIA\CUNND\v9.12\include\13.0" >> $libraryPath = "E:\Program Files\NVIDIA\CUNND\v9.12\lib\13.0\x64\cudnn64_9.lib" >> $dllPath = "E:\Program Files\NVIDIA\CUNND\v9.12\bin\13.0\cudnn64_9.dll" >> >> if (-not (Test-Path $headerPath)) { >> throw "cuDNN头文件路径不存在: $headerPath" >> } >> if (-not (Test-Path $libraryPath)) { >> throw "cuDNN库文件路径不存在: $libraryPath" >> } >> if (-not (Test-Path $dllPath)) { >> throw "cuDNN DLL文件路径不存在: $dllPath" >> } >> >> return @{ >> IncludeDir = $headerPath >> Library = $libraryPath >> BinDir = [System.IO.Path]::GetDirectoryName($dllPath) >> } >> } >> >> Write-Host "`n=== 硬编码cuDNN路径 ===" -ForegroundColor Yellow >> $cudnn = Get-ProperCudnnPath >> Write-Host "cuDNN头文件: $($cudnn.IncludeDir)" >> Write-Host "cuDNN库文件: $($cudnn.Library)" >> Write-Host "cuDNN DLL目录: $($cudnn.BinDir)" >> >> # ------ 环境配置 ------ >> Write-Host "`n=== 配置环境变量 ===" -ForegroundColor Green >> $env:CUDA_PATH = $cudaPath >> $env:Path = "$cudaPath\bin;$($cudnn.BinDir);$env:Path" >> $env:CUDNN_INCLUDE_DIR = $cudnn.IncludeDir >> $env:CUDNN_LIBRARY = $cudnn.Library >> $env:TORCH_CUDA_ARCH_LIST = "8.9" >> >> # 调试信息 >> Write-Host "环境变量检查:" >> Write-Host "CUDA_PATH: $env:CUDA_PATH" >> Write-Host "CUDNN_INCLUDE_DIR: $env:CUDNN_INCLUDE_DIR" >> Write-Host "CUDNN_LIBRARY: $env:CUDNN_LIBRARY" >> Write-Host "PATH: $($env:Path -split ';' | Select-Object -First 10)..." >> >> # ------ 激活Python环境 ------ >> Write-Host "`n=== 激活Python环境 ===" -ForegroundColor Magenta >> . "$pythonEnv\Scripts\Activate.ps1" >> Write-Host "✅ Python虚拟环境已激活" -ForegroundColor Green >> Write-Host "Python版本: $(python --version)" >> Write-Host "Pip版本: $(pip --version)" >> >> # ------ 强制清理 ------ >> Write-Host "`n=== 深度清理构建缓存 ===" -ForegroundColor Red >> python setup.py clean >> Remove-Item -Recurse -Force build, dist, torch\lib, cmake_build -ErrorAction SilentlyContinue >> Remove-Item -Force *.ncb, *.sdf, *.suo -ErrorAction SilentlyContinue >> >> # ------ 安装依赖 ------ >> Write-Host "`n=== 安装核心依赖 ===" -ForegroundColor Yellow >> pip install -U pip setuptools wheel ninja cmake==3.28.7 # 使用稳定版本 >> pip install -r requirements.txt >> >> # ------ 方法4: 直接CMake+Ninja构建 ------ >> Write-Host "`n=== 方法4: 纯CMake+Ninja构建 ===" -ForegroundColor Green >> $buildDir = "$PWD\cmake_release" >> New-Item -ItemType Directory -Path $buildDir -Force | Out-Null >> Set-Location $buildDir >> >> cmake .. -GNinja ` >> -DCMAKE_BUILD_TYPE=Release ` >> -DUSE_CUDA=ON ` >> -DUSE_CUDNN=ON ` >> -DCUDNN_INCLUDE_DIR="$($cudnn.IncludeDir)" ` >> -DCUDNN_LIBRARY="$($cudnn.Library)" ` >> -DPYTHON_EXECUTABLE="$pythonEnv\Scripts\python.exe" ` >> -DCMAKE_INSTALL_PREFIX="$PWD/install" ` >> -DTORCH_CUDA_ARCH_LIST="8.9" ` >> -DCMAKE_MSVC_RESPONSE_FILE=OFF # 解决Windows路径问题 >> >> if ($LASTEXITCODE -ne 0) { >> Write-Host "❌ CMake配置失败" -ForegroundColor Red >> exit 1 >> } >> >> ninja install >> $buildExitCode = $LASTEXITCODE >> Set-Location .. >> >> if ($buildExitCode -eq 0) { >> # ------ 修复运行时依赖 ------ >> $torchLibDir = "$PWD\torch\lib" >> New-Item -ItemType Directory -Path $torchLibDir -Force | Out-Null >> >> # 1. 复制所有CUDA DLL >> Get-ChildItem -Path "$cudaPath\bin\*.dll" | ForEach-Object { >> Copy-Item $_.FullName $torchLibDir -Force >> Write-Host "✅ 复制CUDA DLL: $($_.Name)" >> } >> >> # 2. 复制cuDNN DLL >> Copy-Item "$($cudnn.BinDir)\*.dll" $torchLibDir -Force >> >> # 3. 复制构建生成的DLL >> $buildDlls = Get-ChildItem -Path "$buildDir\lib", "$buildDir\bin" -Recurse -Include *.dll >> foreach ($dll in $buildDlls) { >> Copy-Item $dll.FullName $torchLibDir -Force >> Write-Host "✅ 复制构建DLL: $($dll.Name)" >> } >> >> # 4. 设置Python软链接 >> $installDir = "$buildDir\install" >> $env:PYTHONPATH = "$installDir;$env:PYTHONPATH" >> } >> >> # ------ 验证结果 ------ >> if ($buildExitCode -eq 0) { >> Write-Host "`n=== 验证构建结果 ===" -ForegroundColor Cyan >> $env:Path = "$torchLibDir;$env:Path" >> >> python -c @" >> import os, torch >> print(f'PyTorch版本: {torch.__version__}') >> print(f'CUDA可用: {torch.cuda.is_available()}') >> >> if torch.cuda.is_available(): >> print(f'CUDA版本: {torch.version.cuda}') >> print(f'cuDNN版本: {torch.backends.cudnn.version()}') >> print(f'检测到的GPU: {torch.cuda.get_device_name(0)}') >> >> # 测试基础计算 >> a = torch.randn(1000, 1000, device='cuda') >> b = torch.randn(1000, 1000, device='cuda') >> c = a @ b >> print(f'GPU计算验证: 矩阵乘法成功 (结果形状: {c.shape})') >> >> # 检查关键DLL >> from ctypes import WinDLL >> try: >> WinDLL(os.path.join(torch.__file__, 'lib', 'aoti_custom_ops.dll')) >> print('✅ aoti_custom_ops.dll 加载成功') >> except Exception as e: >> print(f'❌ aoti_custom_ops.dll 加载失败: {str(e)}') >> "@ >> $buildExitCode = $LASTEXITCODE >> } >> >> # ------ 完成报告 ------ >> Write-Host "`n=== 构建报告 ===" -ForegroundColor Cyan >> Write-Host "构建状态: $(if ($buildExitCode -eq 0) {'成功!'} else {'失败'})" -ForegroundColor $(if ($buildExitCode -eq 0) {'Green'} else {'Red'}) >> Write-Host "完成时间: $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" >> >> Stop-Transcript >> exit $buildExitCode >> '@ | Set-Content -Path "build_absolute_fix.ps1" -Encoding UTF8 (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 运行脚本 (rtx5070_env) PS E:\PyTorch_Build\pytorch> Set-ExecutionPolicy Bypass -Scope Process -Force (rtx5070_env) PS E:\PyTorch_Build\pytorch> .\build_absolute_fix.ps1 === PyTorch 终极解决方案 === 开始时间: 2025-09-03 14:24:16 Transcript started, output file is E:\PyTorch_Build\pytorch\build_log_20250903_142416.txt === 硬编码cuDNN路径 === cuDNN头文件: E:\Program Files\NVIDIA\CUNND\v9.12\include\13.0 cuDNN库文件: E:\Program Files\NVIDIA\CUNND\v9.12\lib\13.0\x64\cudnn64_9.lib cuDNN DLL目录: E:\Program Files\NVIDIA\CUNND\v9.12\bin\13.0 === 配置环境变量 === 环境变量检查: CUDA_PATH: E:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0 CUDNN_INCLUDE_DIR: E:\Program Files\NVIDIA\CUNND\v9.12\include\13.0 CUDNN_LIBRARY: E:\Program Files\NVIDIA\CUNND\v9.12\lib\13.0\x64\cudnn64_9.lib PATH: E:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\bin E:\Program Files\NVIDIA\CUNND\v9.12\bin\13.0 C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.44.35207\bin\Hostx64\x64 C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\IDE E:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\bin E:\PyTorch_Build\pytorch\rtx5070_env\Scripts C:\Program Files\PowerShell\7 C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.1\bin C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.1\libnvvp C:\Miniconda3\condabin... === 激活Python环境 === ✅ Python虚拟环境已激活 Python版本: Python 3.10.10 Pip版本: pip 25.2 from E:\PyTorch_Build\pytorch\rtx5070_env\lib\site-packages\pip (python 3.10) === 深度清理构建缓存 === Building wheel torch-2.9.0a0+git2d31c3d E:\PyTorch_Build\pytorch\rtx5070_env\lib\site-packages\setuptools\config\_apply_pyprojecttoml.py:82: SetuptoolsDeprecationWarning: `project.license` as a TOML table is deprecated !! ******************************************************************************** Please use a simple string containing a SPDX expression for `project.license`. You can also use `project.license-files`. (Both options available on setuptools>=77.0.0). By 2026-Feb-18, you need to update your project and remove deprecated calls or your builds will no longer be supported. See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details. ******************************************************************************** !! corresp(dist, value, root_dir) running clean === 安装核心依赖 === Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Requirement already satisfied: pip in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (25.2) Requirement already satisfied: setuptools in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (79.0.1) Collecting setuptools Using cached https://pypi.tuna.tsinghua.edu.cn/packages/a3/dc/17031897dae0efacfea57dfd3a82fdd2a2aeb58e0ff71b77b87e44edc772/setuptools-80.9.0-py3-none-any.whl (1.2 MB) Requirement already satisfied: wheel in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (0.45.1) Requirement already satisfied: ninja in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (1.13.0) ERROR: Ignored the following yanked versions: 3.27.4, 3.28.0, 3.29.0, 3.29.1, 3.31.0 ERROR: Could not find a version that satisfies the requirement cmake==3.28.7 (from versions: 0.1.0, 0.2.0, 0.4.0, 0.5.0, 0.6.0, 0.7.0, 0.7.1, 0.8.0, 0.9.0, 3.6.3, 3.6.3.post1, 3.7.2, 3.8.2, 3.9.6, 3.10.3, 3.11.0, 3.11.4, 3.11.4.post1, 3.12.0, 3.13.0, 3.13.1, 3.13.2, 3.13.2.post1, 3.14.3, 3.14.3.post1, 3.14.4, 3.14.4.post1, 3.15.3, 3.15.3.post1, 3.16.3, 3.16.3.post1, 3.16.5, 3.16.6, 3.16.7, 3.16.8, 3.17.0, 3.17.1, 3.17.2, 3.17.3, 3.18.0, 3.18.2, 3.18.2.post1, 3.18.4, 3.18.4.post1, 3.20.2, 3.20.3, 3.20.4, 3.20.5, 3.21.0, 3.21.1, 3.21.1.post1, 3.21.2, 3.21.3, 3.21.4, 3.22.0, 3.22.1, 3.22.2, 3.22.3, 3.22.4, 3.22.5, 3.22.6, 3.23.3, 3.24.0, 3.24.1, 3.24.1.1, 3.24.2, 3.24.3, 3.25.0, 3.25.2, 3.26.0, 3.26.1, 3.26.3, 3.26.4, 3.27.0, 3.27.1, 3.27.2, 3.27.4.1, 3.27.5, 3.27.6, 3.27.7, 3.27.9, 3.28.1, 3.28.3, 3.28.4, 3.29.0.1, 3.29.2, 3.29.3, 3.29.5, 3.29.5.1, 3.29.6, 3.30.0, 3.30.1, 3.30.2, 3.30.3, 3.30.4, 3.30.5, 3.30.9, 3.31.0.1, 3.31.1, 3.31.2, 3.31.4, 3.31.6, 4.0.0, 4.0.2, 4.0.3, 4.1.0) ERROR: No matching distribution found for cmake==3.28.7 Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Requirement already satisfied: setuptools<80.0,>=70.1.0 in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from -r E:\PyTorch_Build\pytorch\requirements-build.txt (line 2)) (79.0.1) Requirement already satisfied: cmake>=3.27 in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from -r E:\PyTorch_Build\pytorch\requirements-build.txt (line 3)) (4.1.0) Requirement already satisfied: ninja in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from -r E:\PyTorch_Build\pytorch\requirements-build.txt (line 4)) (1.13.0) Requirement already satisfied: numpy in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from -r E:\PyTorch_Build\pytorch\requirements-build.txt (line 5)) (2.2.6) Requirement already satisfied: packaging in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from -r E:\PyTorch_Build\pytorch\requirements-build.txt (line 6)) (25.0) Requirement already satisfied: pyyaml in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from -r E:\PyTorch_Build\pytorch\requirements-build.txt (line 7)) (6.0.2) Requirement already satisfied: requests in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from -r E:\PyTorch_Build\pytorch\requirements-build.txt (line 8)) (2.32.5) Requirement already satisfied: six in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from -r E:\PyTorch_Build\pytorch\requirements-build.txt (line 9)) (1.17.0) Requirement already satisfied: typing-extensions>=4.10.0 in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from -r E:\PyTorch_Build\pytorch\requirements-build.txt (line 10)) (4.15.0) Requirement already satisfied: expecttest>=0.3.0 in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from -r requirements.txt (line 8)) (0.3.0) Requirement already satisfied: filelock in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from -r requirements.txt (line 9)) (3.19.1) Requirement already satisfied: fsspec>=0.8.5 in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from -r requirements.txt (line 10)) (2025.7.0) Requirement already satisfied: hypothesis in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from -r requirements.txt (line 11)) (6.138.13) Requirement already satisfied: jinja2 in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from -r requirements.txt (line 12)) (3.1.6) Requirement already satisfied: lintrunner in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from -r requirements.txt (line 13)) (0.12.7) Requirement already satisfied: networkx>=2.5.1 in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from -r requirements.txt (line 14)) (3.4.2) Requirement already satisfied: optree>=0.13.0 in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from -r requirements.txt (line 15)) (0.17.0) Requirement already satisfied: psutil in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from -r requirements.txt (line 16)) (7.0.0) Requirement already satisfied: sympy>=1.13.3 in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from -r requirements.txt (line 17)) (1.14.0) Requirement already satisfied: wheel in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from -r requirements.txt (line 19)) (0.45.1) Requirement already satisfied: build[uv] in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from -r requirements.txt (line 7)) (1.3.0) Requirement already satisfied: charset_normalizer<4,>=2 in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from requests->-r E:\PyTorch_Build\pytorch\requirements-build.txt (line 8)) (3.4.3) Requirement already satisfied: idna<4,>=2.5 in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from requests->-r E:\PyTorch_Build\pytorch\requirements-build.txt (line 8)) (3.10) Requirement already satisfied: urllib3<3,>=1.21.1 in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from requests->-r E:\PyTorch_Build\pytorch\requirements-build.txt (line 8)) (2.5.0) Requirement already satisfied: certifi>=2017.4.17 in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from requests->-r E:\PyTorch_Build\pytorch\requirements-build.txt (line 8)) (2025.8.3) Requirement already satisfied: pyproject_hooks in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from build[uv]->-r requirements.txt (line 7)) (1.2.0) Requirement already satisfied: colorama in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from build[uv]->-r requirements.txt (line 7)) (0.4.6) Requirement already satisfied: tomli>=1.1.0 in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from build[uv]->-r requirements.txt (line 7)) (2.2.1) Requirement already satisfied: uv>=0.1.18 in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from build[uv]->-r requirements.txt (line 7)) (0.8.14) Requirement already satisfied: attrs>=22.2.0 in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from hypothesis->-r requirements.txt (line 11)) (25.3.0) Requirement already satisfied: exceptiongroup>=1.0.0 in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from hypothesis->-r requirements.txt (line 11)) (1.3.0) Requirement already satisfied: sortedcontainers<3.0.0,>=2.1.0 in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from hypothesis->-r requirements.txt (line 11)) (2.4.0) Requirement already satisfied: MarkupSafe>=2.0 in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from jinja2->-r requirements.txt (line 12)) (3.0.2) Requirement already satisfied: mpmath<1.4,>=1.1.0 in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from sympy>=1.13.3->-r requirements.txt (line 17)) (1.3.0) === 方法4: 纯CMake+Ninja构建 === CMake Deprecation Warning at CMakeLists.txt:9 (cmake_policy): The OLD behavior for policy CMP0126 will be removed from a future version of CMake. The cmake-policies(7) manual explains that the OLD behaviors of all policies are deprecated and that a policy should be set to OLD only under specific short-term circumstances. Projects should be ported to the NEW behavior and not rely on setting a policy to OLD. -- The CXX compiler identification is GNU 13.2.0 -- The C compiler identification is GNU 13.2.0 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: C:/ProgramData/mingw64/mingw64/bin/c++.exe - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: C:/ProgramData/mingw64/mingw64/bin/gcc.exe - skipped -- Detecting C compile features -- Detecting C compile features - done -- Not forcing any particular BLAS to be found CMake Warning at CMakeLists.txt:421 (message): TensorPipe cannot be used on Windows. Set it to OFF CMake Warning at CMakeLists.txt:423 (message): KleidiAI cannot be used on Windows. Set it to OFF CMake Warning at CMakeLists.txt:435 (message): Libuv is not installed in current conda env. Set USE_DISTRIBUTED to OFF. Please run command 'conda install -c conda-forge libuv=1.39' to install libuv. -- Performing Test C_HAS_AVX_1 -- Performing Test C_HAS_AVX_1 - Failed -- Performing Test C_HAS_AVX_2 -- Performing Test C_HAS_AVX_2 - Success -- Performing Test C_HAS_AVX2_1 -- Performing Test C_HAS_AVX2_1 - Failed -- Performing Test C_HAS_AVX2_2 -- Performing Test C_HAS_AVX2_2 - Success -- Performing Test C_HAS_AVX512_1 -- Performing Test C_HAS_AVX512_1 - Failed -- Performing Test C_HAS_AVX512_2 -- Performing Test C_HAS_AVX512_2 - Success -- Performing Test CXX_HAS_AVX_1 -- Performing Test CXX_HAS_AVX_1 - Failed -- Performing Test CXX_HAS_AVX_2 -- Performing Test CXX_HAS_AVX_2 - Success -- Performing Test CXX_HAS_AVX2_1 -- Performing Test CXX_HAS_AVX2_1 - Failed -- Performing Test CXX_HAS_AVX2_2 -- Performing Test CXX_HAS_AVX2_2 - Success -- Performing Test CXX_HAS_AVX512_1 -- Performing Test CXX_HAS_AVX512_1 - Failed -- Performing Test CXX_HAS_AVX512_2 -- Performing Test CXX_HAS_AVX512_2 - Success -- Current compiler supports avx2 extension. Will build perfkernels. -- Performing Test COMPILER_SUPPORTS_HIDDEN_VISIBILITY -- Performing Test COMPILER_SUPPORTS_HIDDEN_VISIBILITY - Success -- Performing Test COMPILER_SUPPORTS_HIDDEN_INLINE_VISIBILITY -- Performing Test COMPILER_SUPPORTS_HIDDEN_INLINE_VISIBILITY - Success -- Performing Test COMPILER_SUPPORTS_RDYNAMIC -- Performing Test COMPILER_SUPPORTS_RDYNAMIC - Failed -- Could not find hardware support for NEON on this machine. -- No OMAP3 processor on this machine. -- No OMAP4 processor on this machine. -- Compiler does not support SVE extension. Will not build perfkernels. CMake Warning at CMakeLists.txt:841 (message): x64 operating system is required for FBGEMM. Not compiling with FBGEMM. Turn this warning off by USE_FBGEMM=OFF. -- Found CUDA: E:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v13.0 (found version "13.0") CMake Error at rtx5070_env/Lib/site-packages/cmake/data/share/cmake-4.1/Modules/CMakeDetermineCompilerId.cmake:928 (message): Compiling the CUDA compiler identification source file "CMakeCUDACompilerId.cu" failed. Compiler: E:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v13.0/bin/nvcc.exe Build flags: Id flags: --keep;--keep-dir;tmp -v The output was: 1 nvcc fatal : Cannot find compiler 'cl.exe' in PATH Compiling the CUDA compiler identification source file "CMakeCUDACompilerId.cu" failed. Compiler: E:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v13.0/bin/nvcc.exe Build flags: -DLIBCUDACXX_ENABLE_SIMPLIFIED_COMPLEX_OPERATIONS;-Xfatbin;-compress-all Id flags: --keep;--keep-dir;tmp -v The output was: 1 nvcc fatal : Cannot find compiler 'cl.exe' in PATH Call Stack (most recent call first): rtx5070_env/Lib/site-packages/cmake/data/share/cmake-4.1/Modules/CMakeDetermineCompilerId.cmake:8 (CMAKE_DETERMINE_COMPILER_ID_BUILD) rtx5070_env/Lib/site-packages/cmake/data/share/cmake-4.1/Modules/CMakeDetermineCompilerId.cmake:53 (__determine_compiler_id_test) rtx5070_env/Lib/site-packages/cmake/data/share/cmake-4.1/Modules/CMakeDetermineCUDACompiler.cmake:162 (CMAKE_DETERMINE_COMPILER_ID) cmake/public/cuda.cmake:47 (enable_language) cmake/Dependencies.cmake:44 (include) CMakeLists.txt:869 (include) -- Configuring incomplete, errors occurred! ❌ CMake配置失败 为啥一直失败呢 我们现在缺的是什么 你能解释给我听吗
09-04
PowerShell 7 环境已加载 (版本: 7.5.2) PS C:\Users\Administrator\Desktop> cd E:\PyTorch_Build\pytorch PS E:\PyTorch_Build\pytorch> python -m venv rtx5070_env PS E:\PyTorch_Build\pytorch> .\rtx5070_env\Scripts\activate (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 查找最新 Windows SDK 库路径 (rtx5070_env) PS E:\PyTorch_Build\pytorch> $sdkLibPath = @( >> "${env:ProgramFiles(x86)}\Windows Kits\10\Lib", >> "${env:ProgramFiles}\Windows Kits\10\Lib" >> ) | Where-Object { Test-Path $_ } | Select-Object -First 1 (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 获取最新版本路径 (rtx5070_env) PS E:\PyTorch_Build\pytorch> $latestSdkVersion = Get-ChildItem -Path $sdkLibPath | >> Where-Object { $_.Name -match '^\d+\.\d+' } | >> Sort-Object { [version]$_.Name } -Descending | >> Select-Object -First 1 (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> if ($latestSdkVersion) { >> $umPath = Join-Path $latestSdkVersion.FullName "um\x64" >> $ucrtPath = Join-Path $latestSdkVersion.FullName "ucrt\x64" >> >> # 添加到环境变量 >> $env:LIB = "$umPath;$ucrtPath;$env:LIB" >> $env:INCLUDE = "$(Join-Path $latestSdkVersion.FullName 'um');$(Join-Path $latestSdkVersion.FullName 'ucrt');$env:INCLUDE" >> >> Write-Host "已添加 LIB 路径: $umPath, $ucrtPath" >> Write-Host "已添加 INCLUDE 路径: $(Join-Path $latestSdkVersion.FullName 'um')" >> } else { >> Write-Host "错误: 未找到 Windows SDK 库路径" -ForegroundColor Red >> } 已添加 LIB 路径: C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\um\x64, C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\ucrt\x64 已添加 INCLUDE 路径: C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\um (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 验证关键工具可用性 (rtx5070_env) PS E:\PyTorch_Build\pytorch> $tools = @("cl.exe", "link.exe", "rc.exe", "mt.exe", "nvcc.exe") (rtx5070_env) PS E:\PyTorch_Build\pytorch> $missingTools = @() (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> foreach ($tool in $tools) { >> if (-not (Get-Command $tool -ErrorAction SilentlyContinue)) { >> $missingTools += $tool >> } >> } (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> if ($missingTools.Count -gt 0) { >> Write-Host "缺失工具: $($missingTools -join ', ')" -ForegroundColor Red >> Write-Host "当前 PATH: $env:PATH" >> } else { >> Write-Host "所有必要工具已配置" -ForegroundColor Green >> } 缺失工具: cl.exe, link.exe, rc.exe, mt.exe 当前 PATH: E:\PyTorch_Build\pytorch\rtx5070_env\Scripts;C:\Program Files\PowerShell\7;C:\Miniconda3\condabin;C:\Miniconda3\Scripts;E:\PyTorch_Build\pytorch\pytorch_env\Scripts;C:\Program Files\PowerShell\7;E:\PyTorch_Build\pytorch\pytorch_env\Scripts;C:\Program Files\PowerShell\7;E:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\bin\x64;E:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\bin;E:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\bin\x64;;E:\PyTorch_Build\pytorch\build\lib.win-amd64-cpython-310\torch\lib;E:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\bin;E:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\bin;C:\Users\Administrator\AppData\Local\Microsoft\dotnet;C:\Users\Administrator\AppData\Local\Microsoft\dotnet;C:\Users\Administrator\AppData\Local\Microsoft\dotnet\;C:\Program Files\dotnet;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;E:\Python310;C:\Program Files\dotnet\;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;C:\Users\Administrator\.dotnet\tools;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;C:\Users\Administrator\.dotnet\tools;E:\Python310\Scripts;E:\Python310\Scripts;C:\Program Files\PowerShell\7\;E:\Program Files\Microsoft VS Code\bin;E:\Program Files\Git\cmd;C:\Program Files\NVIDIA Corporation\Nsight Compute 2025.3.0\;E:\Program Files\CMake\bin;C:\Program Files\Microsoft SQL Server\150\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files (x86)\Incredibuild;E:\PyTorch_Build\pytorch\build\lib.win-amd64-cpython-310\torch\lib;E:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\ProgramData\chocolatey\bin;E:\Program Files\Rust\.cargo\bin;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;C:\Users\Administrator\.dotnet\tools;C:\Users\Administrator\miniconda3\Scripts;E:\Program Files\Rust\.cargo\bin;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;C:\Users\Administrator\.dotnet\tools;C:\Users\Administrator\miniconda3\Scripts;E:\Program Files\Rust\.cargo\bin;C:\Users\Administrator\AppData\Local\Microsoft\WindowsApps;C:\Users\Administrator\.dotnet\tools;C:\ProgramData\mingw64\mingw64\bin (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 获取 SDK 版本 (rtx5070_env) PS E:\PyTorch_Build\pytorch> $sdkVersion = Get-ChildItem -Path "${env:ProgramFiles(x86)}\Windows Kits\10\Include" | >> Where-Object { $_.PSIsContainer -and $_.Name -match '^\d+\.\d+\.\d+' } | >> Sort-Object { [version]$_.Name } -Descending | >> Select-Object -First 1 -ExpandProperty Name (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> $cmakeArgs = @( >> "-G Ninja", >> "-DCMAKE_BUILD_TYPE=Release", >> "-DCMAKE_C_COMPILER=cl.exe", >> "-DCMAKE_CXX_COMPILER=cl.exe", >> "-DCMAKE_CUDA_COMPILER=E:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v13.0/bin/nvcc.exe", >> "-DCMAKE_CUDA_HOST_COMPILER=cl.exe", >> "-DCMAKE_SYSTEM_VERSION=$sdkVersion", # 关键: 指定 SDK 版本 >> "-DCUDA_NVCC_FLAGS=-Xcompiler /wd4819 -gencode arch=compute_89,code=sm_89", >> "-DTORCH_CUDA_ARCH_LIST=8.9", >> "-DUSE_CUDA=ON", >> "-DUSE_NCCL=OFF", >> "-DUSE_DISTRIBUTED=OFF", >> "-DBUILD_TESTING=OFF", >> "-DBLAS=OpenBLAS", >> "-DCUDA_TOOLKIT_ROOT_DIR=E:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v13.0", >> "-DCUDNN_ROOT_DIR=E:/Program Files/NVIDIA/CUDNN/v9.12", >> "-DPYTHON_EXECUTABLE=$((Get-Command python).Source)", >> # 显式指定库路径 >> "-DCMAKE_LIBRARY_PATH=C:/Program Files (x86)/Windows Kits/10/Lib/$sdkVersion/um/x64", >> "-DCMAKE_INCLUDE_PATH=C:/Program Files (x86)/Windows Kits/10/Include/$sdkVersion/um" >> ) (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> cmake .. @cmakeArgs CMake Warning: Ignoring extra path from command line: ".." CMake Error: The source directory "E:/PyTorch_Build" does not appear to contain CMakeLists.txt. Specify --help for usage, or press the help button on the CMake GUI. (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 加载完整 VC 环境 (rtx5070_env) PS E:\PyTorch_Build\pytorch> & "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat" -vcvars_ver=14.4 -winsdk=10.0.22621.0 [ERROR:vcvarsall.bat] Invalid argument found : .4 [ERROR:vcvarsall.bat] Invalid argument found : -winsdk=10 [ERROR:vcvarsall.bat] Invalid argument found : .0.22621.0 [ERROR:vcvarsall.bat] Error in script usage. The correct usage is: Syntax: vcvarsall.bat [arch] [platform_type] [winsdk_version] [-vcvars_ver=vc_version] [-vcvars_spectre_libs=spectre_mode] where : [arch]: x86 | amd64 | x86_amd64 | x86_arm | x86_arm64 | amd64_x86 | amd64_arm | amd64_arm64 [platform_type]: {empty} | store | uwp [winsdk_version] : full Windows 10 SDK number (e.g. 10.0.10240.0) or "8.1" to use the Windows 8.1 SDK. [vc_version] : {none} for latest installed VC++ compiler toolset | "14.0" for VC++ 2015 Compiler Toolset | "14.xx" for the latest 14.xx.yyyyy toolset installed (e.g. "14.11") | "14.xx.yyyyy" for a specific full version number (e.g. "14.11.25503") [spectre_mode] : {none} for libraries without spectre mitigations | "spectre" for libraries with spectre mitigations The store parameter sets environment variables to support Universal Windows Platform application development and is an alias for 'uwp'. For example: vcvarsall.bat x86_amd64 vcvarsall.bat x86_amd64 10.0.10240.0 vcvarsall.bat x86_arm uwp 10.0.10240.0 vcvarsall.bat x86_arm onecore 10.0.10240.0 -vcvars_ver=14.0 vcvarsall.bat x64 8.1 vcvarsall.bat x64 store 8.1 Please make sure either Visual Studio or C++ Build SKU is installed. (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 验证环境 (rtx5070_env) PS E:\PyTorch_Build\pytorch> cl.exe cl.exe: The term 'cl.exe' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. (rtx5070_env) PS E:\PyTorch_Build\pytorch> link.exe link.exe: The term 'link.exe' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 设置 CUDA 路径 (rtx5070_env) PS E:\PyTorch_Build\pytorch> $env:CUDA_PATH = "E:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v13.0" (rtx5070_env) PS E:\PyTorch_Build\pytorch> $env:PATH = "$env:CUDA_PATH/bin;$env:PATH" (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 直接运行 CMake (rtx5070_env) PS E:\PyTorch_Build\pytorch> cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release -DUSE_CUDA=ON ... CMake Warning: Ignoring extra path from command line: "E:/PyTorch_Build" CMake Warning: Ignoring extra path from command line: ".." -- The CXX compiler identification is GNU 13.2.0 -- The C compiler identification is GNU 13.2.0 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: C:/ProgramData/mingw64/mingw64/bin/c++.exe - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: C:/ProgramData/mingw64/mingw64/bin/gcc.exe - skipped -- Detecting C compile features -- Detecting C compile features - done -- Not forcing any particular BLAS to be found CMake Warning at CMakeLists.txt:418 (message): TensorPipe cannot be used on Windows. Set it to OFF CMake Warning at CMakeLists.txt:430 (message): Libuv is not installed in current conda env. Set USE_DISTRIBUTED to OFF. Please run command 'conda install -c conda-forge libuv=1.39' to install libuv. -- Performing Test C_HAS_AVX_1 -- Performing Test C_HAS_AVX_1 - Failed -- Performing Test C_HAS_AVX_2 -- Performing Test C_HAS_AVX_2 - Success -- Performing Test C_HAS_AVX2_1 -- Performing Test C_HAS_AVX2_1 - Failed -- Performing Test C_HAS_AVX2_2 -- Performing Test C_HAS_AVX2_2 - Success -- Performing Test C_HAS_AVX512_1 -- Performing Test C_HAS_AVX512_1 - Failed -- Performing Test C_HAS_AVX512_2 -- Performing Test C_HAS_AVX512_2 - Success -- Performing Test CXX_HAS_AVX_1 -- Performing Test CXX_HAS_AVX_1 - Failed -- Performing Test CXX_HAS_AVX_2 -- Performing Test CXX_HAS_AVX_2 - Success -- Performing Test CXX_HAS_AVX2_1 -- Performing Test CXX_HAS_AVX2_1 - Failed -- Performing Test CXX_HAS_AVX2_2 -- Performing Test CXX_HAS_AVX2_2 - Success -- Performing Test CXX_HAS_AVX512_1 -- Performing Test CXX_HAS_AVX512_1 - Failed -- Performing Test CXX_HAS_AVX512_2 -- Performing Test CXX_HAS_AVX512_2 - Success -- Current compiler supports avx2 extension. Will build perfkernels. -- Performing Test CAFFE2_COMPILER_SUPPORTS_AVX512_EXTENSIONS -- Performing Test CAFFE2_COMPILER_SUPPORTS_AVX512_EXTENSIONS - Success -- Current compiler supports avx512f extension. Will build fbgemm. -- Performing Test COMPILER_SUPPORTS_HIDDEN_VISIBILITY -- Performing Test COMPILER_SUPPORTS_HIDDEN_VISIBILITY - Success -- Performing Test COMPILER_SUPPORTS_HIDDEN_INLINE_VISIBILITY -- Performing Test COMPILER_SUPPORTS_HIDDEN_INLINE_VISIBILITY - Success -- Performing Test COMPILER_SUPPORTS_RDYNAMIC -- Performing Test COMPILER_SUPPORTS_RDYNAMIC - Failed -- Found CUDA: E:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v13.0 (found version "13.0") CMake Error at E:/PyTorch_Build/pytorch/rtx5070_env/Lib/site-packages/cmake/data/share/cmake-4.1/Modules/CMakeDetermineCompilerId.cmake:928 (message): Compiling the CUDA compiler identification source file "CMakeCUDACompilerId.cu" failed. Compiler: E:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v13.0/bin/nvcc.exe Build flags: Id flags: --keep;--keep-dir;tmp -v The output was: 1 nvcc fatal : Cannot find compiler 'cl.exe' in PATH Compiling the CUDA compiler identification source file "CMakeCUDACompilerId.cu" failed. Compiler: E:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v13.0/bin/nvcc.exe Build flags: -DLIBCUDACXX_ENABLE_SIMPLIFIED_COMPLEX_OPERATIONS;-Xfatbin;-compress-all Id flags: --keep;--keep-dir;tmp -v The output was: 1 nvcc fatal : Cannot find compiler 'cl.exe' in PATH Call Stack (most recent call first): E:/PyTorch_Build/pytorch/rtx5070_env/Lib/site-packages/cmake/data/share/cmake-4.1/Modules/CMakeDetermineCompilerId.cmake:8 (CMAKE_DETERMINE_COMPILER_ID_BUILD) E:/PyTorch_Build/pytorch/rtx5070_env/Lib/site-packages/cmake/data/share/cmake-4.1/Modules/CMakeDetermineCompilerId.cmake:53 (__determine_compiler_id_test) E:/PyTorch_Build/pytorch/rtx5070_env/Lib/site-packages/cmake/data/share/cmake-4.1/Modules/CMakeDetermineCUDACompiler.cmake:162 (CMAKE_DETERMINE_COMPILER_ID) cmake/public/cuda.cmake:47 (enable_language) cmake/Dependencies.cmake:43 (include) CMakeLists.txt:853 (include) -- Configuring incomplete, errors occurred! (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 创建测试文件 (rtx5070_env) PS E:\PyTorch_Build\pytorch> @' >> #include <iostream> >> int main() { >> std::cout << "Hello from C++ & CUDA toolchain!" << std::endl; >> return 0; >> } >> '@ | Set-Content test.cpp (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 编译测试 (rtx5070_env) PS E:\PyTorch_Build\pytorch> cl.exe test.cpp /EHsc /link kernel32.lib user32.lib gdi32.lib cl.exe: The term 'cl.exe' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. (rtx5070_env) PS E:\PyTorch_Build\pytorch> if (Test-Path test.exe) { >> .\test.exe >> } else { >> Write-Host "编译失败,错误信息:" >> cl.exe test.cpp /EHsc /link kernel32.lib /v >> } 编译失败,错误信息: cl.exe: Line | 5 | cl.exe test.cpp /EHsc /link kernel32.lib /v | ~~~~~~ | The term 'cl.exe' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 1. 设置基本环境变量 (rtx5070_env) PS E:\PyTorch_Build\pytorch> $env:CUDA_PATH = "E:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v13.0" (rtx5070_env) PS E:\PyTorch_Build\pytorch> $env:CUDNN_PATH = "E:/Program Files/NVIDIA/CUDNN/v9.12" (rtx5070_env) PS E:\PyTorch_Build\pytorch> $env:OpenBLAS_HOME = "E:/Libs/OpenBLAS_Prebuilt" (rtx5070_env) PS E:\PyTorch_Build\pytorch> $env:PATH = "$env:CUDA_PATH/bin;$env:OpenBLAS_HOME/bin;$env:PATH" (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 2. 加载 Visual Studio 环境 (rtx5070_env) PS E:\PyTorch_Build\pytorch> & "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat" ********************************************************************** ** Visual Studio 2022 Developer Command Prompt v17.14.13 ** Copyright (c) 2025 Microsoft Corporation ********************************************************************** [vcvarsall.bat] Environment initialized for: 'x64' (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 3. 添加编译器路径 (rtx5070_env) PS E:\PyTorch_Build\pytorch> $clPath = "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.44.35207\bin\Hostx64\x64" (rtx5070_env) PS E:\PyTorch_Build\pytorch> $env:PATH = "$clPath;$env:PATH" (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 4. 修复 Windows SDK 库路径 (rtx5070_env) PS E:\PyTorch_Build\pytorch> .\fix_kernel32_error.ps1 .\fix_kernel32_error.ps1: The term '.\fix_kernel32_error.ps1' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 5. 验证工具链 (rtx5070_env) PS E:\PyTorch_Build\pytorch> .\verify_toolchain.ps1 .\verify_toolchain.ps1: The term '.\verify_toolchain.ps1' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 6. 准备构建目录 (rtx5070_env) PS E:\PyTorch_Build\pytorch> Set-Location E:\PyTorch_Build\pytorch (rtx5070_env) PS E:\PyTorch_Build\pytorch> Remove-Item build -Recurse -Force -ErrorAction SilentlyContinue (rtx5070_env) PS E:\PyTorch_Build\pytorch> New-Item -Path build -ItemType Directory | Out-Null (rtx5070_env) PS E:\PyTorch_Build\pytorch> Set-Location build (rtx5070_env) PS E:\PyTorch_Build\pytorch\build> (rtx5070_env) PS E:\PyTorch_Build\pytorch\build> # 7. 配置 CMake (rtx5070_env) PS E:\PyTorch_Build\pytorch\build> .\cmake_configure_final.ps1 .\cmake_configure_final.ps1: The term '.\cmake_configure_final.ps1' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. (rtx5070_env) PS E:\PyTorch_Build\pytorch\build> (rtx5070_env) PS E:\PyTorch_Build\pytorch\build> # 8. 编译和安装 (rtx5070_env) PS E:\PyTorch_Build\pytorch\build> if ($LASTEXITCODE -eq 0) { >> cmake --build . --config Release --parallel 8 >> if ($LASTEXITCODE -eq 0) { >> cmake --install . >> } >> } Error: not a CMake build directory (missing CMakeCache.txt) (rtx5070_env) PS E:\PyTorch_Build\pytorch\build> (rtx5070_env) PS E:\PyTorch_Build\pytorch\build> # 9. 验证安装 (rtx5070_env) PS E:\PyTorch_Build\pytorch\build> python -c "import torch; print(f'PyTorch版本: {torch.__version__}'); print(f'CUDA可用: {torch.cuda.is_available()}')" PyTorch版本: 2.8.0+cpu CUDA可用: False (rtx5070_env) PS E:\PyTorch_Build\pytorch\build>
09-03
<think>好的,我现在需要解决用户遇到的“conda.exe cannot execute binary file: Exec format error”问题。用户提到在Windows下的Linux安装Anaconda时出现这个错误,并且运行uname -m显示i686。首先,我得理解这个错误的原因。根据引用[1],“Exec format error”通常是因为尝试运行与系统架构不兼容的二进制文件。比如在32位系统上运行64位的程序,或者反之。用户使用uname -m得到的i686,说明系统是32位的,而他们下载的conda安装包可能是64位的,导致不兼容。 接下来,我需要确认Anaconda的版本是否与系统架构匹配。用户可能下载了x86_64(64位)的安装包,而系统是i686(32位)。这时候需要引导用户到Anaconda官网下载32位的安装包。此外,用户可能误在WSL或其他Linux环境中运行了Windows版的conda.exe,这也是常见错误,应该建议使用Linux版本的.sh安装脚本。 另外,检查文件类型是否有误也很重要。通过file命令可以确认安装包的实际架构,确保是32位的ELF文件。如果用户确实需要64位环境,可能需要升级系统到64位,但这涉及到更多步骤,比如更换操作系统或安装64位内核。 最后,总结解决方案时,要分步骤清晰列出,确保用户能逐步操作。同时,生成相关问题帮助用户扩展知识,比如如何检查系统架构、Anaconda的不同版本区别等。确保引用正确,比如引用[2]提到uname -m的结果,引用[1]解释错误原因,这样用户能对应理解每个步骤的依据。</think>### 解决方案分析 出现`conda.exe cannot execute binary file: Exec format error`的根本原因是**二进制文件与系统架构不兼容**。常见场景包括: 1. 尝试在32位系统(如i686)运行64位程序(x86_64)[^1][^2]; 2. 错误地在Linux环境中使用Windows版本的`conda.exe`(Windows可执行文件无法直接在Linux运行)。 ### 分步解决方案 #### 1. 确认系统架构 在终端运行以下命令: ```bash uname -m # 若输出为i686则为32位系统,x86_64则为64位系统[^2] ``` #### 2. 选择匹配的Anaconda安装包 - **32位系统(i686)**:需下载名称含`x86`或`32-bit`的安装包(如`Anaconda3-2023.03-Linux-x86.sh`) - **64位系统(x86_64)**:下载名称含`x86_64`或`64-bit`的安装包(如`Anaconda3-2023.03-Linux-x86_64.sh`) > 官网下载地址:[Anaconda Archives](https://repo.anaconda.com/archive/) #### 3. 验证安装包类型 通过`file`命令检查安装包是否与系统匹配: ```bash file Anaconda3-*.sh # 正常应显示"ELF 32-bit"或"ELF 64-bit" ``` #### 4. 使用Linux专用安装脚本 Windows的`.exe`文件无法在Linux直接运行,必须通过以下命令安装: ```bash bash Anaconda3-*.sh # 使用sh脚本而非直接执行.exe ``` #### 5. 升级系统架构(可选) 若需长期使用64位环境,可考虑: - 重装64位Linux系统 - 使用虚拟机或Docker容器部署64位环境
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

源启智能

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值