我正在尝试在Ubuntu 16.04中运行Cuda(7.5版)代码。该代码是使用Cuda 3.0编写的,并且在Ubuntu 11上运行良好。在Ubuntu 16.04中,出现此错误:
/usr/include/string.h: In function ‘void* __mempcpy_inline(void*, const void*, size_t)’:
/usr/include/string.h:652:42: error: ‘memcpy’ was not declared in this scope
return (char *) memcpy (__dest, __src, __n) + __n;
解决方案是根据许多互联网资源,在run_nvcc.cmake文件中添加-D_FORCE_INLINES以解决编译错误,但是网络上的示例似乎与不同的cmake文件相关,因此我无法准确复制它。我尝试将其添加到其他位置,但无法正常工作。我需要知道添加-D_FORCE_INLINES的正确位置。我在下面包括了cmake文件的修改部分,该部分随nvcc的不同版本而变化(我猜是这样)。任何帮助,将不胜感激。 cmake文件的修改后的部分是:
set(CMAKE_CXX_FLAGS "-D_FORCE_INLINES") #tried adding it here first
# For CUDA 2.3 and above, add the -D_FORCE_INLINES flag
# for dependency generation and hope for the best.
set(depends_CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS}")
set(CUDA_VERSION @CUDA_VERSION@)
if(CUDA_VERSION VERSION_GREATER "3.0")
cmake_policy(PUSH)
# CMake policy 0007 NEW states that empty list elements are not
# ignored. I'm just setting it to avoid the warning that's printed.
cmake_policy(SET CMP0007 NEW)
list(APPEND depends_CUDA_NVCC_FLAGS "-D_FORCE_INLINES")
#second modification (appending the list)
cmake_policy(POP)
endif()
答案 0 :(得分:0)
我将其添加到CMakeLists.txt的开头。问题已经解决。
设置(CMAKE_CXX_FLAGS -D_FORCE_INLINES)