1
1
运行时
使用dcu编程hello world报错
2023-03-11 20:23:21
79

您好,我最近在学习cuda/hip编程,在dcu上进行最简单的hello程序编写时,出现如下错误,请问是什么原因?

我的代码:

#include <stdio.h>
#include <hip/hip_runtime.h>

__global__ void kernel(){
    printf("hello dcu!\n");
}

int main() {

    kernel<<<10,1>>>();
    return 0;
}

我加载的环境:

compiler/dtk/22.04.2
compiler/devtoolset/7.3.1
mpi/hpcx/gcc-7.3.1
anaconda3/5.2.0

编译流程:

$ hipcc hellodcu.cpp -o hellodcu
$ ./hellodcu

报错截图:

全部评论(2)
只看楼主
T
tianlh
1楼

您好,代码修改如下:

#include <stdio.h>

#include <hip/hip_runtime.h>

__global__ void kernel()

{

printf("hello dcu!\n");

}

int main()

{

kernel<<<1,1>>>();

hipDeviceSynchronize();

return 0;

}

运行之前请先export HIP_KERNEL_PRINTF=1
2023/3/13
B
brucecui
回复 @tianlh
收到,解决了~
2023/3/14
没有更多内容了
--
楼主
Level.1
0 帖子
楼主热帖
暂无数据