我正在尝试使用cuda-memcheck调试应用程序 . 我想要做的是将我的应用程序的输出重定向到一个文件,但另一方面,将cuda-memcheck的stdout和stderr重定向到另一个文件 . 但我无法让它发挥作用 . 这个:
cuda-memcheck "app.exe > stdout1.txt" > memcheck.log 2>&1
什么都不做 . 但是如果我删除引号内的重定向(忽略我的app输出),它就会执行 . 所以问题是,如何重定向子命令的标准输出?
根据您对 cuda-memcheck 的行为的评论,您可以使用以下命令 .
cuda-memcheck
cuda-memcheck --log-file memcheck.log app.exe >app.stdout.txt
Edit
这是我对CentOS的测试 . 它可能适用于Win32控制台应用程序,但不适用于Win32应用程序 .
a.cu
#include <iostream> int main () { std::cout<< "hello world to stdout!" <<std::endl; std::cerr<< "hello world to stderr!" <<std::endl; return 0; }
编译命令:
$ nvcc -O3 -o a a.cu
运行命令:
$ cuda-memcheck --log-file mem.log a >a.stdout.log 2>a.stderr.log
结果文件:
$ cat mem.log ========= CUDA-MEMCHECK ========= ERROR SUMMARY: 0 errors $ cat a.stdout.log hello world to stdout! $ cat a.stderr.log hello world to stderr!
1 回答
根据您对
cuda-memcheck
的行为的评论,您可以使用以下命令 .Edit
这是我对CentOS的测试 . 它可能适用于Win32控制台应用程序,但不适用于Win32应用程序 .
a.cu
编译命令:
运行命令:
结果文件: