为什么CMake强制使用libcublas进行可分离的编译? [英] Why does CMake force the use of libcublas with separable compilation?

查看:79
本文介绍了为什么CMake强制使用libcublas进行可分离的编译?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用CMake 3.11构建以下基于CUDA的小型项目:

I use CMake 3.11 to build the following tiny CUDA-based project:

CMakeLists.txt

CMakeLists.txt:

cmake_minimum_required(VERSION 3.1)
find_package(CUDA 7.0 REQUIRED)
set(CUDA_SEPARABLE_COMPILATION ON)
cuda_add_executable(dummy dummy.cu)

dummy.cu

dummy.cu:

int main() { }

奇怪的是,在构建时,以下命令用于dlink阶段:

Strangely enough, when building, the following command is used for the dlink phase:

/path/to/cuda/bin/nvcc -m64 -ccbin /opt/gcc-5.4.0/bin/gcc -dlink /home/joeuser/src/dummy/CMakeFiles/dummy.dir//./dummy_generated_dummy.cu.o /path/to/cuda/lib64/libcublas_device.a -o /home/joeuser/src/dummy/CMakeFiles/dummy.dir/./dummy_intermediate_link.o

为什么CMake链接到据说不需要的cublas?

Why is CMake linking against cublas where it supposedly doesn't need it?

注意:如果我删除SEPARABLE_COMPILATION li否,cublas不会添加到dlink命令参数中。

Note: If I remove the SEPARABLE_COMPILATION line, cublas is not added to the dlink command arguments.

推荐答案

部分答案:

如果我们使用CMake的本机CUDA语言支持,这似乎不会发生,例如

This doesn't seem to happen if we use CMake's native CUDA language support, e.g.

cmake_minimum_required(VERSION 3.1)
enable_language(CUDA)
add_executable(dummy dummy.cu)

以上-工程。即使设置,我也不能使它 not 不能分开编译:

instead of the above - works. I can't make it not have separable compilation though, even if I set:

set_property(TARGET dummy PROPERTY CUDA_SEPARABLE_COMPILATION OFF)

这篇关于为什么CMake强制使用libcublas进行可分离的编译?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆