Skip to content
This repository has been archived by the owner on Aug 17, 2021. It is now read-only.

Convolutional net example throws at runtime #2

Closed
subversive-owl opened this issue Aug 20, 2017 · 2 comments · Fixed by #8
Closed

Convolutional net example throws at runtime #2

subversive-owl opened this issue Aug 20, 2017 · 2 comments · Fixed by #8
Assignees

Comments

@subversive-owl
Copy link
Contributor

subversive-owl commented Aug 20, 2017

Log:

target/release/juice-examples mnist conv --batch-size 10 --learning-rate 0.002
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: BadParam("`window_dim_a`, `padding_a` or `stride_a` has negative element or invalid `mode`.")', /checkout/src/libcore/result.rs:860
note: Run with `RUST_BACKTRACE=1` for a backtrace.

The relevant part of the backtrace is here:

   9: core::result::unwrap_failed
  10: <juice::layers::common::pooling::Pooling<f32, B> as juice::layer::ILayer<B>>::reshape
  11: <juice::layer::Layer<B>>::connect
  12: <juice::layers::container::sequential::Sequential<B>>::init_layer
  13: <juice::layers::container::sequential::Sequential<B>>::from_config
  14: <juice::layer::Layer<B>>::from_config
  15: juice_examples::run_mnist
  16: juice_examples::main
  17: __rust_maybe_catch_panic
             at /checkout/src/libpanic_unwind/lib.rs:98
  18: std::rt::lang_start
             at /checkout/src/libstd/panicking.rs:433
             at /checkout/src/libstd/panic.rs:361
             at /checkout/src/libstd/rt.rs:59
  19: __libc_start_main
  20: _start
@subversive-owl
Copy link
Contributor Author

subversive-owl commented Sep 10, 2017

found where the error is being thrown from exactly, rust-cudnn/cudnn/src/api/pooling.rs:

 unsafe fn ffi_set_pooling_nd_descriptor(
        desc: cudnnPoolingDescriptor_t,
        mode: cudnnPoolingMode_t,
        maxpooling_nan_opt: cudnnNanPropagation_t,
        nb_dims: ::libc::c_int,
        window_dim_a: *const ::libc::c_int,
        padding_a: *const ::libc::c_int,
        stride_a: *const ::libc::c_int,
    ) -> Result<(), Error> {
        match cudnnSetPoolingNdDescriptor(desc, mode, maxpooling_nan_opt, nb_dims, window_dim_a, padding_a, stride_a) {
            cudnnStatus_t::CUDNN_STATUS_SUCCESS => Ok(()),
            cudnnStatus_t::CUDNN_STATUS_BAD_PARAM => Err(Error::BadParam("`window_dim_a`, `padding_a` or `stride_a` has negative element or invalid `mode`.")),
            _ => Err(Error::Unknown("Unable to set CUDA cuDNN Pooling Descriptor.")),
        }
    }

now to find out what's making it upset...

@subversive-owl
Copy link
Contributor Author

subversive-owl commented Sep 11, 2017

partial finding:

at

impl PoolingDescriptor {
    /// Initializes a new CUDA cuDNN Pooling Descriptor.
    pub fn new(mode: cudnnPoolingMode_t, window: &[i32], padding: &[i32], stride: &[i32]) -> Result<PoolingDescriptor, Error> {
        let generic_pooling_desc = try!(API::create_pooling_descriptor());

stride is equal to [0,0] here despite it being called with

net_cfg.add_layer(LayerConfig::new("pooling", PoolingConfig { mode: PoolingMode::Max, 
  filter_shape: vec![2], padding: vec![0], stride: vec![2] }));

at the other end of the stack.

In the Pooling layer implementation at juice/src/layers/pooling.rs,

impl<B: IBackend + conn::Pooling<f32>> ILayer<B> for Pooling<f32, B> {
    impl_ilayer_common!();

    fn reshape(&mut self,
               backend: ::std::rc::Rc<B>,
               input_data: &mut Vec<ArcLock<SharedTensor<f32>>>,
               input_gradient: &mut Vec<ArcLock<SharedTensor<f32>>>,
               weights_data: &mut Vec<ArcLock<SharedTensor<f32>>>,
               weights_gradient: &mut Vec<ArcLock<SharedTensor<f32>>>,
               output_data: &mut Vec<ArcLock<SharedTensor<f32>>>,
               output_gradient: &mut Vec<ArcLock<SharedTensor<f32>>>) {

stride is defined as let stride = cast_vec_usize_to_i32(self.stride_dims(num_spatial_dims));, which is still equal to [2,2]

however, in the call to let config = backend.new_pooling_config(&filter, &padding, &stride).unwrap(); it's somehow changed:

impl<T> Pooling<T> for Backend<Cuda>
    where T: Float + Default + DataTypeInfo
{
    fn new_pooling_config(&self,
                          window: &[i32],
                          stride: &[i32],
                          padding: &[i32])
                          -> Result<Self::CPOOL, ::co::error::Error> {
        println!("got to just before pooling descriptor");
        println!("stride is {:?}", stride);

at this point stride is [0, 0].

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

Successfully merging a pull request may close this issue.

2 participants