>有没有办法做到这一点:
>使用NVIDIA GPU部署套件?
>没有NVIDIA GPU部署套件?
> CMake的FindCUDA可以帮助您确定这些开关的值吗?
解决方法 我的策略是编译并运行一个bash脚本来探测卡并返回cmake的gencode.灵感来自 University of Chicago’s SLURM.要处理错误或多个gpus或其他情况,请根据需要进行修改.在项目文件夹中创建一个文件cudaComputeVersion.bash并确保它可以从shell执行.进入这个文件放:
#!/bin/bash# create a 'here document' that is code we compile and use to probe the cardcat << 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/cudaComputeVersionrm /tmp/cudaComputeVersion.curm /tmp/cudaComputeVersion
并在您的CMakeLists.txt中放置:
# at cmake-build-time,probe the card and set a cmake variableexecute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/cudaComputeVersion.bash OUTPUT_VARIABLE GENCODE)# at project-compile-time,include the gencode into the compile optionsset(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}; "${GENCODE}")# this makes CMake all chatty and allows you to see that GENCODE was set correctlyset(CMAKE_VERBOSE_MAKEfile TRUE)
干杯
总结以上是内存溢出为你收集整理的cuda – 在CMake中确定我需要的nvcc所需的gencode(compute_,arch_)值全部内容,希望文章能够帮你解决cuda – 在CMake中确定我需要的nvcc所需的gencode(compute_,arch_)值所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)