gpt4 book ai didi

c++ - 使用 CMake 设置 CUDA_NVCC_FLAGS

转载 作者:搜寻专家 更新时间:2023-10-31 02:16:36 26 4
gpt4 key购买 nike

我正在尝试在 Windows 上使用 CMake 编译一个 CUDA 项目。我不熟悉 make 或 CMake,过去几天我读了一些书,但我仍然无法弄清楚。我收到以下错误消息:

Chri@Riemann-PC /cygdrive/c/Apps/ThirdParty/MAGMA/magma-2.0.1/build64
$ make
[ 1%] Built target lapacktest
[ 1%] Building NVCC (Device) object CMakeFiles/magma.dir/magmablas/magma_generated_zherk_batched_core.cu.o
nvcc fatal : nvcc cannot find a supported version of Microsoft Visual Studio. Only the versions 2010, 2012, and 2013 are supported
CMake Error at magma_generated_zherk_batched_core.cu.o.cmake:207 (message):
Error generating
/cygdrive/c/Apps/ThirdParty/MAGMA/magma-2.0.1/build64/CMakeFiles/magma.dir/magmablas/./magma_generated_zherk_batched_core.cu.o


CMakeFiles/magma.dir/build.make:2058: recipe for target 'CMakeFiles/magma.dir/magmablas/magma_generated_zherk_batched_core.cu.o' failed
make[2]: *** [CMakeFiles/magma.dir/magmablas/magma_generated_zherk_batched_core.cu.o] Error 1
CMakeFiles/Makefile2:105: recipe for target 'CMakeFiles/magma.dir/all' failed
make[1]: *** [CMakeFiles/magma.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

使用 make VERBOSE=1 命令,我得到以下错误:

cd /cygdrive/c/Apps/ThirdParty/MAGMA/magma-2.0.1/build64/CMakeFiles/magma.dir/magmablas && /usr/bin/cmake.exe -D verbose:BOOL=1 -D build_configuration:STRING= -D generated_file:STRING=/cygdrive/c/Apps/ThirdParty/MAGMA/magma-2.0.1/build64/CMakeFiles/magma.dir/magmablas/./magma_generated_zherk_batched_core.cu.o -D generated_cubin_file:STRING=/cygdrive/c/Apps/ThirdParty/MAGMA/magma-2.0.1/build64/CMakeFiles/magma.dir/magmablas/./magma_generated_zherk_batched_core.cu.o.cubin.txt -P /cygdrive/c/Apps/ThirdParty/MAGMA/magma-2.0.1/build64/CMakeFiles/magma.dir/magmablas/magma_generated_zherk_batched_core.cu.o.cmake
-- Removing /cygdrive/c/Apps/ThirdParty/MAGMA/magma-2.0.1/build64/CMakeFiles/magma.dir/magmablas/./magma_generated_zherk_batched_core.cu.o
/usr/bin/cmake.exe -E remove /cygdrive/c/Apps/ThirdParty/MAGMA/magma-2.0.1/build64/CMakeFiles/magma.dir/magmablas/./magma_generated_zherk_batched_core.cu.o
-- Generating dependency file: /cygdrive/c/Apps/ThirdParty/MAGMA/magma-2.0.1/build64/CMakeFiles/magma.dir/magmablas/magma_generated_zherk_batched_core.cu.o.NVCC-depend
"/cygdrive/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v7.5/bin/nvcc.exe" -M -D__CUDACC__ /cygdrive/c/Apps/ThirdParty/MAGMA/magma-2.0.1/magmablas/zherk_batched_core.cu -o /cygdrive/c/Apps/ThirdParty/MAGMA/magma-2.0.1/build64/CMakeFiles/magma.dir/magmablas/magma_generated_zherk_batched_core.cu.o.NVCC-depend -ccbin /usr/bin/gcc.exe -m64 -Xcompiler ,\"-fopenmp\",\"-Wall\",\"-Wno-unused-function\",\"-g\" -DHAVE_CUBLAS -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_35,code=compute_35 -DNVCC "-I/cygdrive/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v7.5/include" "-I/cygdrive/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v7.5/include" -I/cygdrive/c/Apps/ThirdParty/MAGMA/magma-2.0.1/include -I/cygdrive/c/Apps/ThirdParty/MAGMA/magma-2.0.1/control
nvcc fatal : nvcc cannot find a supported version of Microsoft Visual Studio. Only the versions 2010, 2012, and 2013 are supported

它仍然使用 gcc 编译器 (-ccbin/usr/bin/gcc.exe)。

我进入文件:C:\Apps\ThirdParty\cygwin64\usr\share\cmake-3.3.2\Modules\FindCUDA.cmake 并添加以下行:

set(VS_DIR "C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\bin")
message(${VS_DIR})
set(CUDA_NVCC_FLAGS "-ccbin ${VS_DIR}" CACHE STRING "Semi-colon delimit multiple arguments.")

我还在 nvcc.profile 文件中添加了以下行:

CUDA_NVCC_FLAGS += -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin";

仍然没有运气。我花了几天时间试图解决这个问题。我很感激在这件事上的任何帮助。

最佳答案

FindCUDA 中设置主机编译器的选项是CUDA_HOST_COMPILER,参见FindCUDA documentation .

尝试

set(CUDA_HOST_COMPILER "<path to compiler executable>")

或者在调用cmake命令时设置

cmake .. -DCUDA_HOST_COMPILER=<path to compiler executable>

我想 CUDA_HOST_COMPILER 选项会覆盖 CUDA_NVCC_FLAGSccbin 设置。对于其他选项,您可以按照您尝试的方式使用 CUDA_NVCC_FLAGS。 (因此,标题具有误导性。这不是如何设置CUDA_NVCC_FLAGS的问题。)

我经常在 Linux 上使用它,但是我没有 Windows 环境来测试它。

关于c++ - 使用 CMake 设置 CUDA_NVCC_FLAGS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36757743/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com