大佬教程收集整理的这篇文章主要介绍了cuda – 在CMake中确定我需要的nvcc所需的gencode(compute_,arch_)值,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
>有没有办法做到这一点:
>使用NVIDIA GPU部署套件?
>没有NVIDIA GPU部署套件?
> CMake的FindCUDA可以帮助您确定这些开关的值吗?
在项目文件夹中创建一个文件cudaComputeVersion.bash并确保它可以从sHell执行.进入这个文件放:
#!/bin/bash # create a 'here document' that is code we compile and use to probe the card cat << EOF > /tmp/cudaComputeVersion.cu #include <stdio.h> int main() { cudaDeviceProp prop; cudaGetDeviceProperties(&prop,0); int v = prop.major * 10 + prop.minor; printf("-gencode arch=compute_%d,code=sm_%d\n",v,v); } EOF # probe the card and cleanup /usr/local/cuda/bin/nvcc /tmp/cudaComputeVersion.cu -o /tmp/cudaComputeVersion /tmp/cudaComputeVersion rm /tmp/cudaComputeVersion.cu rm /tmp/cudaComputeVersion
并在您的CMakeLists.txt中放置:
# at cmake-build-time,probe the card and set a cmake variable execute_process(COMMAND ${CR_598_11845@AKE_CURRENT_sourcE_DIR}/cudaComputeVersion.bash OUTPUT_VARIABLE GENCODE) # at project-compile-time,include the gencodE into the compile options set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}; "${GENCODE}") # this makes CMake all chatty and allows you to see that GENCODE was set correctly set(CMAKE_VERBOSE_MAKEFILE TRUE)
干杯
以上是大佬教程为你收集整理的cuda – 在CMake中确定我需要的nvcc所需的gencode(compute_,arch_)值全部内容,希望文章能够帮你解决cuda – 在CMake中确定我需要的nvcc所需的gencode(compute_,arch_)值所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。