我正在尝试在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()发布于 2018-12-21 18:03:29
我在CMakeLists.txt的开头添加了这段代码。问题已经解决了。
set(CMAKE_CXX_FLAGS -D_FORCE_INLINES)
https://stackoverflow.com/questions/51978941
复制相似问题