我正在编写代码来处理两个用户之间的通信,并且需要 LDPC 的 CUDA 实现来快速检查错误。我以前没有使用过 CUDA,但我在 GitHub (https://github.com/robertwgh/cuLDPC) 上找到了一个 repo,它可以满足我的所有需求。我的问题是我无法编译这个库,可能是因为它是旧版本的 CUDA (v4/v5)。
我尝试通过将所有文件添加到项目中来使用 Visual Studio 进行编译,但出现了各种错误。其中一些似乎与代码本身有关,但主要问题是 nvcc 的问题,在 MSB3721 错误中给出。
在 repo 中有一个包含 makefile 的拉取请求,所以我检查了一下,但这并没有改变错误。
然后我尝试进入命令提示符并手动使用 nvcc,但出现错误
Cannot find compiler 'cl.exe' in PATH
我尝试通过添加来解决这个问题
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\
我的 PATH 变量,但我得到了同样的错误。重置 PATH 后,我还运行了 vcvars32.bat 和 vcvars64.bat,但这两次仍然没有效果。
此外,我已将 cublas.lib、cudart.lib 和 cusparse.lib 添加到项目属性中的链接器输入依赖项,并且我在构建依赖项 > 构建自定义菜单中检查了 CUDA 10.1。
我现在不知道该去哪里,非常感谢对此事有更多了解的人的帮助。
最佳答案
Github 存储库为我构建和运行的 FWIW,几乎是开箱即用的。唯一需要的几个技巧是:
- 不要直接编译
cuLDPC_kernel.cu
,因为它被视为来自cuLDPC.cu
的头文件> - 注释掉一些对功能不重要的损坏的时序代码。我猜这些变量在错误的词法范围内。 (下面
git diff
的结果)
首先创建一个新的支持 CUDA 的 Visual Studio 项目:
从 github 存储库中拖入“src”目录。然后将cuLDPC_kernel.cu的文件属性修改为不构建。
设置“从构建中排除”= 是
构建所需的代码更改:
diff --git a/src/cuLDPC.cu b/src/cuLDPC.cu
index f217de4..3c3865c 100755
--- a/src/cuLDPC.cu
+++ b/src/cuLDPC.cu
@@ -448,17 +448,17 @@ int runTest()
#if MEASURE_CPU_TIME == 1
cudaDeviceSynchronize();
- cpu_timer.stop();
- cpu_run_time += cpu_timer.stop_get();
+ //cpu_timer.stop();^M
+ //cpu_run_time += cpu_timer.stop_get();^M
printf ("\n=================================\n\r");
printf ("GPU CUDA Demo\n");
printf ("SNR = %1.1f dB\n", snr);
printf ("# codewords = %d, # streams = %d, CW=%d, MCW=%d\r\n",total_codeword * NSTREAMS, NSTREAMS, CW, MCW);
printf("number of iterations = %1.1f \r\n", aver_iter);
- printf("CPU time: %f ms, for %d simulations.\n", cpu_run_time, MAX_SIM);
- float throughput = (float)CODEWORD_LEN * NSTREAMS * MCW * CW * MAX_SIM / cpu_run_time /1000;
- printf("Throughput = %f Mbps\r\n", (float)CODEWORD_LEN * NSTREAMS * MCW * CW * MAX_SIM / cpu_run_time /1000);
+ //printf("CPU time: %f ms, for %d simulations.\n", cpu_run_time, MAX_SIM);^M
+ //float throughput = (float)CODEWORD_LEN * NSTREAMS * MCW * CW * MAX_SIM / cpu_run_time /1000;^M
+ //printf("Throughput = %f Mbps\r\n", (float)CODEWORD_LEN * NSTREAMS * MCW * CW * MAX_SIM / cpu_run_time /1000); ^M
#endif
#if MEASURE_CUDA_TIME == 1
关于c++ - 如何编译 CUDA C++ 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57043774/