gpt4 book ai didi

c++ - "unsigned int *"类型的参数与 "size_t *"类型的参数不兼容

转载 作者:太空狗 更新时间:2023-10-29 23:33:54 24 4
gpt4 key购买 nike

我在 cuda 中使用 C++ 编写了这段代码:

// Variables
float *query_dev;
float *ref_dev;
float *dist_dev;
int *ind_dev;
cudaArray *ref_array;
cudaError_t result;
size_t query_pitch;
size_t query_pitch_in_bytes;
size_t ref_pitch;
size_t ref_pitch_in_bytes;
size_t ind_pitch;
size_t ind_pitch_in_bytes;
size_t max_nb_query_traited;
size_t actual_nb_query_width;
unsigned int memory_total;
unsigned int memory_free;

// Check if we can use texture memory for reference points
unsigned int use_texture = ( ref_width*size_of_float<=MAX_TEXTURE_WIDTH_IN_BYTES && height*size_of_float<=MAX_TEXTURE_HEIGHT_IN_BYTES );

// CUDA Initialisation
cuInit(0);

// Check free memory using driver API ; only (MAX_PART_OF_FREE_MEMORY_USED*100)% of memory will be used

CUcontext cuContext;
CUdevice cuDevice=0;
cuCtxCreate(&cuContext, 0, cuDevice);
cuMemGetInfo(&memory_free, &memory_total);

我在以下行编译时遇到错误:cuMemGetInfo(&memory_free, &memory_total);

错误是:

app.cu(311): error: argument of type "unsigned int *" is incompatible with parameter of type "size_t *"

app.cu(311): error: argument of type "unsigned int *" is incompatible with parameter of type "size_t

311 是一行:cuMemGetInfo(&memory_free, &memory_total);

我不知道这个错误是什么,你知道吗?

最佳答案

更改以下行:

unsigned int memory_total;
unsigned int memory_free;

到:

size_t memory_total;
size_t memory_free;

您可能正在尝试最初在 CUDA 3.0 之前构建的旧代码。

Source

关于c++ - "unsigned int *"类型的参数与 "size_t *"类型的参数不兼容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7983103/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com