3 releases

Uses old Rust 2015

0.0.3 Mar 2, 2016
0.0.2 Feb 2, 2016
0.0.1 Dec 7, 2015

#491 in Machine learning

Download history 286/week @ 2023-10-28 225/week @ 2023-11-04 480/week @ 2023-11-11 255/week @ 2023-11-18 243/week @ 2023-11-25 127/week @ 2023-12-02 225/week @ 2023-12-09 259/week @ 2023-12-16 228/week @ 2023-12-23 316/week @ 2023-12-30 215/week @ 2024-01-06 258/week @ 2024-01-13 172/week @ 2024-01-20 119/week @ 2024-01-27 160/week @ 2024-02-03 256/week @ 2024-02-10

761 downloads per month
Used in 257 crates (2 directly)


867 lines

Contains (rust library, 5MB) librustc_serialize-3c33cb2a40992011.rlib, (rust library, 1MB) libterm-841ef31004739dda.rlib, (ELF exe/lib, 720KB) build-script-build, (ELF exe/lib, 580KB) build-script-build, (rust library, 550KB) liblibc-adb8b8e7aaa2f93f.rlib, (rust library, 390KB) liblibc-dd3420cb049117bb.rlib and 6 more.

rust-cuDNN • Join the chat at https://gitter.im/autumnai/collenchyma Build Status Coverage Status Crates.io License

rust-cuDNN provides safe wrapper for CUDA's cuDNN library, so you can use it comfortably and safely in your Rust application.

As cuDNN relies on CUDA to allocate memory on the GPU, you might also look into rust-cuda.

rust-cudnn was developed at Autumn for the Rust Machine Intelligence Framework Leaf.

rust-cudnn is part of the High-Performance Computation Framework Collenchyma, for the [Neural Network Plugin][nn]. For an easy, unified interface for NN operations, such as those provided by cuDNN, you might check out Collenchyma.

For more information,

Getting Started

If you're using Cargo, just add rust-cuDNN to your Cargo.toml:

cudnn = "1.3.1"

If you're using Cargo Edit, you can call:

$ cargo add cudnn


Using the high-level Cudnn interface.

extern crate cudnn;
extern crate libc;
use cudnn::{Cudnn, TensorDescriptor};
use cudnn::utils::{ScalParams, DataType};
fn main() {
    // Initialize a new cuDNN context and allocates resources.
    let cudnn = Cudnn::new().unwrap();
    // Create a cuDNN Tensor Descriptor for `src` and `dest` memory.
    let src_desc = TensorDescriptor::new(&[2, 2, 2], &[4, 2, 1], DataType::Float).unwrap();
    let dest_desc = TensorDescriptor::new(&[2, 2, 2], &[4, 2, 1], DataType::Float).unwrap();
    // Obtain the `src` and memory pointer on the GPU.
    // NOTE: You wouldn't do it like that. You need to really allocate memory on the GPU with e.g. CUDA or Collenchyma.
    let src_data: *const ::libc::c_void = ::std::ptr::null();
    let dest_data: *mut ::libc::c_void = ::std::ptr::null_mut();
    // Now you can compute the forward sigmoid activation on your GPU.
    cudnn.sigmoid_forward::<f32>(&src_desc, src_data, &dest_desc, dest_data, ScalParams::default());


rust-cudnn depends on the cuDNN runtime libraries, which can be obtained from NVIDIA.

Manual Configuration

rust-cudnn's build script will by default attempt to locate cudnn via pkg-config. This will not work in some situations, for example,

  • on systems that don't have pkg-config,
  • when cross compiling, or
  • when cuDNN is not installed in the default system library directory (e.g. /usr/lib).

Therefore the build script can be configured by exporting the following environment variables:

    If specified, a directory that will be used to find cuDNN runtime libraries. e.g. /opt/cuda/lib

    If specified, cuDNN libraries will be statically rather than dynamically linked.

    If specified, will be used to find cuDNN libraries under a different name.

If either CUDNN_LIB_DIR or CUDNN_INCLUDE_DIR are specified, then the build script will skip the pkg-config step.

If your also need to run the compiled binaries yourself, make sure that they are available:

# Linux; for other platforms consult the instructions that come with cuDNN
cd <cudnn_installpath>


Want to contribute? Awesome! We have instructions to help you get started contributing code or documentation. And high priority issues, that we could need your help with.

We have a mostly real-time collaboration culture and happens here on Github and on the Collenchyma Gitter Channel. You can also reach out to the Maintainers {@MJ, @hobofan}.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as below, without any additional terms or conditions.


Licensed under either of

at your option.


Defines the Foreign Function Interface for the CUDA cuDNN API.