CUDA 新版本 Visual Studio 和 CUDA 兼容性的小问题

▶ 升级到 Visual Studio 2017 和 CUDA 9.1 之后,直接编译以前的 CUDA C 程序出现了如下报错:

1 严重性    代码    说明    项目    文件    行    禁止显示状态
2 错误(活动)    E0029    应输入表达式    cudaProject    d:CodeCUDAcudaProjectcudaProjectkernel.cu    116    
3 错误(活动)    E0029    应输入表达式    cudaProject    d:CodeCUDAcudaProjectcudaProjectkernel.cu    118    
4 错误    MSB3721    命令“"D:ProgramCUDA9.1in
vcc.exe" -gencode=arch=compute_30,code="sm_30,compute_30" --use-local-env --cl-version 2017 -ccbin "D:ProgramVisualStudio2017VCToolsMSVC14.13.26128inHostX86x64" -x cu  -ID:ProgramCUDA9.1include -ID:ProgramCUDA9.1include  -G   --keep-dir x64Debug -maxrregcount=0  --machine 64 --compile -cudart static  -g   -DWIN32 -DWIN64 -D_DEBUG -D_CONSOLE -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /FS /Zi /RTC1 /MDd " -o x64Debugkernel.cu.obj "D:CodeCUDAcudaProjectcudaProjectkernel.cu"”已退出,返回代码为 2。    cudaProject    D:ProgramVisualStudio2017Common7IDEVCVCTargetsBuildCustomizationsCUDA 9.1.targets    707    
5 错误    C1189    #error:  -- unsupported Microsoft Visual Studio version! Only the versions 2012, 2013, 2015 and 2017 are supported!    cudaProject    d:programcuda9.1includecrthost_config.h    135    

● 那两个“应输入表达式”是读不了 <<< 和 >>> 操作符;

● 最后那个错很直接,在 host_config.h 中有下列对 Visual Studio 的版本筛选,Visual Studio 2015 (v140) 的 _MSC_VER 等于 1900

 1 #if defined(__CUDACC__)
 2 
 3 ...
 4 
 5 #if defined(_WIN32)
 6 
 7 #if _MSC_VER < 1600 || _MSC_VER > 1911
 8 
 9 #error -- unsupported Microsoft Visual Studio version! Only the versions 2012, 2013, 2015 and 2017 are supported!
10 
11 #elif _MSC_VER == 1600 /* _MSC_VERION == 1600 */
12 
13 #pragma message("support for Microsoft Visual Studio 2010 has been deprecated!")
14 
15 #endif /* _MSC_VER < 1600 || _MSC_VER > 1800 || _MSC_VERSION == 1600 */
16 
17 #endif /* _WIN32 */
18 
19 ...
20 
21 #endif /* __CUDACC__ */

● 经指点(http://tieba.baidu.com/p/5476899594),把平台的版本从 Visual Studio 2017 (v141) 降到 Visual Studio 2015 (v140) 就编译通过了。

  

  

原文地址:https://www.cnblogs.com/cuancuancuanhao/p/8975863.html