CHECK(调用)函数在Google Colab中出错[重复]
Posted
技术标签:
【中文标题】CHECK(调用)函数在Google Colab中出错[重复]【英文标题】:CHECK(call) function get error in Google Colab [duplicate] 【发布时间】:2020-11-01 18:12:25 【问题描述】:我刚刚从 CUDA 中的普通 CHECK(call)
函数复制了一个函数,并在 Google Colab 中使用 nvcc_plugin
运行
#define CHECK(call)
const cudaError_t error = call;
if (error != cudaSuccess)
printf("Error: %s:%d, ", __FILE__, __LINE__);
printf("code:%d, reason: %s\n", error, cudaGetErrorString(error));
exit(1);
但它会引发错误
/tmp/tmpvc2kvnuh/9c0f913f-6a2c-420d-9e3a-94c6e3123f7f.cu(9): error: expected a declaration
我该怎么做?
【问题讨论】:
【参考方案1】:#define CHECK(call) \
\
const cudaError_t error = call;\
if (error != cudaSuccess)\
\
printf("Error: %s:%d, ", __FILE__, __LINE__);\
printf("code:%d, reason: %s\n", error, cudaGetErrorString(error));\
exit(1);\
\
如果你想要一个多行宏,你必须添加反斜杠。
【讨论】:
以上是关于CHECK(调用)函数在Google Colab中出错[重复]的主要内容,如果未能解决你的问题,请参考以下文章
在单个单元格 google colab 中多次调用 matplotlib imshow() 时如何保留以前的图像?
以编程方式在 Google Colab 中运行所有单元格命令