簡體   English   中英

CUDA 編譯器無法編譯出簡單的測試程序

[英]CUDA compiler is unable to compile a simple test program

我正在嘗試獲取 NVIDIA 的 CUDA 設置並安裝在我的具有 NVIDIA GEFORCE RTX 2080 SUPER 顯卡的 PC 上。 經過數小時的嘗試不同的事情和大量的研究,我已經讓 CUDA 使用命令提示符工作,盡管嘗試在 CLion 中使用 CUDA 將不起作用。

使用

nvcc main.cu -o build.exe

從命令行生成可執行文件,我可以在 GPU 上運行它,但是在嘗試使用 CLion 時出現以下錯誤:

我相信這是相關的部分,但是如果需要,還有更多

-- The CUDA compiler identification is unknown
-- Check for working CUDA compiler: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.0/bin/nvcc.exe
-- Check for working CUDA compiler: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.0/bin/nvcc.exe -- broken
CMake Error at C:/Users/penci/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/201.7846.88/bin/cmake/win/share/cmake-3.16/Modules/CMakeTestCUDACompiler.cmake:46 (message):
  The CUDA compiler

    "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.0/bin/nvcc.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: C:/Users/penci/OneDrive/Desktop/Code/C-Cpp/CUDA PLEASE/cmake-build-debug/CMakeFiles/CMakeTmp
    
    Run Build Command(s):nmake /nologo cmTC_03473\fast &&   "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.26.28801\bin\HostX86\x86\nmake.exe" -f CMakeFiles\cmTC_03473.dir\build.make /nologo -L                  CMakeFiles\cmTC_03473.dir\build
    Building CUDA object CMakeFiles/cmTC_03473.dir/main.cu.obj
        C:\PROGRA~1\NVIDIA~2\CUDA\v11.0\bin\nvcc.exe     -x cu -c "C:\Users\penci\OneDrive\Desktop\Code\C-Cpp\CUDA PLEASE\cmake-build-debug\CMakeFiles\CMakeTmp\main.cu" -o CMakeFiles\cmTC_03473.dir\main.cu.obj

謝謝你的幫助!

=============================== 編輯1 ================== ===========

這是來自 CLion 的完整 output (它也使用不同的項目,但仍然是完全相同的輸出)

C:\Users\penci\AppData\Local\JetBrains\CLion2020.1\cygwin_cmake\bin\cmake.exe -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" /cygdrive/c/Users/penci/OneDrive/Desktop/Code/C-Cpp/CUDA_TEST
-- The CUDA compiler identification is NVIDIA 11.0.194
-- Check for working CUDA compiler: /cygdrive/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.0/bin/nvcc.exe
-- Check for working CUDA compiler: /cygdrive/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.0/bin/nvcc.exe -- broken
CMake Error at /cygdrive/c/Users/penci/AppData/Local/JetBrains/CLion2020.1/cygwin_cmake/share/cmake-3.16.5/Modules/CMakeTestCUDACompiler.cmake:46 (message):
  The CUDA compiler

    "/cygdrive/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.0/bin/nvcc.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /cygdrive/c/Users/penci/OneDrive/Desktop/Code/C-Cpp/CUDA_TEST/cmake-build-debug/CMakeFiles/CMakeTmp
    
    Run Build Command(s):/usr/bin/make.exe cmTC_03d85/fast && /usr/bin/make -f CMakeFiles/cmTC_03d85.dir/build.make CMakeFiles/cmTC_03d85.dir/build
    make[1]: Entering directory '/cygdrive/c/Users/penci/OneDrive/Desktop/Code/C-Cpp/CUDA_TEST/cmake-build-debug/CMakeFiles/CMakeTmp'
    Building CUDA object CMakeFiles/cmTC_03d85.dir/main.cu.o
    "/cygdrive/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.0/bin/nvcc.exe"     -x cu -c /cygdrive/c/Users/penci/OneDrive/Desktop/Code/C-Cpp/CUDA_TEST/cmake-build-debug/CMakeFiles/CMakeTmp/main.cu -o CMakeFiles/cmTC_03d85.dir/main.cu.o
    c1xx: fatal error C1083: Cannot open source file: 'C:/cygdrive/c/Users/penci/OneDrive/Desktop/Code/C-Cpp/CUDA_TEST/cmake-build-debug/CMakeFiles/CMakeTmp/main.cu': No such file or directory
    main.cu
    make[1]: *** [CMakeFiles/cmTC_03d85.dir/build.make:66: CMakeFiles/cmTC_03d85.dir/main.cu.o] Error 2
    make[1]: Leaving directory '/cygdrive/c/Users/penci/OneDrive/Desktop/Code/C-Cpp/CUDA_TEST/cmake-build-debug/CMakeFiles/CMakeTmp'
    make: *** [Makefile:121: cmTC_03d85/fast] Error 2
    
    

  

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:2 (project)


-- Configuring incomplete, errors occurred!
See also "/cygdrive/c/Users/penci/OneDrive/Desktop/Code/C-Cpp/CUDA_TEST/cmake-build-debug/CMakeFiles/CMakeOutput.log".
See also "/cygdrive/c/Users/penci/OneDrive/Desktop/Code/C-Cpp/CUDA_TEST/cmake-build-debug/CMakeFiles/CMakeError.log".

[Finished]

================================ 編輯2 ================= ===============

切換到 MSVC 2017 和 Visual Studio 工具鏈后,我現在得到一個稍微不同的錯誤:

C:\Users\penci\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\201.7846.88\bin\cmake\win\bin\cmake.exe -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - NMake Makefiles" C:\Users\penci\OneDrive\Desktop\Code\C-Cpp\CUDA_TEST
-- The CUDA compiler identification is NVIDIA 11.0.194
-- Check for working CUDA compiler: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.0/bin/nvcc.exe
-- Check for working CUDA compiler: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.0/bin/nvcc.exe -- broken
CMake Error at C:/Users/penci/AppData/Local/JetBrains/Toolbox/apps/CLion/ch-0/201.7846.88/bin/cmake/win/share/cmake-3.16/Modules/CMakeTestCUDACompiler.cmake:46 (message):
  The CUDA compiler

    "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.0/bin/nvcc.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: C:/Users/penci/OneDrive/Desktop/Code/C-Cpp/CUDA_TEST/cmake-build-debug/CMakeFiles/CMakeTmp
    
    Run Build Command(s):nmake /nologo cmTC_23e94\fast &&   "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\nmake.exe" -f CMakeFiles\cmTC_23e94.dir\build.make /nologo -L                  CMakeFiles\cmTC_23e94.dir\build
    Building CUDA object CMakeFiles/cmTC_23e94.dir/main.cu.obj
        C:\PROGRA~1\NVIDIA~2\CUDA\v11.0\bin\nvcc.exe    -D_WINDOWS -Xcompiler=" /GR /EHsc"  -Xcompiler="-Zi -Ob0 -Od /RTC1" -Xcompiler=-MDd -x cu -c C:\Users\penci\OneDrive\Desktop\Code\C-Cpp\CUDA_TEST\cmake-build-debug\CMakeFiles\CMakeTmp\main.cu -o CMakeFiles\cmTC_23e94.dir\main.cu.obj -Xcompiler=-FdCMakeFiles\cmTC_23e94.dir\,-FS
    main.cu
    Linking CUDA executable cmTC_23e94.exe
        C:\Users\penci\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\201.7846.88\bin\cmake\win\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\cmTC_23e94.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100177~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100177~1.0\x64\mt.exe --manifests  -- C:\PROGRA~2\MICROS~2\2017\COMMUN~1\VC\Tools\MSVC\1416~1.270\bin\Hostx64\x64\link.exe /nologo "CMakeFiles\cmTC_23e94.dir\main.cu.obj"  @C:\Users\penci\AppData\Local\Temp\nmD0E.tmp
    LINK Pass 1: command "C:\PROGRA~2\MICROS~2\2017\COMMUN~1\VC\Tools\MSVC\1416~1.270\bin\Hostx64\x64\link.exe /nologo CMakeFiles\cmTC_23e94.dir\main.cu.obj /out:cmTC_23e94.exe /implib:cmTC_23e94.lib /pdb:C:\Users\penci\OneDrive\Desktop\Code\C-Cpp\CUDA_TEST\cmake-build-debug\CMakeFiles\CMakeTmp\cmTC_23e94.pdb /version:0.0 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib -LIBPATH:C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.0/lib/x64 cudadevrt.lib cudart_static.lib /MANIFEST /MANIFESTFILE:CMakeFiles\cmTC_23e94.dir/intermediate.manifest CMakeFiles\cmTC_23e94.dir/manifest.res" failed (exit code 1120) with the following output:
       Creating library cmTC_23e94.lib and object cmTC_23e94.exp
    MSVCRTD.lib(utility_app.obj) : error LNK2019: unresolved external symbol __imp_RoInitialize referenced in function __scrt_initialize_winrt
    cmTC_23e94.exe : fatal error LNK1120: 1 unresolved externals
    NMAKE : fatal error U1077: 'C:\Users\penci\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\201.7846.88\bin\cmake\win\bin\cmake.exe' : return code '0xffffffff'
    Stop.
    NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\HostX64\x64\nmake.exe"' : return code '0x2'
    Stop.
    
    

  

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:2 (project)


-- Configuring incomplete, errors occurred!
See also "C:/Users/penci/OneDrive/Desktop/Code/C-Cpp/CUDA_TEST/cmake-build-debug/CMakeFiles/CMakeOutput.log".
See also "C:/Users/penci/OneDrive/Desktop/Code/C-Cpp/CUDA_TEST/cmake-build-debug/CMakeFiles/CMakeError.log".

[Finished]

通過確保您的 PATH 已更新以包含

C:/Program Files/NVIDIA GPU 計算工具包/CUDA/v11.0/bin

我的 CMakeLists.txt 看起來像這樣

cmake_minimum_required(VERSION 3.17)
project(cuda_test CUDA)

find_package(CUDA)
set(CMAKE_CUDA_STANDARD 14)

add_executable(cuda_test main.cu)

set_target_properties(
        cuda_test
        PROPERTIES
        CUDA_SEPARABLE_COMPILATION ON)

並在工具鏈中使用帶有這些設置的 Visual Studio 2017 在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM