cudart link错误自动修复脚本

部署运行你感兴趣的模型镜像

问题

在conda安装cuda环境时

mamba install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia -y
mamba install nvidia/label/cuda-12.1.0::cuda

安装的envs/xxx/lib/libcudart.so 会link到错的

如果手动修复太复杂,我写了一个脚本自动修复

脚本

#!/bin/bash

# 检查是否提供了环境名称作为参数
if [ "$#" -ne 1 ]; then
    echo "Usage: $0 <environment_name>"
    exit 1
fi

env_name=$1
env_path="/mnt/data/wangziyi/miniconda3/envs/$env_name/lib"

# 检查环境路径是否存在
if [ ! -d "$env_path" ]; then
    echo "Error: The environment path $env_path does not exist."
    exit 1
fi

# 使用find命令和正则表达式来查找最长的libcudart.so文件名
cudart_so_file=$(find "$env_path" -type f -regextype posix-extended -regex "$env_path/libcudart\.so\.[0-9]+\.[0-9]+\.[0-9]+" -printf '%f\n' | sort -rV | head -n 1)

# 检查是否找到了文件
if [ -z "$cudart_so_file" ]; then
    echo "Error: No file matching libcudart.so.<version> was found in the environment."
    exit 1
fi

# 创建或更新libcudart.so的符号链接
ln -sf "$env_path/$cudart_so_file" "$env_path/libcudart.so"

echo "Symbol link for libcudart.so has been updated to $cudart_so_file."

在这里插入图片描述

新版

function fixcuda() {
    # 检查是否提供了环境名称作为参数
    if [ "$#" -ne 1 ]; then
        # 如果没有提供参数,使用环境变量CONDA_DEFAULT_ENV的值
        env_name=${CONDA_DEFAULT_ENV:-"base"}
    else
        env_name=$1
    fi

    env_path="$HOME/miniconda3/envs/$env_name/lib"
    echo "Environment path: $env_path"

    ls -l $env_path | grep cuda

    # 检查环境路径是否存在
    if [ ! -d "$env_path" ]; then
        echo "Error: The environment path $env_path does not exist."
        exit 1
    fi

    # 使用find命令和正则表达式来查找最长的libcudart.so文件名
    cudart_so_file=$(find "$env_path" -type f -regextype posix-extended -regex "$env_path/libcudart\.so\.[0-9]+\.[0-9]+\.[0-9]+" -printf '%f\n' | sort -rV | head -n 1)

    # 检查是否找到了文件
    if [ -z "$cudart_so_file" ]; then
        echo "Error: No file matching libcudart.so.<version> was found in the environment."
        exit 1
    fi

    # 创建或更新libcudart.so的符号链接
    ln -sf "$env_path/$cudart_so_file" "$env_path/libcudart.so"

    echo "Symbol link for libcudart.so has been updated to $cudart_so_file."
}

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

PyTorch 2.5

PyTorch 2.5

PyTorch
Cuda

PyTorch 是一个开源的 Python 机器学习库,基于 Torch 库,底层由 C++ 实现,应用于人工智能领域,如计算机视觉和自然语言处理

FAILED: [code=2] sleef/src/common/CMakeFiles/addSuffix.dir/addSuffix.c.obj C:\PROGRA~1\MICROS~3\2022\COMMUN~1\VC\Tools\MSVC\1444~1.352\bin\Hostx64\x64\cl.exe /nologo -DEXPORT_AOTI_FUNCTIONS -DMINIZ_DISABLE_ZIP_READER_CRC32_CHECKS -DNOMINMAX -DONNXIFI_ENABLE_EXT=1 -DONNX_ML=1 -DONNX_NAMESPACE=onnx_torch -DUSE_EXTERNAL_MZCRC -DUSE_MIMALLOC -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_DEPRECATE=1 -D_UCRT_LEGACY_INFINITY -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\third_party\sleef\src\common -IE:\PyTorch_Build\pytorch\third_party\sleef\src\arch -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\torch\include -external:IE:\PyTorch_Build\pytorch\cmake\..\third_party\eigen -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:W0 /DWIN32 /D_WINDOWS /bigobj -DNDEBUG /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_DEPRECATE /O2 /Ob2 /DNDEBUG /bigobj -DNDEBUG -MD /showIncludes /Fosleef\src\common\CMakeFiles\addSuffix.dir\addSuffix.c.obj /Fdsleef\src\common\CMakeFiles\addSuffix.dir\ /FS -c E:\PyTorch_Build\pytorch\third_party\sleef\src\common\addSuffix.c E:\PyTorch_Build\pytorch\third_party\sleef\src\common\addSuffix.c(6): fatal error C1083: 无法打开包括文件: “stdio.h”: No such file or directory [5105/7459] Linking C shared library bin\torch_global_deps.dll FAILED: [code=4294967295] bin/torch_global_deps.dll lib/torch_global_deps.lib C:\WINDOWS\system32\cmd.exe /C "cd . && E:\Python310\Lib\site-packages\cmake\data\bin\cmake.exe -E vs_link_dll --msvc-ver=1944 --intdir=caffe2\CMakeFiles\torch_global_deps.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100261~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100261~1.0\x64\mt.exe --manifests -- C:\PROGRA~1\MICROS~3\2022\COMMUN~1\VC\Tools\MSVC\1444~1.352\bin\Hostx64\x64\link.exe /nologo caffe2\CMakeFiles\torch_global_deps.dir\__\torch\csrc\empty.c.obj /out:bin\torch_global_deps.dll /implib:lib\torch_global_deps.lib /pdb:bin\torch_global_deps.pdb /dll /version:0.0 /machine:x64 /ignore:4049 /ignore:4217 /ignore:4099 /INCREMENTAL:NO "E:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\lib\x64\cudart.lib" kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ." LINK: command "C:\PROGRA~1\MICROS~3\2022\COMMUN~1\VC\Tools\MSVC\1444~1.352\bin\Hostx64\x64\link.exe /nologo caffe2\CMakeFiles\torch_global_deps.dir\__\torch\csrc\empty.c.obj /out:bin\torch_global_deps.dll /implib:lib\torch_global_deps.lib /pdb:bin\torch_global_deps.pdb /dll /version:0.0 /machine:x64 /ignore:4049 /ignore:4217 /ignore:4099 /INCREMENTAL:NO E:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\lib\x64\cudart.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST:EMBED,ID=2" failed (exit code 1181) with the following output: LINK : fatal error LNK1181: 无法打开输入文件“kernel32.lib” ninja: build stopped: cannot make progress due to previous errors. (pytorch_env) PS E:\PyTorch_Build\pytorch> (pytorch_env) PS E:\PyTorch_Build\pytorch> # 如果上述命令失败,尝试重新生成并编译 (pytorch_env) PS E:\PyTorch_Build\pytorch> python setup.py clean Building wheel torch-2.9.0a0+git2d31c3d E:\PyTorch_Build\pytorch\pytorch_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 (pytorch_env) PS E:\PyTorch_Build\pytorch> python setup.py develop --cmakem Building wheel torch-2.9.0a0+git2d31c3d option --cmakem not recognized (pytorch_env) PS E:\PyTorch_Build\pytorch> # 编译完成后验证 (pytorch_env) PS E:\PyTorch_Build\pytorch> python -c "import torch; print(torch.__version__); print(torch.cuda.is_available())" Traceback (most recent call last): File "<string>", line 1, in <module> File "E:\PyTorch_Build\pytorch\torch\__init__.py", line 69, in <module> from torch.torch_version import __version__ as __version__ File "E:\PyTorch_Build\pytorch\torch\torch_version.py", line 5, in <module> from torch.version import __version__ as internal_version ModuleNotFoundError: No module named 'torch.version'
09-02
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> # 修改 cmake_config.ps1 (rtx5070_env) PS E:\PyTorch_Build\pytorch> @" >> # cmake_config.ps1 >> # 修复源目录路径 - 指向PyTorch源码目录 >> `$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 -Force (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 修改 compile_cuda_test.ps1 (rtx5070_env) PS E:\PyTorch_Build\pytorch> @" >> # compile_cuda_test.ps1 >> `$cudaTest = @' >> #include <cuda_runtime.h> >> #include <iostream> >> #include <cuda.h> // 添加必要头文件 >> >> __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((void**)&dev_a, arraySize * sizeof(int)); // 修复指针转换 >> cudaMalloc((void**)&dev_b, arraySize * sizeof(int)); >> cudaMalloc((void**)&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] << " "; >> } >> return 0; >> } >> '@ >> >> `$cudaTest | Set-Content cuda_test.cu # 改为.cu扩展名 >> >> `$ccbinPath = "`$env:VCToolsInstallDir\bin\Hostx64\x64" >> >> # 添加显式包含路径 >> nvcc -ccbin "`$ccbinPath" -I "E:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\include" cuda_test.cu -o cuda_test >> >> if (Test-Path cuda_test.exe) { >> .\cuda_test.exe >> } else { >> Write-Host "CUDA编译失败,请检查环境" >> } >> "@ | Set-Content compile_cuda_test.ps1 -Force (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> Remove-Item build -Recurse -Force -ErrorAction SilentlyContinue (rtx5070_env) PS E:\PyTorch_Build\pytorch> .\full_build.ps1 === 开始完整构建 === 环境设置完成! Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Requirement already satisfied: numpy in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (2.2.6) Requirement already satisfied: ninja in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (1.13.0) Requirement already satisfied: pyyaml in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (6.0.2) Requirement already satisfied: mkl in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (2025.2.0) Requirement already satisfied: mkl-include in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (2025.2.0) Requirement already satisfied: setuptools in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (65.5.0) Requirement already satisfied: cmake in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (4.1.0) Requirement already satisfied: cffi in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (1.17.1) Requirement already satisfied: typing_extensions in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (4.15.0) Requirement already satisfied: future in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (1.0.0) Requirement already satisfied: six in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (1.17.0) Requirement already satisfied: requests in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (2.32.5) Requirement already satisfied: dataclasses in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (0.6) Requirement already satisfied: intel-openmp<2026,>=2024 in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from mkl) (2025.2.1) Requirement already satisfied: tbb==2022.* in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from mkl) (2022.2.0) Requirement already satisfied: tcmlib==1.* in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from tbb==2022.*->mkl) (1.4.0) Requirement already satisfied: pycparser in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from cffi) (2.22) Requirement already satisfied: idna<4,>=2.5 in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from requests) (3.10) Requirement already satisfied: certifi>=2017.4.17 in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from requests) (2025.8.3) Requirement already satisfied: urllib3<3,>=1.21.1 in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from requests) (2.5.0) Requirement already satisfied: charset_normalizer<4,>=2 in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from requests) (3.4.3) Requirement already satisfied: intel-cmplr-lib-ur==2025.2.1 in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from intel-openmp<2026,>=2024->mkl) (2025.2.1) Requirement already satisfied: umf==0.11.* in e:\pytorch_build\pytorch\rtx5070_env\lib\site-packages (from intel-cmplr-lib-ur==2025.2.1->intel-openmp<2026,>=2024->mkl) (0.11.0) [notice] A new release of pip available: 22.3.1 -> 25.2 [notice] To update, run: python.exe -m pip install --upgrade pip 运行 CMake: cmake E:\PyTorch_Build\pytorch @cmakeArgs CMake Warning at CMakeLists.txt:418 (message): TensorPipe cannot be used on Windows. Set it to OFF -- Current compiler supports avx2 extension. Will build perfkernels. -- Current compiler supports avx512f extension. Will build fbgemm. -- The CUDA compiler identification is NVIDIA 13.0.48 with host compiler MSVC 19.44.35215.0 -- Detecting CUDA compiler ABI info -- Detecting CUDA compiler ABI info - failed -- Check for working CUDA compiler: E:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v13.0/bin/nvcc.exe -- Check for working CUDA compiler: E:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v13.0/bin/nvcc.exe - broken CMake Error at E:/PyTorch_Build/pytorch/rtx5070_env/Lib/site-packages/cmake/data/share/cmake-4.1/Modules/CMakeTestCUDACompiler.cmake:59 (message): The CUDA compiler "E:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v13.0/bin/nvcc.exe" is not able to compile a simple test program. It fails with the following output: Change Dir: 'E:/PyTorch_Build/pytorch/CMakeFiles/CMakeScratch/TryCompile-9hsd61' Run Build Command(s): E:/PyTorch_Build/pytorch/rtx5070_env/Scripts/ninja.exe -v cmTC_917ed [1/2] "E:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v13.0\bin\nvcc.exe" -forward-unknown-to-host-compiler -ccbin=C:\PROGRA~1\MICROS~3\2022\COMMUN~1\VC\Tools\MSVC\1444~1.352\bin\Hostx64\x64\cl.exe -DLIBCUDACXX_ENABLE_SIMPLIFIED_COMPLEX_OPERATIONS -Xfatbin -compress-all -Xcompiler=" -Zi -Ob0 -Od /RTC1" "--generate-code=arch=compute_75,code=[compute_75,sm_75]" -Xcompiler=-MDd -MD -MT CMakeFiles\cmTC_917ed.dir\main.cu.obj -MF CMakeFiles\cmTC_917ed.dir\main.cu.obj.d -x cu -c E:\PyTorch_Build\pytorch\CMakeFiles\CMakeScratch\TryCompile-9hsd61\main.cu -o CMakeFiles\cmTC_917ed.dir\main.cu.obj -Xcompiler=-FdCMakeFiles\cmTC_917ed.dir\,-FS main.cu tmpxft_00004ff4_00000000-10_main.cudafe1.cpp [2/2] C:\WINDOWS\system32\cmd.exe /C "cd . && E:\PyTorch_Build\pytorch\rtx5070_env\Lib\site-packages\cmake\data\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\cmTC_917ed.dir --rc=C:\ProgramData\mingw64\mingw64\bin\windres.exe --mt="" --manifests -- C:\ProgramData\mingw64\mingw64\bin\ld.exe /nologo CMakeFiles\cmTC_917ed.dir\main.cu.obj /out:cmTC_917ed.exe /implib:cmTC_917ed.lib /pdb:cmTC_917ed.pdb /version:0.0 /debug /INCREMENTAL cudadevrt.lib cudart.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib -LIBPATH:"E:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v13.0/lib/x64" && cd ." FAILED: [code=4294967295] cmTC_917ed.exe C:\WINDOWS\system32\cmd.exe /C "cd . && E:\PyTorch_Build\pytorch\rtx5070_env\Lib\site-packages\cmake\data\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\cmTC_917ed.dir --rc=C:\ProgramData\mingw64\mingw64\bin\windres.exe --mt="" --manifests -- C:\ProgramData\mingw64\mingw64\bin\ld.exe /nologo CMakeFiles\cmTC_917ed.dir\main.cu.obj /out:cmTC_917ed.exe /implib:cmTC_917ed.lib /pdb:cmTC_917ed.pdb /version:0.0 /debug /INCREMENTAL cudadevrt.lib cudart.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib -LIBPATH:"E:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v13.0/lib/x64" && cd ." RC Pass 1: command "C:\ProgramData\mingw64\mingw64\bin\windres.exe /fo CMakeFiles\cmTC_917ed.dir/manifest.res CMakeFiles\cmTC_917ed.dir/manifest.rc" failed (exit code 1) with the following output: Usage: C:\ProgramData\mingw64\mingw64\bin\windres.exe [option(s)] [input-file] [output-file] The options are: -i --input=<file> Name input file -o --output=<file> Name output file -J --input-format=<format> Specify input format -O --output-format=<format> Specify output format -F --target=<target> Specify COFF target --preprocessor=<program> Program to use to preprocess rc file --preprocessor-arg=<arg> Additional preprocessor argument -I --include-dir=<dir> Include directory when preprocessing rc file -D --define <sym>[=<val>] Define SYM when preprocessing rc file -U --undefine <sym> Undefine SYM when preprocessing rc file -v --verbose Verbose - tells you what it's doing -c --codepage=<codepage> Specify default codepage -l --language=<val> Set language when reading rc file --use-temp-file Use a temporary file instead of popen to read the preprocessor output --no-use-temp-file Use popen (default) -r Ignored for compatibility with rc @<file> Read options from <file> -h --help Print this help message -V --version Print version information FORMAT is one of rc, res, or coff, and is deduced from the file name extension if not specified. A single file name is an input file. No input-file is stdin, default rc. No output-file is stdout, default rc. C:\ProgramData\mingw64\mingw64\bin\windres.exe: supported targets: pe-x86-64 pei-x86-64 pe-bigobj-x86-64 elf64-x86-64 pe-i386 pei-i386 elf32-i386 elf32-iamcu elf64-little elf64-big elf32-little elf32-big srec symbolsrec verilog tekhex binary ihex plugin ninja: build stopped: subcommand failed. CMake will not be able to correctly generate this project. Call Stack (most recent call first): cmake/public/cuda.cmake:47 (enable_language) cmake/Dependencies.cmake:43 (include) CMakeLists.txt:853 (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= cl.exe CMAKE_C_COMPILER= cl.exe -- Generating done (0.0s) CMake Warning: Manually-specified variables were not used by the project: BLAS BUILD_TESTING CUDNN_ROOT_DIR PYTHON_EXECUTABLE TORCH_CUDA_ARCH_LIST CMake Generate step failed. Build files cannot be regenerated correctly. 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> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 3. 验证CUDA编译 (rtx5070_env) PS E:\PyTorch_Build\pytorch> .\compile_cuda_test.ps1 cuda_test.cu cuda_test.cu(1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失 E:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v13.0/include\cuda.h(23283): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失 cuda_test.cu(1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失 E:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v13.0/include\cuda.h(23283): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失 tmpxft_00004e0c_00000000-10_cuda_test.cudafe1.cpp CUDA娴嬭瘯缁撴灉: 11 22 33 44 55 (rtx5070_env) PS E:\PyTorch_Build\pytorch> (rtx5070_env) PS E:\PyTorch_Build\pytorch> # 4. 最终验证 (rtx5070_env) PS E:\PyTorch_Build\pytorch> python -c @" >> import torch >> print(f'PyTorch版本: {torch.__version__}') >> print(f'CUDA可用: {torch.cuda.is_available()}') >> if torch.cuda.is_available(): >> print(f'CUDA设备数量: {torch.cuda.device_count()}') >> print(f'设备0名称: {torch.cuda.get_device_name(0)}') >> "@ Traceback (most recent call last): File "<string>", line 2, in <module> AttributeError: module 'torch' has no attribute '__version__' (rtx5070_env) PS E:\PyTorch_Build\pytorch>
最新发布
09-03
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值