【问题标题】:How do I convert a __CUDACC_VER__ value into a MAJOR, MINOR, BUILD triplet?如何将 __CUDACC_VER__ 值转换为 MAJOR、MINOR、BUILD 三元组?
【发布时间】:2018-06-01 17:49:06
【问题描述】:

当较新 (CUDA 9) 版本的 nvcc 遇到 __CUDACC_VER__ 时,它会放弃并告诉您以下信息:

/usr/local/cuda/include/crt/common_functions.h:64:24: error: token ""__CUDACC_VER__ is no longer supported.  Use __CUDACC_VER_MAJOR__, __CUDACC_VER_MINOR__, and __CUDACC_VER_BUILD__ instead."" is not valid in preprocessor expressions
 #define __CUDACC_VER__ "__CUDACC_VER__ is no longer supported.  Use __CUDACC_VER_MAJOR__, __CUDACC_VER_MINOR__, and __CUDACC_VER_BUILD__ instead."

那么,我如何将 __CUDACC_VER__ 的使用转换为适用于旧版本和新版本 NVCC 的东西?

【问题讨论】:

    标签: cuda nvcc


    【解决方案1】:

    部分答案:

    至少对于较新的版本,NVCC documentation 告诉我们(在第 3 页)公式是什么:

    __CUDACC_VER__ = 
         __CUDACC_VER_MAJOR__ * 10000 +
         __CUDACC_VER_MINOR__ * 100 +
         __CUDACC_VER_BUILD__
    

    因此,例如,检查来自 CUDA 7.5 或更高版本的 nvcc 意味着检查

    (__CUDACC_VER__ > 70500)
    

    还有你要写的三元组值

    (__CUDACC_VER_MAJOR__ > 7) or ((__CUDACC_VER_MAJOR__ == 7) and (__CUDACC_VER_MINOR__ >= 5))
    

    改为。

    【讨论】:

      猜你喜欢
      • 2015-01-03
      • 2012-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多