Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to perform cudnn convolution #298

Open
HVisMyLife opened this issue Nov 16, 2024 · 0 comments
Open

Unable to perform cudnn convolution #298

HVisMyLife opened this issue Nov 16, 2024 · 0 comments

Comments

@HVisMyLife
Copy link

Hello
I'm trying to setup convolution like that:

let input_desc = cudnn.create_4d_tensor::<f32>(sys::cudnnTensorFormat_t::CUDNN_TENSOR_NCHW, [1,1,64,64]).unwrap();
let output_desc = cudnn.create_4d_tensor::<f32>(sys::cudnnTensorFormat_t::CUDNN_TENSOR_NCHW, [1,1,64,64]).unwrap();
let filter_desc = cudnn.create_4d_filter::<f32>(sys::cudnnTensorFormat_t::CUDNN_TENSOR_NCHW, [1,1,1,1]).unwrap();
let mut convolution_desc = cudnn.create_conv2d::<f32>([0,0], [1,1], [1,1], sys::cudnnConvolutionMode_t::CUDNN_CONVOLUTION).unwrap();
convolution_desc.set_math_type(sys::cudnnMathType_t::CUDNN_DEFAULT_MATH).unwrap();
convolution_desc.set_group_count(1).unwrap();

let convolution = ConvForward {conv: &convolution_desc, x: &input_desc, w: &filter_desc, y: &output_desc};
let algo = convolution.pick_algorithm().unwrap();
let workspace_size = convolution.get_workspace_size(algo).unwrap();

let matrix = vec![0.5; 64*64];
let kernel = vec![0.2; 1];
let matrix_output = vec![0.0; 64*64];

let src = gpu.htod_copy(matrix).unwrap();
let filter = gpu.htod_copy(kernel).unwrap();
let mut dest = gpu.htod_copy(matrix_output).unwrap();
unsafe {
    let mut workspace = gpu.alloc_zeros::<u8>(workspace_size).unwrap();
    let mut workspace = workspace.transmute_mut::<u8>(workspace_size).unwrap();
    convolution.launch(algo, Some(&mut workspace), (1.,0.), &src, &filter, &mut dest).unwrap();
}

And it that form (with one element kernel) it works as expected, output is full of 0.1 (0.5*0.2).
However, as soon as I change kernel's dimensions to more than that (for example [1,1,3,3]) it throws CudnnError(CUDNN_STATUS_BAD_PARAM) at pick_algorithm()... What I'm doing wrong?

Thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant