Permission denied: 'C:\\Users\\Public\\Desktop\\From py.txt'

本文介绍了解决在Python编程中遇到的文件写入权限错误的方法。通过使用管理员帐户登录并修改目标文件夹的安全设置,成功解决了无法写入公共桌面目录的问题。
部署运行你感兴趣的模型镜像

接上一篇文章 加了r以后报错
import csv

filename = ‘D:\软件安装包\python\《Python编程:从入门到实践》源代码文件\chapter_16\sitka_weather_07-2014.csv’
with open(filename) as f:
reader = csv.reader(f)
row_reader = next(reader)
# print(row_reader)

a = []
for line in reader:
    b = int(line[1])  #提取 第2列 字符串为数字
    a.append(b)
# print(a)

filename1 = r’C:\Users\Public\Desktop\From py.txt’
with open(filename1, ‘w’) as c:
c.write(a)

“D:\install program\python\python.exe” D:/test1/test.py
Traceback (most recent call last):
File “D:/test1/test.py”, line 16, in
with open(filename1, ‘w’) as c:
PermissionError: [Errno 13] Permission denied: ‘C:\Users\Public\Desktop\From py.txt’

Process finished with exit code 1

已解决:
使用管理员帐户登陆电脑后,右击C:\Users\Administrator\Desktop目录,选择属性,在弹出的文件夹属性设置窗口中选择安全,添加你需要具有此文件访问权限的用户帐户,然后确认即可。

您可能感兴趣的与本文相关的镜像

Python3.8

Python3.8

Conda
Python

Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本

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> # 在配置编译选项部分添加 (rtx5070_env) PS E:\PyTorch_Build\pytorch> $Env:USE_CUDNN = 1 (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 确保使用正确的cuDNN路径 (rtx5070_env) PS E:\PyTorch_Build\pytorch> if ($env:CUDNN_HOME) { >> $cudnnHome = $env:CUDNN_HOME.Replace('"', '') >> $Env:CUDNN_INCLUDE_DIR = "${cudnnHome}\include" >> >> # 自动检测lib目录结构 >> $libPath = if (Test-Path "${cudnnHome}\lib\x64") { >> "${cudnnHome}\lib\x64" >> } else { >> "${cudnnHome}\lib" >> } >> >> $Env:CUDNN_LIBRARY = $libPath >> $Env:CUDNN_ROOT = $cudnnHome >> >> Write-Host "✓ cuDNN配置:" >> Write-Host " - INCLUDE: $Env:CUDNN_INCLUDE_DIR" >> Write-Host " - LIB: $Env:CUDNN_LIBRARY" >> } else { >> Write-Host "⚠ 警告: CUDNN_HOME未设置" -ForegroundColor Yellow >> } ⚠ 警告: CUDNN_HOME未设置 (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 1. 设置环境变量 (rtx5070_env) PS E:\PyTorch_Build\pytorch> $env:CUDA_HOME = "E:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.1" (rtx5070_env) PS E:\PyTorch_Build\pytorch> $env:CUDNN_HOME = "E:\Program Files\NVIDIA\CUDNN\v8.9.6" (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 2. 运行修复后的诊断脚本 (rtx5070_env) PS E:\PyTorch_Build\pytorch> python diagnose_fixed_v6.py File "E:\PyTorch_Build\pytorch\diagnose_fixed_v6.py", line 33 def main(): SyntaxError: expected 'except' or 'finally' block (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 3. 清理环境 (rtx5070_env) PS E:\PyTorch_Build\pytorch> Remove-Item -Recurse -Force build, dist, torch.egg-info -ErrorAction Ignore (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 4. 创建新虚拟环境 (rtx5070_env) PS E:\PyTorch_Build\pytorch> python -m venv rtx5070_env Error: [Errno 13] Permission denied: 'E:\\PyTorch_Build\\pytorch\\rtx5070_env\\Scripts\\python.exe' (rtx5070_env) PS E:\PyTorch_Build\pytorch> .\rtx5070_env\Scripts\Activate.ps1 (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 5. 安装基础依赖 (rtx5070_env) PS E:\PyTorch_Build\pytorch> python -m pip install -U pip setuptools wheel cmake ninja Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Requirement already satisfied: pip in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (22.3.1) Collecting pip Using cached https://pypi.tuna.tsinghua.edu.cn/packages/b7/3f/945ef7ab14dc4f9d7f40288d2df998d1837ee0888ec3659c813487572faa/pip-25.2-py3-none-any.whl (1.8 MB) 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: cmake in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (4.1.0) Requirement already satisfied: ninja in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (1.13.0) Installing collected packages: setuptools, pip Attempting uninstall: setuptools Found existing installation: setuptools 79.0.1 Uninstalling setuptools-79.0.1: Successfully uninstalled setuptools-79.0.1 Attempting uninstall: pip Found existing installation: pip 22.3.1 Uninstalling pip-22.3.1: Successfully uninstalled pip-22.3.1 Successfully installed pip-25.2 setuptools-80.9.0 (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 6. 安装PyTorch构建依赖 (rtx5070_env) PS E:\PyTorch_Build\pytorch> pip install -r requirements.txt Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Collecting setuptools<80.0,>=70.1.0 (from -r E:\PyTorch_Build\pytorch\requirements-build.txt (line 2)) Downloading https://pypi.tuna.tsinghua.edu.cn/packages/0d/6d/b4752b044bf94cb802d88a888dc7d288baaf77d7910b7dedda74b5ceea0c/setuptools-79.0.1-py3-none-any.whl (1.3 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.3/1.3 MB 10.6 MB/s 0:00:00 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) Installing collected packages: setuptools Attempting uninstall: setuptools Found existing installation: setuptools 80.9.0 Uninstalling setuptools-80.9.0: Successfully uninstalled setuptools-80.9.0 Successfully installed setuptools-79.0.1 (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 7. 运行增强构建脚本 (rtx5070_env) PS E:\PyTorch_Build\pytorch> .\build_optimized_v4.ps1 -Verbose ====== PyTorch 增强构建 V4 ====== ✓ 修复: torch\headeronly\CMakeLists.txt (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 8. 验证安装 (rtx5070_env) PS E:\PyTorch_Build\pytorch> python -c "import torch; print(f'PyTorch版本: {torch.__version__}'); print(f'CUDA可用: {torch.cuda.is_available()}')" Traceback (most recent call last): File "<string>", line 1, in <module> AttributeError: module 'torch' has no attribute '__version__' (rtx5070_env) PS E:\PyTorch_Build\pytorch>
09-03
1.”8.c.obj [564/7459] Building C object confu-deps\XNNPACK\CMakeFiles\microkernels-prod.dir\src\f32-vlog\gen\f32-vlog-scalar-rational-3-3-div.c.obj E:\PyTorch_Build\pytorch\third_party\XNNPACK\src\f32-vlog\gen\f32-vlog-scalar-rational-3-3-div.c(1): warning C4819: \xb8\xc3\xceļ\xfe\xb0\xfc\xba\xac\xb2\xbb\xc4\xdc\xd4ڵ\xb1ǰ\xb4\xfa\xc2\xebҳ(936)\xd6б\xedʾ\xb5\xc4\xd7ַ\xfb\xa1\xa3\xc7뽫\xb8\xc3\xceļ\xfe\xb1\xa3\xb4\xe6Ϊ Unicode \xb8\xf1ʽ\xd2Է\xc0ֹ\xca\xfd\xbeݶ\xaaʧ ninja: build stopped: subcommand failed. -- Checkout nccl release tag: v2.27.5-1 error: subprocess-exited-with-error × Building wheel for torch (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> See above for output. note: This error originates from a subprocess, and is likely not a problem with pip. full command: 'E:\PyTorch_Build\pytorch\rtx5070_env\Scripts\python.exe' 'E:\PyTorch_Build\pytorch\rtx5070_env\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py' build_wheel 'C:\Users\ADMINI~1\AppData\Local\Temp\tmpr8yby3pq' cwd: E:\PyTorch_Build\pytorch Building wheel for torch (pyproject.toml) ... error ERROR: Failed building wheel for torch Failed to build torch ERROR: Could not build wheels for torch, which is required to install pyproject.toml-based projects (rtx5070_env) PS E:\PyTorch_Build\pytorch> “ 2.”PS C:\Users\Administrator\Desktop> cd E:\PyTorch_Build\pytorch PS E:\PyTorch_Build\pytorch> python -m venv rtx5070_env Error: [Errno 13] Permission denied: 'E:\\PyTorch_Build\\pytorch\\rtx5070_env\\Scripts\\python.exe' PS E:\PyTorch_Build\pytorch> .\rtx5070_env\Scripts\activate (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 创建脚本目录 (rtx5070_env) PS E:\PyTorch_Build\pytorch> $scriptDir = "E:\PyTorch_Build\scripts" (rtx5070_env) PS E:\PyTorch_Build\pytorch> New-Item -ItemType Directory -Path $scriptDir -Force | Out-Null (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 保存 cudnn_validator.ps1 (rtx5070_env) PS E:\PyTorch_Build\pytorch> @' >> # cudnn_validator.ps1 >> $cudnnBase = "E:\Program Files\NVIDIA\CUDNN\v9.12" >> $cudaVersion = "13.0" >> $binPath = Join-Path $cudnnBase "bin\$cudaVersion" >> >> $dllFiles = Get-ChildItem -LiteralPath $binPath -Filter "*.dll" -ErrorAction Stop >> >> if (-not $dllFiles) { >> throw "❌ 在 $binPath 中未找到任何 DLL 文件" >> } >> >> $targetDll = $dllFiles | Where-Object { $_.Name -match "cudnn_ops_infer\d+_8\.dll" } | Select-Object -First 1 >> >> if (-not $targetDll) { >> $targetDll = $dllFiles | Where-Object { $_.Name -like "cudnn_ops_infer*.dll" } | Select-Object -First 1 >> >> if (-not $targetDll) { >> Write-Host "🔍 在 $binPath 中找到以下 DLL 文件:" -ForegroundColor Cyan >> $dllFiles | ForEach-Object { Write-Host " - $($_.Name)" } >> $targetDll = $dllFiles | Where-Object { $_.Name -like "cudnn*.dll" } | Select-Object -First 1 >> } >> } >> >> if ($targetDll) { >> $linkPath = Join-Path $binPath "cudnn_ops_infer64_8.dll" >> if (-not (Test-Path $linkPath)) { >> cmd /c mklink "$linkPath" "$($targetDll.FullName)" > $null >> } >> >> Write-Host "✅ 使用文件: $($targetDll.FullName)" >> Write-Host "✅ 已创建符号链接: $linkPath" >> } else { >> throw "❌ 错误: 未找到任何匹配的 cuDNN DLL 文件" >> } >> '@ | Out-File "$scriptDir\cudnn_validator.ps1" -Encoding UTF8 (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 保存内存保护脚本 (rtx5070_env) PS E:\PyTorch_Build\pytorch> @' >> # memory_protection_v4.ps1 >> $pageFileSettings = @{ >> InitialSize = 16384 # 16GB >> MaximumSize = 32768 # 32GB >> } >> >> try { >> $pageFile = Get-WmiObject -Class Win32_PageFileSetting >> >> if ($pageFile) { >> $regPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" >> Set-ItemProperty -Path $regPath -Name "PagingFiles" -Value "$env:SystemDrive\pagefile.sys $($pageFileSettings.InitialSize) $($pageFileSettings.MaximumSize)" -Force >> Write-Host "✅ 页面文件设置已更新" >> } else { >> Set-WmiInstance -Class Win32_PageFileSetting -Arguments @{ >> Name = "$env:SystemDrive\pagefile.sys" >> InitialSize = $pageFileSettings.InitialSize >> MaximumSize = $pageFileSettings.MaximumSize >> } >> } >> >> Restart-Service -Name "SysMain" -Force -ErrorAction SilentlyContinue >> } >> catch { >> $manualSettings = @" >> Windows Registry Editor Version 5.00 >> >> [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management] >> "PagingFiles"="$env:SystemDrive\pagefile.sys $($pageFileSettings.InitialSize) $($pageFileSettings.MaximumSize)" >> "@ >> $regFilePath = "E:\PyTorch_Build\pagefile_settings.reg" >> $manualSettings | Out-File $regFilePath >> Start-Process "regedit.exe" -ArgumentList "/s `"$regFilePath`"" -Wait >> } >> '@ | Out-File "$scriptDir\memory_protection_v4.ps1" -Encoding UTF8 (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 保存安全构建脚本 (rtx5070_env) PS E:\PyTorch_Build\pytorch> @' >> # safe_build_v4.ps1 >> param([switch]$Incremental) >> >> Import-Module "$env:USERPROFILE\Documents\WindowsPowerShell\Modules\ScriptManager" -Force >> >> try { >> Repair-All >> Invoke-Script -ScriptName "cuDNN 验证" { & "E:\PyTorch_Build\scripts\cudnn_validator.ps1" } >> Invoke-Script -ScriptName "内存配置" { & "E:\PyTorch_Build\scripts\memory_protection_v4.ps1" } >> >> if ($Incremental) { >> Build-PyTorch -Resume >> } else { >> Build-PyTorch >> } >> } >> catch { >> Write-Host "编译失败: $_" -ForegroundColor Red >> exit 1 >> } >> finally { >> Write-Host "编译进程已完成" -ForegroundColor Green >> } >> '@ | Out-File "$scriptDir\safe_build_v4.ps1" -Encoding UTF8 (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 创建模块目录 (rtx5070_env) PS E:\PyTorch_Build\pytorch> $moduleDir = "$env:USERPROFILE\Documents\WindowsPowerShell\Modules\ScriptManager" (rtx5070_env) PS E:\PyTorch_Build\pytorch> New-Item -ItemType Directory -Path $moduleDir -Force | Out-Null (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 保存模块文件 (rtx5070_env) PS E:\PyTorch_Build\pytorch> @' >> # ScriptManager.psm1 >> $scriptDir = "E:\PyTorch_Build\scripts" >> >> function Invoke-Script { >> param([string]$ScriptName, [ScriptBlock]$ScriptBlock) >> Write-Host "🛠️ 执行: $ScriptName" -ForegroundColor Cyan >> & $ScriptBlock >> Write-Host "✅ $ScriptName 完成" -ForegroundColor Green >> } >> >> function Repair-All { >> # 实现修复逻辑 >> Write-Host "🔧 执行系统修复..." -ForegroundColor Yellow >> # 这里添加实际的修复代码 >> } >> >> function Build-PyTorch { >> param([switch]$Resume) >> Write-Host "🏗️ 开始编译 PyTorch..." -ForegroundColor Magenta >> >> if ($Resume) { >> cmake --build build --config Release --target install -- /m >> } else { >> cmake -S . -B build -GNinja -DCMAKE_BUILD_TYPE=Release ` >> -DUSE_CUDA=ON -DUSE_CUDNN=ON ` >> -DCUDA_TOOLKIT_ROOT_DIR="C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0" ` >> -DCUDNN_ROOT="E:\Program Files\NVIDIA\CUDNN\v9.12" >> cmake --build build --config Release --target install -- /m >> } >> >> Write-Host "🎉 PyTorch 编译完成" -ForegroundColor Green >> } >> >> Export-ModuleMember -Function Invoke-Script, Repair-All, Build-PyTorch >> '@ | Out-File "$moduleDir\ScriptManager.psm1" -Encoding UTF8 (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 管理员权限创建虚拟环境 (rtx5070_env) PS E:\PyTorch_Build\pytorch> $adminScript = @" >> Set-Location "E:\PyTorch_Build\pytorch" >> python -m venv rtx5070_env --clear >> "@ (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> $adminScript | Out-File "$env:TEMP\create_venv.ps1" -Encoding UTF8 (rtx5070_env) PS E:\PyTorch_Build\pytorch> Start-Process powershell -ArgumentList "-ExecutionPolicy Bypass -File `"$env:TEMP\create_venv.ps1`"" -Verb RunAs -Wait (rtx5070_env) PS E:\PyTorch_Build\pytorch> Remove-Item "$env:TEMP\create_venv.ps1" -Force (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 激活虚拟环境 (rtx5070_env) PS E:\PyTorch_Build\pytorch> & "E:\PyTorch_Build\pytorch\rtx5070_env\Scripts\Activate.ps1" &: The term 'E:\PyTorch_Build\pytorch\rtx5070_env\Scripts\Activate.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> # 步骤1: 创建所有必需的脚本文件 (rtx5070_env) PS E:\PyTorch_Build\pytorch> & { >> # 这里放置上面创建脚本文件的代码块 >> } (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 步骤2: 导入模块 (rtx5070_env) PS E:\PyTorch_Build\pytorch> Import-Module "$env:USERPROFILE\Documents\WindowsPowerShell\Modules\ScriptManager" -Force (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 步骤3: 执行构建流程 (rtx5070_env) PS E:\PyTorch_Build\pytorch> Invoke-Script "cuDNN 验证" { & "E:\PyTorch_Build\scripts\cudnn_validator.ps1" } 🛠️ 执行: cuDNN 验证 ✅ 使用文件: E:\Program Files\NVIDIA\CUDNN\v9.12\bin\13.0\cudnn_ops_infer64_8.dll ✅ 已创建符号链接: E:\Program Files\NVIDIA\CUDNN\v9.12\bin\13.0\cudnn_ops_infer64_8.dll ✅ cuDNN 验证 完成 (rtx5070_env) PS E:\PyTorch_Build\pytorch> Invoke-Script "内存配置" { & "E:\PyTorch_Build\scripts\memory_protection_v4.ps1" } 🛠️ 执行: 内存配置 ✅ 页面文件设置已更新 ✅ 内存配置 完成 (rtx5070_env) PS E:\PyTorch_Build\pytorch> Invoke-Script "PyTorch 编译" { & "E:\PyTorch_Build\scripts\safe_build_v4.ps1" } 🛠️ 执行: PyTorch 编译 🔧 执行系统修复... 🛠️ 执行: cuDNN 验证 ✅ 使用文件: E:\Program Files\NVIDIA\CUDNN\v9.12\bin\13.0\cudnn_ops_infer64_8.dll ✅ 已创建符号链接: E:\Program Files\NVIDIA\CUDNN\v9.12\bin\13.0\cudnn_ops_infer64_8.dll ✅ cuDNN 验证 完成 🛠️ 执行: 内存配置 ✅ 页面文件设置已更新 ✅ 内存配置 完成 🏗️ 开始编译 PyTorch... 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. 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. -- Current compiler supports avx2 extension. Will build perfkernels. -- 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 Error at cmake/Modules_CUDA_fix/upstream/FindCUDA.cmake:750 (find_program): Syntax error in cmake code at E:/PyTorch_Build/pytorch/cmake/Modules_CUDA_fix/upstream/FindCUDA.cmake:750 when parsing string CUDA_NVCC_EXECUTABLE;NAMES;nvcc;PATHS;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0;ENV;CUDA_PATH;ENV;CUDA_BIN_PATH;PATH_SUFFIXES;bin;bin64;NO_DEFAULT_PATH Invalid character escape '\P'. Call Stack (most recent call first): cmake/Modules_CUDA_fix/upstream/FindCUDA.cmake:760 (cuda_find_host_program) cmake/Modules_CUDA_fix/FindCUDA.cmake:10 (include) cmake/public/cuda.cmake:29 (find_package) cmake/Dependencies.cmake:44 (include) CMakeLists.txt:869 (include) -- Configuring incomplete, errors occurred! You have changed variables that require your cache to be deleted. Configure will be re-run and you may have to reset some variables. The following variables have changed: CMAKE_CXX_COMPILER= C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.44.35207/bin/Hostx64/x64/cl.exe CMAKE_C_COMPILER= C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.44.35207/bin/Hostx64/x64/cl.exe CMake Error: Running 'C:/Users/Administrator/AppData/Local/Temp/pip-build-env-q72qsgkl/overlay/Scripts/ninja.exe' '-C' 'E:/PyTorch_Build/pytorch/build' '-t' 'restat' 'build.ninja' 'E:/PyTorch_Build/pytorch/build/cmake_install.cmake' 'E:/PyTorch_Build/pytorch/build/CTestTestfile.cmake' failed with: ninja: error: failed recompaction: Permission denied -- Generating done (0.1s) CMake Warning: Manually-specified variables were not used by the project: CUDNN_ROOT CMake Generate step failed. Build files cannot be regenerated correctly. Error: not a CMake build directory (missing CMakeCache.txt) 🎉 PyTorch 编译完成 编译进程已完成 ✅ PyTorch 编译 完成 (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 步骤4: 安装 PyTorch (rtx5070_env) PS E:\PyTorch_Build\pytorch> Set-Location "E:\PyTorch_Build\pytorch" (rtx5070_env) PS E:\PyTorch_Build\pytorch> pip install -v . No pyvenv.cfg file (rtx5070_env) PS E:\PyTorch_Build\pytorch>“
09-05
“tmpxft_000061d4_00000000-7_cutlassB_f32_aligned_k65536_dropout.cudafe1.cpp [4835/7459] Building CXX object caffe2\CMakeFiles\torch_cuda.dir\__\torch\csrc\jit\tensorexpr\cuda_codegen.cpp.obj E:\PyTorch_Build\pytorch\torch/csrc/jit/tensorexpr/ir.h(395): warning C4805: “==”: 在操作中将类型“c10::impl::ScalarTypeToCPPType<c10::ScalarType::Bool>::type”与类型“T”混合不安全 with [ T=int ] E:\PyTorch_Build\pytorch\torch/csrc/jit/tensorexpr/ir.h(395): note: 模板实例化上下文(最早的实例化上下文)为 E:\PyTorch_Build\pytorch\torch\csrc\jit\tensorexpr\cuda_codegen.cpp(147): note: 查看对正在编译的函数 模板 实例化“bool torch::jit::tensorexpr::immediateEquals<int>(const torch::jit::tensorexpr::ExprPtr &,T)”的引用 with [ T=int ] [4844/7459] Building CUDA object caffe2\CMakeFiles\torch_c...aten\src\ATen\native\quantized\cuda\FakeQuantizeCore.cu.ob FakeQuantizeCore.cu tmpxft_000011c8_00000000-7_FakeQuantizeCore.cudafe1.cpp [4850/7459] Building CUDA object caffe2\CMakeFiles\torch_c...aten\src\ATen\native\sparse\cuda\SparseCsrTensorMath.cu.ob SparseCsrTensorMath.cu tmpxft_00000e1c_00000000-7_SparseCsrTensorMath.cudafe1.cpp [4854/7459] Building CXX object caffe2\torch\CMakeFiles\torch_python.dir\csrc\StorageMethods.cpp.obj FAILED: [code=2] caffe2/torch/CMakeFiles/torch_python.dir/csrc/StorageMethods.cpp.obj C:\PROGRA~2\MICROS~2\2022\BUILDT~1\VC\Tools\MSVC\1444~1.352\bin\Hostx64\x64\cl.exe /nologo /TP -DAT_PER_OPERATOR_HEADERS -DBUILDING_TESTS -DEXPORT_AOTI_FUNCTIONS -DFMT_HEADER_ONLY=1 -DMINIZ_DISABLE_ZIP_READER_CRC32_CHECKS -DNOMINMAX -DONNXIFI_ENABLE_EXT=1 -DONNX_ML=1 -DONNX_NAMESPACE=onnx_torch -DPy_NO_LINK_LIB -DTHP_BUILD_MAIN_LIB -DTORCH_CUDA_USE_NVTX3 -DUSE_CUDA -DUSE_EXTERNAL_MZCRC -DUSE_ITT -DUSE_MIMALLOC -DUSE_NUMPY -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_DEPRECATE=1 -D_UCRT_LEGACY_INFINITY -Dtorch_python_EXPORTS -IE:\PyTorch_Build\pytorch\build\aten\src -IE:\PyTorch_Build\pytorch\aten\src -IE:\PyTorch_Build\pytorch\build -IE:\PyTorch_Build\pytorch -IE:\PyTorch_Build\pytorch\nlohmann -IE:\PyTorch_Build\pytorch\moodycamel -IE:\PyTorch_Build\pytorch\third_party\mimalloc\include -IE:\PyTorch_Build\pytorch\torch\.. -IE:\PyTorch_Build\pytorch\torch\..\aten\src -IE:\PyTorch_Build\pytorch\torch\..\aten\src\TH -IE:\PyTorch_Build\pytorch\build\caffe2\aten\src -IE:\PyTorch_Build\pytorch\build\third_party -IE:\PyTorch_Build\pytorch\build\third_party\onnx -IE:\PyTorch_Build\pytorch\torch\..\third_party\valgrind-headers -IE:\PyTorch_Build\pytorch\torch\..\third_party\gloo -IE:\PyTorch_Build\pytorch\torch\..\third_party\onnx -IE:\PyTorch_Build\pytorch\torch\..\third_party\flatbuffers\include -IE:\PyTorch_Build\pytorch\torch\..\third_party\kineto\libkineto\include -IE:\PyTorch_Build\pytorch\torch\..\third_party\cpp-httplib -IE:\PyTorch_Build\pytorch\torch\..\third_party\nlohmann\include -IE:\PyTorch_Build\pytorch\torch\csrc -IE:\PyTorch_Build\pytorch\torch\csrc\api\include -IE:\PyTorch_Build\pytorch\torch\lib -IE:\PyTorch_Build\pytorch\torch\standalone -IE:\PyTorch_Build\pytorch\torch\lib\libshm_windows -IE:\PyTorch_Build\pytorch\torch\csrc\api -IE:\PyTorch_Build\pytorch\c10\.. -IE:\PyTorch_Build\pytorch\c10\cuda\..\.. -IE:\PyTorch_Build\pytorch\third_party\fmt\include -IE:\PyTorch_Build\pytorch\third_party\onnx -external:IE:\PyTorch_Build\pytorch\cmake\..\third_party\googletest\googlemock\include -external:IE:\PyTorch_Build\pytorch\cmake\..\third_party\googletest\googletest\include -external:IE:\PyTorch_Build\pytorch\third_party\protobuf\src -external:IE:\PyTorch_Build\pytorch\third_party\XNNPACK\include -external:IE:\PyTorch_Build\pytorch\third_party\ittapi\include -external:IE:\PyTorch_Build\pytorch\cmake\..\third_party\eigen -external:IE:\PyTorch_Build\pytorch\third_party\ideep\mkl-dnn\include\oneapi\dnnl -external:IE:\PyTorch_Build\pytorch\third_party\ideep\include -external:IE:\PyTorch_Build\pytorch\INTERFACE -external:IE:\PyTorch_Build\pytorch\third_party\nlohmann\include -external:IE:\PyTorch_Build\pytorch\third_party\concurrentqueue -external:IE:\PyTorch_Build\pytorch\rtx5070_env\lib\site-packages\numpy\_core\include -external:IE:\Python310\Include -external:I"E:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\include" -external:IE:\PyTorch_Build\pytorch\cmake\..\third_party\pybind11\include -external:IE:\PyTorch_Build\pytorch\cmake\..\third_party\opentelemetry-cpp\api\include -external:IE:\PyTorch_Build\pytorch\third_party\cpp-httplib -external:IE:\PyTorch_Build\pytorch\third_party\NVTX\c\include -external:W0 /DWIN32 /D_WINDOWS /EHsc /Zc:__cplusplus /bigobj /FS /utf-8 -DUSE_PTHREADPOOL -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOROCTRACER -DLIBKINETO_NOXPUPTI=ON -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE /wd4624 /wd4068 /wd4067 /wd4267 /wd4661 /wd4717 /wd4244 /wd4804 /wd4273 -DHAVE_AVX512_CPU_DEFINITION -DHAVE_AVX2_CPU_DEFINITION /Zc:preprocessor /Zc:preprocessor /Zc:preprocessor /O2 /Ob2 /DNDEBUG /bigobj -DNDEBUG -std:c++17 -MD /permissive- /EHsc /bigobj -O2 /utf-8 /showIncludes /Focaffe2\torch\CMakeFiles\torch_python.dir\csrc\StorageMethods.cpp.obj /Fdcaffe2\torch\CMakeFiles\torch_python.dir\ /FS -c E:\PyTorch_Build\pytorch\torch\csrc\StorageMethods.cpp E:\PyTorch_Build\pytorch\torch\csrc\StorageMethods.cpp(9): fatal error C1083: 无法打开包括文件: “libshm.h”: No such file or directory [4855/7459] Building CXX object caffe2\torch\CMakeFiles\torch_python.dir\csrc\Storage.cpp.obj FAILED: [code=2] caffe2/torch/CMakeFiles/torch_python.dir/csrc/Storage.cpp.obj C:\PROGRA~2\MICROS~2\2022\BUILDT~1\VC\Tools\MSVC\1444~1.352\bin\Hostx64\x64\cl.exe /nologo /TP -DAT_PER_OPERATOR_HEADERS -DBUILDING_TESTS -DEXPORT_AOTI_FUNCTIONS -DFMT_HEADER_ONLY=1 -DMINIZ_DISABLE_ZIP_READER_CRC32_CHECKS -DNOMINMAX -DONNXIFI_ENABLE_EXT=1 -DONNX_ML=1 -DONNX_NAMESPACE=onnx_torch -DPy_NO_LINK_LIB -DTHP_BUILD_MAIN_LIB -DTORCH_CUDA_USE_NVTX3 -DUSE_CUDA -DUSE_EXTERNAL_MZCRC -DUSE_ITT -DUSE_MIMALLOC -DUSE_NUMPY -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_DEPRECATE=1 -D_UCRT_LEGACY_INFINITY -Dtorch_python_EXPORTS -IE:\PyTorch_Build\pytorch\build\aten\src -IE:\PyTorch_Build\pytorch\aten\src -IE:\PyTorch_Build\pytorch\build -IE:\PyTorch_Build\pytorch -IE:\PyTorch_Build\pytorch\nlohmann -IE:\PyTorch_Build\pytorch\moodycamel -IE:\PyTorch_Build\pytorch\third_party\mimalloc\include -IE:\PyTorch_Build\pytorch\torch\.. -IE:\PyTorch_Build\pytorch\torch\..\aten\src -IE:\PyTorch_Build\pytorch\torch\..\aten\src\TH -IE:\PyTorch_Build\pytorch\build\caffe2\aten\src -IE:\PyTorch_Build\pytorch\build\third_party -IE:\PyTorch_Build\pytorch\build\third_party\onnx -IE:\PyTorch_Build\pytorch\torch\..\third_party\valgrind-headers -IE:\PyTorch_Build\pytorch\torch\..\third_party\gloo -IE:\PyTorch_Build\pytorch\torch\..\third_party\onnx -IE:\PyTorch_Build\pytorch\torch\..\third_party\flatbuffers\include -IE:\PyTorch_Build\pytorch\torch\..\third_party\kineto\libkineto\include -IE:\PyTorch_Build\pytorch\torch\..\third_party\cpp-httplib -IE:\PyTorch_Build\pytorch\torch\..\third_party\nlohmann\include -IE:\PyTorch_Build\pytorch\torch\csrc -IE:\PyTorch_Build\pytorch\torch\csrc\api\include -IE:\PyTorch_Build\pytorch\torch\lib -IE:\PyTorch_Build\pytorch\torch\standalone -IE:\PyTorch_Build\pytorch\torch\lib\libshm_windows -IE:\PyTorch_Build\pytorch\torch\csrc\api -IE:\PyTorch_Build\pytorch\c10\.. -IE:\PyTorch_Build\pytorch\c10\cuda\..\.. -IE:\PyTorch_Build\pytorch\third_party\fmt\include -IE:\PyTorch_Build\pytorch\third_party\onnx -external:IE:\PyTorch_Build\pytorch\cmake\..\third_party\googletest\googlemock\include -external:IE:\PyTorch_Build\pytorch\cmake\..\third_party\googletest\googletest\include -external:IE:\PyTorch_Build\pytorch\third_party\protobuf\src -external:IE:\PyTorch_Build\pytorch\third_party\XNNPACK\include -external:IE:\PyTorch_Build\pytorch\third_party\ittapi\include -external:IE:\PyTorch_Build\pytorch\cmake\..\third_party\eigen -external:IE:\PyTorch_Build\pytorch\third_party\ideep\mkl-dnn\include\oneapi\dnnl -external:IE:\PyTorch_Build\pytorch\third_party\ideep\include -external:IE:\PyTorch_Build\pytorch\INTERFACE -external:IE:\PyTorch_Build\pytorch\third_party\nlohmann\include -external:IE:\PyTorch_Build\pytorch\third_party\concurrentqueue -external:IE:\PyTorch_Build\pytorch\rtx5070_env\lib\site-packages\numpy\_core\include -external:IE:\Python310\Include -external:I"E:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\include" -external:IE:\PyTorch_Build\pytorch\cmake\..\third_party\pybind11\include -external:IE:\PyTorch_Build\pytorch\cmake\..\third_party\opentelemetry-cpp\api\include -external:IE:\PyTorch_Build\pytorch\third_party\cpp-httplib -external:IE:\PyTorch_Build\pytorch\third_party\NVTX\c\include -external:W0 /DWIN32 /D_WINDOWS /EHsc /Zc:__cplusplus /bigobj /FS /utf-8 -DUSE_PTHREADPOOL -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOROCTRACER -DLIBKINETO_NOXPUPTI=ON -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE /wd4624 /wd4068 /wd4067 /wd4267 /wd4661 /wd4717 /wd4244 /wd4804 /wd4273 -DHAVE_AVX512_CPU_DEFINITION -DHAVE_AVX2_CPU_DEFINITION /Zc:preprocessor /Zc:preprocessor /Zc:preprocessor /O2 /Ob2 /DNDEBUG /bigobj -DNDEBUG -std:c++17 -MD /permissive- /EHsc /bigobj -O2 /utf-8 /showIncludes /Focaffe2\torch\CMakeFiles\torch_python.dir\csrc\Storage.cpp.obj /Fdcaffe2\torch\CMakeFiles\torch_python.dir\ /FS -c E:\PyTorch_Build\pytorch\torch\csrc\Storage.cpp E:\PyTorch_Build\pytorch\torch\csrc\Storage.cpp(10): fatal error C1083: 无法打开包括文件: “libshm.h”: No such file or directory [4856/7459] Building CXX object caffe2\torch\CMakeFiles\torch_python.dir\csrc\Module.cpp.obj FAILED: [code=2] caffe2/torch/CMakeFiles/torch_python.dir/csrc/Module.cpp.obj C:\PROGRA~2\MICROS~2\2022\BUILDT~1\VC\Tools\MSVC\1444~1.352\bin\Hostx64\x64\cl.exe /nologo /TP -DAT_PER_OPERATOR_HEADERS -DBUILDING_TESTS -DEXPORT_AOTI_FUNCTIONS -DFMT_HEADER_ONLY=1 -DMINIZ_DISABLE_ZIP_READER_CRC32_CHECKS -DNOMINMAX -DONNXIFI_ENABLE_EXT=1 -DONNX_ML=1 -DONNX_NAMESPACE=onnx_torch -DPy_NO_LINK_LIB -DTHP_BUILD_MAIN_LIB -DTORCH_CUDA_USE_NVTX3 -DUSE_CUDA -DUSE_EXTERNAL_MZCRC -DUSE_ITT -DUSE_MIMALLOC -DUSE_NUMPY -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_DEPRECATE=1 -D_UCRT_LEGACY_INFINITY -Dtorch_python_EXPORTS -IE:\PyTorch_Build\pytorch\build\aten\src -IE:\PyTorch_Build\pytorch\aten\src -IE:\PyTorch_Build\pytorch\build -IE:\PyTorch_Build\pytorch -IE:\PyTorch_Build\pytorch\nlohmann -IE:\PyTorch_Build\pytorch\moodycamel -IE:\PyTorch_Build\pytorch\third_party\mimalloc\include -IE:\PyTorch_Build\pytorch\torch\.. -IE:\PyTorch_Build\pytorch\torch\..\aten\src -IE:\PyTorch_Build\pytorch\torch\..\aten\src\TH -IE:\PyTorch_Build\pytorch\build\caffe2\aten\src -IE:\PyTorch_Build\pytorch\build\third_party -IE:\PyTorch_Build\pytorch\build\third_party\onnx -IE:\PyTorch_Build\pytorch\torch\..\third_party\valgrind-headers -IE:\PyTorch_Build\pytorch\torch\..\third_party\gloo -IE:\PyTorch_Build\pytorch\torch\..\third_party\onnx -IE:\PyTorch_Build\pytorch\torch\..\third_party\flatbuffers\include -IE:\PyTorch_Build\pytorch\torch\..\third_party\kineto\libkineto\include -IE:\PyTorch_Build\pytorch\torch\..\third_party\cpp-httplib -IE:\PyTorch_Build\pytorch\torch\..\third_party\nlohmann\include -IE:\PyTorch_Build\pytorch\torch\csrc -IE:\PyTorch_Build\pytorch\torch\csrc\api\include -IE:\PyTorch_Build\pytorch\torch\lib -IE:\PyTorch_Build\pytorch\torch\standalone -IE:\PyTorch_Build\pytorch\torch\lib\libshm_windows -IE:\PyTorch_Build\pytorch\torch\csrc\api -IE:\PyTorch_Build\pytorch\c10\.. -IE:\PyTorch_Build\pytorch\c10\cuda\..\.. -IE:\PyTorch_Build\pytorch\third_party\fmt\include -IE:\PyTorch_Build\pytorch\third_party\onnx -external:IE:\PyTorch_Build\pytorch\cmake\..\third_party\googletest\googlemock\include -external:IE:\PyTorch_Build\pytorch\cmake\..\third_party\googletest\googletest\include -external:IE:\PyTorch_Build\pytorch\third_party\protobuf\src -external:IE:\PyTorch_Build\pytorch\third_party\XNNPACK\include -external:IE:\PyTorch_Build\pytorch\third_party\ittapi\include -external:IE:\PyTorch_Build\pytorch\cmake\..\third_party\eigen -external:IE:\PyTorch_Build\pytorch\third_party\ideep\mkl-dnn\include\oneapi\dnnl -external:IE:\PyTorch_Build\pytorch\third_party\ideep\include -external:IE:\PyTorch_Build\pytorch\INTERFACE -external:IE:\PyTorch_Build\pytorch\third_party\nlohmann\include -external:IE:\PyTorch_Build\pytorch\third_party\concurrentqueue -external:IE:\PyTorch_Build\pytorch\rtx5070_env\lib\site-packages\numpy\_core\include -external:IE:\Python310\Include -external:I"E:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\include" -external:IE:\PyTorch_Build\pytorch\cmake\..\third_party\pybind11\include -external:IE:\PyTorch_Build\pytorch\cmake\..\third_party\opentelemetry-cpp\api\include -external:IE:\PyTorch_Build\pytorch\third_party\cpp-httplib -external:IE:\PyTorch_Build\pytorch\third_party\NVTX\c\include -external:W0 /DWIN32 /D_WINDOWS /EHsc /Zc:__cplusplus /bigobj /FS /utf-8 -DUSE_PTHREADPOOL -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOROCTRACER -DLIBKINETO_NOXPUPTI=ON -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE /wd4624 /wd4068 /wd4067 /wd4267 /wd4661 /wd4717 /wd4244 /wd4804 /wd4273 -DHAVE_AVX512_CPU_DEFINITION -DHAVE_AVX2_CPU_DEFINITION /Zc:preprocessor /Zc:preprocessor /Zc:preprocessor /O2 /Ob2 /DNDEBUG /bigobj -DNDEBUG -std:c++17 -MD /permissive- /EHsc /bigobj -O2 /utf-8 /showIncludes /Focaffe2\torch\CMakeFiles\torch_python.dir\csrc\Module.cpp.obj /Fdcaffe2\torch\CMakeFiles\torch_python.dir\ /FS -c E:\PyTorch_Build\pytorch\torch\csrc\Module.cpp E:\PyTorch_Build\pytorch\torch\csrc\Module.cpp(34): fatal error C1083: 无法打开包括文件: “libshm.h”: No such file or directory [4872/7459] Building CUDA object caffe2\CMakeFiles\torch_cuda.dir\__\aten\src\ATen\native\cuda\group_norm_kernel.cu.obj group_norm_kernel.cu tmpxft_00005adc_00000000-7_group_norm_kernel.cudafe1.cpp [4873/7459] Building CUDA object caffe2\CMakeFiles\torch_cuda.dir\__\aten\src\ATen\UfuncCUDA_add.cu.obj UfuncCUDA_add.cu tmpxft_00006bdc_00000000-7_UfuncCUDA_add.cudafe1.cpp [4875/7459] Building CUDA object caffe2\CMakeFiles\torch_cuda.dir\__\aten\src\ATen\native\cuda\Unique.cu.obj Unique.cu tmpxft_00000658_00000000-7_Unique.cudafe1.cpp ninja: build stopped: subcommand failed. (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch>” “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 Error: [Errno 13] Permission denied: 'E:\\PyTorch_Build\\pytorch\\rtx5070_env\\Scripts\\python.exe' PS E:\PyTorch_Build\pytorch> .\rtx5070_env\Scripts\activate (rtx5070_env) PS E:\PyTorch_Build\pytorch> conda install -c conda-forge openblas 3 channel Terms of Service accepted Retrieving notices: done Channels: - conda-forge - defaults - nvidia - pytorch-nightly Platform: win-64 Collecting package metadata (repodata.json): done Solving environment: done ## Package Plan ## environment location: C:\Miniconda3 added / updated specs: - openblas The following packages will be downloaded: package | build ---------------------------|----------------- libopenblas-0.3.30 |pthreads_ha4fe6b2_2 3.8 MB conda-forge openblas-0.3.30 |pthreads_h4a7f399_2 262 KB conda-forge ------------------------------------------------------------ Total: 4.0 MB The following NEW packages will be INSTALLED: libopenblas conda-forge/win-64::libopenblas-0.3.30-pthreads_ha4fe6b2_2 openblas conda-forge/win-64::openblas-0.3.30-pthreads_h4a7f399_2 Proceed ([y]/n)? y Downloading and Extracting Packages: Preparing transaction: done Verifying transaction: done Executing transaction: done (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 设置cuDNN路径 (rtx5070_env) PS E:\PyTorch_Build\pytorch> @" >> set(CUDNN_INCLUDE_DIR "E:/Program Files/NVIDIA/CUNND/v9.12/include/13.0") >> set(CUDNN_LIBRARY "E:/Program Files/NVIDIA/CUNND/v9.12/lib/13.0/x64/cudnn64_9.lib") >> message(STATUS "Applied custom cuDNN settings") >> "@ | Set-Content set_cudnn.cmake (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 在CMakeLists.txt第一行插入引用 (rtx5070_env) PS E:\PyTorch_Build\pytorch> $cmakeFile = "CMakeLists.txt" (rtx5070_env) PS E:\PyTorch_Build\pytorch> $content = Get-Content $cmakeFile (rtx5070_env) PS E:\PyTorch_Build\pytorch> $newContent = @() (rtx5070_env) PS E:\PyTorch_Build\pytorch> $newContent += "include(set_cudnn.cmake)" (rtx5070_env) PS E:\PyTorch_Build\pytorch> $newContent += $content (rtx5070_env) PS E:\PyTorch_Build\pytorch> $newContent | Set-Content $cmakeFile (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 安装OpenBLAS (rtx5070_env) PS E:\PyTorch_Build\pytorch> conda install -c conda-forge openblas -y 3 channel Terms of Service accepted Channels: - conda-forge - defaults - nvidia - pytorch-nightly Platform: win-64 Collecting package metadata (repodata.json): done Solving environment: done # All requested packages already installed. (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> Write-Host "✅ 构建环境优化完成" -ForegroundColor Green ✅ 构建环境优化完成 (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 检查GPU支持状态 (rtx5070_env) PS E:\PyTorch_Build\pytorch> python -c "import torch; print(f'CUDA可用: {torch.cuda.is_available()}')" Traceback (most recent call last): File "<string>", line 1, in <module> File "E:\PyTorch_Build\pytorch\torch\__init__.py", line 415, in <module> from torch._C import * # noqa: F403 ImportError: DLL load failed while importing _C: 找不到指定的模块。 (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 查看已完成任务比例 (rtx5070_env) PS E:\PyTorch_Build\pytorch> $total = 7459 (rtx5070_env) PS E:\PyTorch_Build\pytorch> $completed = (Get-ChildItem build -Recurse -File | Measure-Object).Count (rtx5070_env) PS E:\PyTorch_Build\pytorch> $percent = [math]::Round(($completed/$total)*100, 2) (rtx5070_env) PS E:\PyTorch_Build\pytorch> Write-Host "构建进度: $completed/$total ($percent%)" 构建进度: 12552/7459 (168.28%) (rtx5070_env) PS E:\PyTorch_Build\pytorch>”
09-04
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值