【解决方案】安装vssdk_full.exe遇到的问题

本文提供了解决将文件重命名回其原始名称并重新尝试设置的方法。包括查看文件属性、重命名步骤及转自链接。

Stop Block: CompatibilityMode : Windows Program Compatibility mode is on. Turn it off and then try Setup again.

 

查看文件的属性->详细信息->原始文件名

解决方案:

将文件重命名为原始文件名。

转载于:https://www.cnblogs.com/jackson0714/p/5189677.html

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> 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 (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 设置执行策略 (rtx5070_env) PS E:\PyTorch_Build\pytorch> Set-ExecutionPolicy RemoteSigned -Scope Process -Force (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 创建所有脚本文件 (rtx5070_env) PS E:\PyTorch_Build\pytorch> # [粘贴上面的四个脚本创建命令] (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 运行完整构建流程 (rtx5070_env) PS E:\PyTorch_Build\pytorch> .\full_build.ps1 (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 验证CUDA编译 (rtx5070_env) PS E:\PyTorch_Build\pytorch> .\compile_cuda_test.ps1 ParserError: E:\PyTorch_Build\pytorch\compile_cuda_test.ps1:56 Line | 56 | '@ | Set-Content compile_cuda_test.ps1 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | The string is missing the terminator: '. (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 验证PyTorch安装 (rtx5070_env) PS E:\PyTorch_Build\pytorch> 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> PowerShell 7 环境已加载 (版本: 7.5.2) 版本:: The term '版本:' 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> PS C:\Users\Administrator\Desktop> cd E:\PyTorch_Build\pytorch Get-Process: A positional parameter cannot be found that accepts argument 'cd'. (rtx5070_env) PS E:\PyTorch_Build\pytorch> PS E:\PyTorch_Build\pytorch> python -m venv rtx5070_env Get-Process: A positional parameter cannot be found that accepts argument 'python'. (rtx5070_env) PS E:\PyTorch_Build\pytorch> PS E:\PyTorch_Build\pytorch> .\rtx5070_env\Scripts\activate Get-Process: A positional parameter cannot be found that accepts argument '.\rtx5070_env\Scripts\activate'. (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 创建虚拟环境 ParserError: Line | 1 | (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 创建虚拟环境 | ~~ | Unexpected token 'PS' in expression or statement. (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> python -m venv rtx5070_env ParserError: Line | 1 | (rtx5070_env) PS E:\PyTorch_Build\pytorch> python -m venv rtx5070_env | ~~ | Unexpected token 'PS' in expression or statement. (rtx5070_env) PS E:\PyTorch_Build\pytorch> Error: [Errno 13] Permission denied: 'E:\\PyTorch_Build\\pytorch\\rtx5070_env\\Scripts\\python.exe' Error:: The term 'Error:' 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> .\rtx5070_env\Scripts\activate ParserError: Line | 1 | (rtx5070_env) PS E:\PyTorch_Build\pytorch> .\rtx5070_env\Scripts\acti … | ~~ | Unexpected token 'PS' in expression or statement. (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> ParserError: Line | 1 | (rtx5070_env) PS E:\PyTorch_Build\pytorch> | ~~ | Unexpected token 'PS' in expression or statement. (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 设置执行策略 ParserError: Line | 1 | (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 设置执行策略 | ~~ | Unexpected token 'PS' in expression or statement. (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> Set-ExecutionPolicy RemoteSigned -Scope Process -Force ParserError: Line | 1 | (rtx5070_env) PS E:\PyTorch_Build\pytorch> Set-ExecutionPolicy Remote … | ~~ | Unexpected token 'PS' in expression or statement. (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> ParserError: Line | 1 | (rtx5070_env) PS E:\PyTorch_Build\pytorch> | ~~ | Unexpected token 'PS' in expression or statement. (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 创建所有脚本文件 ParserError: Line | 1 | (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 创建所有脚本文件 | ~~ | Unexpected token 'PS' in expression or statement. (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # [粘贴上面的四个脚本创建命令] ParserError: Line | 1 | (rtx5070_env) PS E:\PyTorch_Build\pytorch> # [粘贴上面的四个脚本创建命令] | ~~ | Unexpected token 'PS' in expression or statement. (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> ParserError: Line | 1 | (rtx5070_env) PS E:\PyTorch_Build\pytorch> | ~~ | Unexpected token 'PS' in expression or statement. (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 运行完整构建流程 ParserError: Line | 1 | (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 运行完整构建流程 | ~~ | Unexpected token 'PS' in expression or statement. (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> .\full_build.ps1 ParserError: Line | 1 | (rtx5070_env) PS E:\PyTorch_Build\pytorch> .\full_build.ps1 | ~~ | Unexpected token 'PS' in expression or statement. (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> ParserError: Line | 1 | (rtx5070_env) PS E:\PyTorch_Build\pytorch> | ~~ | Unexpected token 'PS' in expression or statement. (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 验证CUDA编译 ParserError: Line | 1 | (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 验证CUDA编译 | ~~ | Unexpected token 'PS' in expression or statement. (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> .\compile_cuda_test.ps1 ParserError: Line | 1 | (rtx5070_env) PS E:\PyTorch_Build\pytorch> .\compile_cuda_test.ps1 | ~~ | Unexpected token 'PS' in expression or statement. (rtx5070_env) PS E:\PyTorch_Build\pytorch> ParserError: E:\PyTorch_Build\pytorch\compile_cuda_test.ps1:56 ParserError:: The term 'ParserError:' 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> Line | >> 56 | '@ | Set-Content compile_cuda_test.ps1 >> | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> | The string is missing the terminator: '. >> (rtx5070_env) PS E:\PyTorch_Build\pytorch> ParserError: Line | 2 | 56 | '@ | Set-Content compile_cuda_test.ps1 | ~~ | Expressions are only allowed as the first element of a pipeline. (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 验证PyTorch安装 ParserError: Line | 1 | (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 验证PyTorch安装 | ~~ | Unexpected token 'PS' in expression or statement. (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> python -c "import torch; print(f'PyTorch版本: {torch.__version__}'); print(f'CUDA可用: {torch.cuda.is_available()}')" ParserError: Line | 1 | (rtx5070_env) PS E:\PyTorch_Build\pytorch> python -c "import torch; p … | ~~ | Unexpected token 'PS' in expression or statement. (rtx5070_env) PS E:\PyTorch_Build\pytorch> PyTorch版本: 2.8.0+cpu PyTorch版本:: The term 'PyTorch版本:' 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> CUDA可用: False CUDA可用:: The term 'CUDA可用:' 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> ParserError: Line | 1 | (rtx5070_env) PS E:\PyTorch_Build\pytorch> | ~~ | Unexpected token 'PS' in expression or statement. (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 1. 环境设置脚本 (rtx5070_env) PS E:\PyTorch_Build\pytorch> @" >> # setup_environment.ps1 >> Set-ExecutionPolicy RemoteSigned -Scope Process -Force >> >> `$vsPath = "C:\Program Files\Microsoft Visual Studio\2022\Community" >> `$vcPath = "`$vsPath\VC\Tools\MSVC" >> `$sdkPath = "C:\Program Files (x86)\Windows Kits\10" >> >> # 获取最新MSVC版本 >> `$msvcVersions = Get-ChildItem -Path `$vcPath | >> Where-Object { `$_.Name -match '^\d+\.\d+\.\d+' } | >> Sort-Object { [version]`$_.Name } -Descending >> `$latestMsvc = `$msvcVersions | Select-Object -First 1 >> `$msvcVersion = `$latestMsvc.Name >> `$env:VCToolsInstallDir = "`$vcPath\`$msvcVersion" >> >> # 获取最新Windows SDK >> `$sdkVersions = Get-ChildItem -Path "`$sdkPath\Include" | >> Where-Object { `$_.Name -match '^\d+\.\d+\.\d+' } | >> Sort-Object { [version]`$_.Name } -Descending >> `$latestSdk = `$sdkVersions | Select-Object -First 1 >> `$sdkVersion = `$latestSdk.Name >> >> # 设置环境变量 >> `$env:PATH = @( >> "`$env:VCToolsInstallDir\bin\Hostx64\x64", >> "`$sdkPath\bin\`$sdkVersion\x64", >> "E:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\bin", >> "E:\Program Files\NVIDIA\CUDNN\v9.12\bin", >> `$env:PATH >> ) -join ';' >> >> `$env:INCLUDE = @( >> "`$env:VCToolsInstallDir\include", >> "`$sdkPath\Include\`$sdkVersion\um", >> "`$sdkPath\Include\`$sdkVersion\ucrt", >> "`$sdkPath\Include\`$sdkVersion\shared", >> "E:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\include", >> `$env:INCLUDE >> ) -join ';' >> >> `$env:LIB = @( >> "`$env:VCToolsInstallDir\lib\x64", >> "`$sdkPath\Lib\`$sdkVersion\um\x64", >> "`$sdkPath\Lib\`$sdkVersion\ucrt\x64", >> "E:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\lib\x64", >> `$env:LIB >> ) -join ';' >> >> # 设置CUDA编译器 >> `$env:CUDA_HOST_COMPILER = "`$env:VCToolsInstallDir\bin\Hostx64\x64\cl.exe" >> "@ | Set-Content setup_environment.ps1 (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 2. CMake配置脚本 (rtx5070_env) PS E:\PyTorch_Build\pytorch> @" >> # cmake_config.ps1 >> `$sourceDir = (Get-Item -Path "..").FullName >> `$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=10.0.22621.0", >> "-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)" >> ) >> >> Write-Host "运行 CMake: cmake `$sourceDir @cmakeArgs" >> cmake `$sourceDir @cmakeArgs >> "@ | Set-Content cmake_config.ps1 (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 3. 完整构建脚本 (rtx5070_env) PS E:\PyTorch_Build\pytorch> @" >> # full_build.ps1 >> # 初始化环境 >> .\setup_environment.ps1 >> >> # 准备构建目录 >> Set-Location E:\PyTorch_Build\pytorch >> Remove-Item build -Recurse -Force -ErrorAction SilentlyContinue >> New-Item -Path build -ItemType Directory | Out-Null >> Set-Location build >> >> # 配置 CMake >> .\cmake_config.ps1 >> >> # 编译和安装 >> if (`$LASTEXITCODE -eq 0) { >> cmake --build . --config Release --parallel 8 >> if (`$LASTEXITCODE -eq 0) { >> cmake --install . >> } >> } >> >> # 验证安装 >> python -c "import torch; print(f'PyTorch版本: {torch.__version__}'); print(f'CUDA可用: {torch.cuda.is_available()}')" >> "@ | Set-Content full_build.ps1 (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 4. CUDA测试脚本(修复终止符问题) (rtx5070_env) PS E:\PyTorch_Build\pytorch> @" >> # compile_cuda_test.ps1 >> # 创建CUDA测试程序 >> `$cudaTest = @' >> #include <cuda_runtime.h> >> #include <iostream> >> >> __global__ void addKernel(int *c, const int *a, const int *b) { >> int i = threadIdx.x; >> c[i] = a[i] + b[i]; >> } >> >> int main() { >> const int arraySize = 5; >> const int a[arraySize] = {1, 2, 3, 4, 5}; >> const int b[arraySize] = {10, 20, 30, 40, 50}; >> int c[arraySize] = {0}; >> >> int *dev_a, *dev_b, *dev_c; >> cudaMalloc(&dev_a, arraySize * sizeof(int)); >> cudaMalloc(&dev_b, arraySize * sizeof(int)); >> cudaMalloc(&dev_c, arraySize * sizeof(int)); >> >> cudaMemcpy(dev_a, a, arraySize * sizeof(int), cudaMemcpyHostToDevice); >> cudaMemcpy(dev_b, b, arraySize * sizeof(int), cudaMemcpyHostToDevice); >> >> addKernel<<<1, arraySize>>>(dev_c, dev_a, dev_b); >> cudaMemcpy(c, dev_c, arraySize * sizeof(int), cudaMemcpyDeviceToHost); >> >> std::cout << "CUDA测试结果: "; >> for (int i = 0; i < arraySize; i++) { >> std::cout << c[i] << " "; >> } >> >> cudaFree(dev_a); >> cudaFree(dev_b); >> cudaFree(dev_c); >> return 0; >> } >> '@ >> >> `$cudaTest | Set-Content cuda_test.cpp >> >> # 编译测试 >> `$ccbinPath = "`$env:VCToolsInstallDir\bin\Hostx64\x64" >> nvcc -ccbin "`$ccbinPath" cuda_test.cpp -o cuda_test >> >> # 运行测试 >> if (Test-Path cuda_test.exe) { >> .\cuda_test.exe >> } else { >> Write-Host "CUDA编译失败,请检查环境" >> } >> "@ | Set-Content compile_cuda_test.ps1 (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 1. 确保在正确目录 (rtx5070_env) PS E:\PyTorch_Build\pytorch> cd 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> Get-Process python* | Stop-Process -Force -ErrorAction SilentlyContinue (rtx5070_env) PS E:\PyTorch_Build\pytorch> Remove-Item rtx5070_env -Recurse -Force -ErrorAction SilentlyContinue (rtx5070_env) PS E:\PyTorch_Build\pytorch> python -m venv rtx5070_env (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> # 3. 设置执行策略 (rtx5070_env) PS E:\PyTorch_Build\pytorch> Set-ExecutionPolicy RemoteSigned -Scope Process -Force (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 4. 创建所有脚本文件 (rtx5070_env) PS E:\PyTorch_Build\pytorch> # [粘贴上面的脚本创建命令] (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 5. 执行构建流程 (rtx5070_env) PS E:\PyTorch_Build\pytorch> .\full_build.ps1 .\cmake_config.ps1: E:\PyTorch_Build\pytorch\full_build.ps1:12 Line | 12 | .\cmake_config.ps1 | ~~~~~~~~~~~~~~~~~~ | The term '.\cmake_config.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. Error: not a CMake build directory (missing CMakeCache.txt) Traceback (most recent call last): File "<string>", line 1, in <module> ModuleNotFoundError: No module named 'torch' (rtx5070_env) PS E:\PyTorch_Build\pytorch\build> (rtx5070_env) PS E:\PyTorch_Build\pytorch\build> # 6. 验证CUDA编译 (rtx5070_env) PS E:\PyTorch_Build\pytorch\build> .\compile_cuda_test.ps1 .\compile_cuda_test.ps1: The term '.\compile_cuda_test.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> # 7. 验证PyTorch安装 (rtx5070_env) PS E:\PyTorch_Build\pytorch\build> 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> ModuleNotFoundError: No module named 'torch' (rtx5070_env) PS E:\PyTorch_Build\pytorch\build> if ($?) { >> python -c @" >> import torch >> print(f'CUDA设备数量: {torch.cuda.device_count()}') >> if torch.cuda.is_available(): >> print(f'设备0名称: {torch.cuda.get_device_name(0)}') >> "@ >> } (rtx5070_env) PS E:\PyTorch_Build\pytorch\build>
最新发布
09-03
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> # 正确加载 Visual Studio 构建环境 (rtx5070_env) PS E:\PyTorch_Build\pytorch> $vsPath = "C:\Program Files\Microsoft Visual Studio\2022\Community" (rtx5070_env) PS E:\PyTorch_Build\pytorch> & "$vsPath\VC\Auxiliary\Build\vcvars64.bat" x64 ********************************************************************** ** 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> # 验证环境加载 (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> # 正确设置 CMake 参数数组 (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=10.0.22621.0", >> "-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)" >> ) (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 运行 CMake (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> # 设置执行策略 (rtx5070_env) PS E:\PyTorch_Build\pytorch> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process -Force (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 加载 VS 环境 (rtx5070_env) PS E:\PyTorch_Build\pytorch> .\vs_env_setup.ps1 .\vs_env_setup.ps1: The term '.\vs_env_setup.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> # 设置 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:CUDNN_PATH = "E:/Program Files/NVIDIA/CUDNN/v9.12" (rtx5070_env) PS E:\PyTorch_Build\pytorch> $env:PATH = "$env:CUDA_PATH/bin;$env:CUDNN_PATH/bin;$env:PATH" (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 准备构建目录 (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> # 配置 CMake (rtx5070_env) PS E:\PyTorch_Build\pytorch\build> .\cmake_config.ps1 .\cmake_config.ps1: The term '.\cmake_config.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> # 编译和安装 (rtx5070_env) PS E:\PyTorch_Build\pytorch\build> if ($LASTEXITCODE -eq 0) { >> cmake --build . --config Release --parallel 8 >> if ($LASTEXITCODE -eq 0) { >> cmake --install . >> } >> } (rtx5070_env) PS E:\PyTorch_Build\pytorch\build> (rtx5070_env) PS E:\PyTorch_Build\pytorch\build> # 验证安装 (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> python -c @" >> import torch >> import platform >> import os >> >> print('===== 系统信息 =====') >> print(f'操作系统: {platform.system()} {platform.release()}') >> print(f'Python版本: {platform.python_version()}') >> print(f'PyTorch版本: {torch.__version__}') >> >> print('\n===== CUDA 支持 =====') >> 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.device_count()}') >> >> for i in range(torch.cuda.device_count()): >> props = torch.cuda.get_device_properties(i) >> print(f'\n设备 {i}: {props.name}') >> print(f' 计算能力: {props.major}.{props.minor}') >> print(f' 内存: {props.total_memory/1024**3:.2f} GB') >> >> # GPU 计算测试 >> try: >> a = torch.randn(10000, 10000, device='cuda') >> b = torch.randn(10000, 10000, device='cuda') >> c = torch.matmul(a, b) >> print('\n===== 计算测试 =====') >> print(f'矩阵乘法完成 | 结果形状: {c.shape}') >> except Exception as e: >> print(f'计算测试失败: {str(e)}') >> else: >> print('\n===== 错误诊断 =====') >> print('编译配置信息:') >> print(torch.__config__.show()) >> >> print('\n环境变量检查:') >> print(f'CUDA_HOME: {os.environ.get("CUDA_HOME", "未设置")}') >> print(f'PATH包含CUDA: {"CUDA" in os.environ.get("PATH", "")}') >> print(f'NVCC路径: {os.environ.get("CUDA_PATH", "未设置")}') >> "@ ===== 系统信息 ===== 操作系统: Windows 10 Python版本: 3.10.10 PyTorch版本: 2.8.0+cpu ===== CUDA 支持 ===== CUDA可用: False ===== 错误诊断 ===== 编译配置信息: PyTorch built with: - C++ Version: 201703 - MSVC 193833145 - Intel(R) oneAPI Math Kernel Library Version 2025.2-Product Build 20250620 for Intel(R) 64 architecture applications - Intel(R) MKL-DNN v3.7.1 (Git Hash 8d263e693366ef8db40acc569cc7d8edf644556d) - OpenMP 2019 - LAPACK is enabled (usually provided by MKL) - CPU capability usage: AVX2 - Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, COMMIT_SHA=a1cb3cc05d46d198467bebbb6e8fba50a325d4e7, CXX_COMPILER=C:/actions-runner/_work/pytorch/pytorch/pytorch/.ci/pytorch/windows/tmp_bin/sccache-cl.exe, CXX_FLAGS=/DWIN32 /D_WINDOWS /EHsc /Zc:__cplusplus /bigobj /FS /utf-8 -DUSE_PTHREADPOOL -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOCUPTI -DLIBKINETO_NOROCTRACER -DLIBKINETO_NOXPUPTI=ON -DUSE_FBGEMM -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE /wd4624 /wd4068 /wd4067 /wd4267 /wd4661 /wd4717 /wd4244 /wd4804 /wd4273, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, TORCH_VERSION=2.8.0, USE_CUDA=0, USE_CUDNN=OFF, USE_CUSPARSELT=OFF, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_GLOO=ON, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=OFF, USE_NNPACK=OFF, USE_OPENMP=ON, USE_ROCM=OFF, USE_ROCM_KERNEL_ASSERT=OFF, USE_XCCL=OFF, USE_XPU=OFF, 环境变量检查: CUDA_HOME: E:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.1 PATH包含CUDA: True NVCC路径: E:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v13.0 (rtx5070_env) PS E:\PyTorch_Build\pytorch\build> "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> # 创建 CUDA 测试程序 (rtx5070_env) PS E:\PyTorch_Build\pytorch> @' >> #include <cuda_runtime.h> >> #include <iostream> >> >> __global__ void addKernel(int *c, const int *a, const int *b) { >> int i = threadIdx.x; >> c[i] = a[i] + b[i]; >> } >> >> int main() { >> const int arraySize = 5; >> const int a[arraySize] = {1, 2, 3, 4, 5}; >> const int b[arraySize] = {10, 20, 30, 40, 50}; >> int c[arraySize] = {0}; >> >> int *dev_a, *dev_b, *dev_c; >> cudaMalloc(&dev_a, arraySize * sizeof(int)); >> cudaMalloc(&dev_b, arraySize * sizeof(int)); >> cudaMalloc(&dev_c, arraySize * sizeof(int)); >> >> cudaMemcpy(dev_a, a, arraySize * sizeof(int), cudaMemcpyHostToDevice); >> cudaMemcpy(dev_b, b, arraySize * sizeof(int), cudaMemcpyHostToDevice); >> >> addKernel<<<1, arraySize>>>(dev_c, dev_a, dev_b); >> cudaMemcpy(c, dev_c, arraySize * sizeof(int), cudaMemcpyDeviceToHost); >> >> std::cout << "CUDA 测试结果: "; >> for (int i = 0; i < arraySize; i++) { >> std::cout << c[i] << " "; >> } >> >> cudaFree(dev_a); >> cudaFree(dev_b); >> cudaFree(dev_c); >> return 0; >> } >> '@ | Set-Content cuda_test.cpp (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 编译测试 (rtx5070_env) PS E:\PyTorch_Build\pytorch> nvcc cuda_test.cpp -o cuda_test nvcc fatal : Cannot find compiler 'cl.exe' in PATH (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 运行测试 (rtx5070_env) PS E:\PyTorch_Build\pytorch> if (Test-Path cuda_test.exe) { >> .\cuda_test.exe >> } else { >> Write-Host "CUDA 编译失败,请检查环境" >> } CUDA 编译失败,请检查环境 (rtx5070_env) PS E:\PyTorch_Build\pytorch> .\full_build.ps1 ********************************************************************** ** Visual Studio 2022 Developer Command Prompt v17.14.13 ** Copyright (c) 2025 Microsoft Corporation ********************************************************************** [vcvarsall.bat] Environment initialized for: 'x64' cl.exe: E:\PyTorch_Build\pytorch\vs_env_setup.ps1:6 Line | 6 | 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. link.exe: E:\PyTorch_Build\pytorch\vs_env_setup.ps1:7 Line | 7 | 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. .\cmake_config.ps1: E:\PyTorch_Build\pytorch\full_build.ps1:19 Line | 19 | .\cmake_config.ps1 | ~~~~~~~~~~~~~~~~~~ | The term '.\cmake_config.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. Error: not a CMake build directory (missing CMakeCache.txt) PyTorch版本: 2.8.0+cpu CUDA可用: False (rtx5070_env) PS E:\PyTorch_Build\pytorch\build> .\verify_pytorch.ps1 .\verify_pytorch.ps1: The term '.\verify_pytorch.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> .\compile_test.ps1 .\compile_test.ps1: The term '.\compile_test.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>"
09-03
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值