{ "info": { "author": "Hannes Bretschneider", "author_email": "habretschneider@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2.7", "Topic :: Scientific/Engineering :: Artificial Intelligence", "Topic :: Scientific/Engineering :: Image Recognition" ], "description": "cudnn-python-wrappers\r\n=====================\r\n\r\nPython wrappers for the NVIDIA cuDNN libraries.\r\n-----------------------------------------------\r\n\r\nThis is a set of minimal Python wrappers for the `NVIDIA\r\ncuDNN `__ library of convolutional\r\nneural network primitives. NVIDIA cuDNN is available free of charge, but\r\nrequires an NVIDIA developer account to download. Users should follow\r\nthe cuDNN API documentation to use these wrappers, as they faithfully\r\nreplicate the cuDNN C API.\r\n\r\nThese wrappers expose the full cuDNN API as Python functions, but are\r\nminimalistic in that they don't implement any higher order\r\nfunctionality, such as operating directly on data structures like\r\nPyCUDA ``GPUArray`` or cudamat ``CUDAMatrix``. Since the interface\r\nfaithfully replicates the C API, the user is responsible for\r\nallocating and deallocating handles to all cuDNN data structures and\r\npassing references to arrays as pointers. However, cuDNN status codes\r\nare translated to Python exceptions. The most common application for\r\nthese wrappers will be to be used along `PyCUDA \r\n`__, but they will work\r\nequally well with other frameworks such as `CUDAMat\r\n`__.\r\n\r\nUsers need to make sure that they pass all arguments as the correct data\r\ntype, that is ``ctypes.c_void_p`` for all handles and array pointers and\r\n``ctypes.c_int`` for all integer arguments and enums. Here is an example\r\non how to perform forward convolution on a PyCUDA ``GPUArray``:\r\n\r\n.. code:: python\r\n\r\n import pycuda.autoinit\r\n from pycuda import gpuarray\r\n import libcudnn, ctypes\r\n import numpy as np\r\n\r\n # Create a cuDNN context\r\n cudnn_context = libcudnn.cudnnCreate()\r\n\r\n # Set some options and tensor dimensions\r\n accumulate = libcudnn.cudnnAccumulateResults['CUDNN_RESULT_NO_ACCUMULATE']\r\n tensor_format = libcudnn.cudnnTensorFormat['CUDNN_TENSOR_NCHW']\r\n data_type = libcudnn.cudnnDataType['CUDNN_DATA_FLOAT']\r\n convolution_mode = libcudnn.cudnnConvolutionMode['CUDNN_CROSS_CORRELATION']\r\n convolution_path = libcudnn.cudnnConvolutionPath['CUDNN_CONVOLUTION_FORWARD']\r\n\r\n n_input = 100\r\n filters_in = 10\r\n filters_out = 8\r\n height_in = 20\r\n width_in = 20\r\n height_filter = 5\r\n width_filter = 5\r\n pad_h = 4\r\n pad_w = 4\r\n vertical_stride = 1\r\n horizontal_stride = 1\r\n upscalex = 1\r\n upscaley = 1\r\n\r\n # Input tensor\r\n X = gpuarray.to_gpu(np.random.rand(n_input, filters_in, height_in, width_in)\r\n .astype(np.float32))\r\n\r\n # Filter tensor\r\n filters = gpuarray.to_gpu(np.random.rand(filters_out,\r\n filters_in, height_filter, width_filter).astype(np.float32))\r\n\r\n #Descriptor for input\r\n X_desc = libcudnn.cudnnCreateTensor4dDescriptor()\r\n libcudnn.cudnnSetTensor4dDescriptor(X_desc, tensor_format, data_type,\r\n n_input, filters_in, height_in, width_in)\r\n\r\n # Filter descriptor\r\n filters_desc = libcudnn.cudnnCreateFilterDescriptor()\r\n libcudnn.cudnnSetFilterDescriptor(filters_desc, data_type, filters_out,\r\n filters_in, height_filter, width_filter)\r\n\r\n # Convolution descriptor\r\n conv_desc = libcudnn.cudnnCreateConvolutionDescriptor()\r\n libcudnn.cudnnSetConvolutionDescriptor(conv_desc, X_desc, filters_desc,\r\n pad_h, pad_w, vertical_stride, horizontal_stride, upscalex, upscaley,\r\n convolution_mode)\r\n\r\n # Get output dimensions (first two values are n_input and filters_out)\r\n _, _, height_output, width_output = libcudnn.cudnnGetOutputTensor4dDim(\r\n conv_desc, convolution_path)\r\n\r\n # Output tensor\r\n Y = gpuarray.empty((n_input, filters_out, height_output, width_output), np.float32)\r\n Y_desc = libcudnn.cudnnCreateTensor4dDescriptor()\r\n libcudnn.cudnnSetTensor4dDescriptor(Y_desc, tensor_format, data_type, n_input,\r\n filters_out, height_output, width_output)\r\n\r\n # Get pointers to GPU memory\r\n X_data = ctypes.c_void_p(int(X.gpudata))\r\n filters_data = ctypes.c_void_p(int(filters.gpudata))\r\n Y_data = ctypes.c_void_p(int(Y.gpudata))\r\n\r\n # Perform convolution\r\n libcudnn.cudnnConvolutionForward(cudnn_context, X_desc, X_data,\r\n filters_desc, filters_data, conv_desc,\r\n Y_desc, Y_data, accumulate)\r\n\r\n # Clean up\r\n libcudnn.cudnnDestroyTensor4dDescriptor(X_desc)\r\n libcudnn.cudnnDestroyTensor4dDescriptor(Y_desc)\r\n libcudnn.cudnnDestroyFilterDescriptor(filters_desc)\r\n libcudnn.cudnnDestroyConvolutionDescriptor(conv_desc)\r\n libcudnn.cudnnDestroy(cudnn_context)\r\n\r\nInstallation\r\n------------\r\n\r\nInstall from PyPi with\r\n\r\n::\r\n\r\n pip install cudnn-python-wrappers", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/hannes-brt/cudnn-python-wrappers", "keywords": "cuda,nvidia,cudnn,convolutional neural networks,machine learning,deep learning", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "cudnn-python-wrappers", "package_url": "https://pypi.org/project/cudnn-python-wrappers/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/cudnn-python-wrappers/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/hannes-brt/cudnn-python-wrappers" }, "release_url": "https://pypi.org/project/cudnn-python-wrappers/1.0/", "requires_dist": null, "requires_python": null, "summary": "Python wrappers for the NVIDIA cudnn 6.5 R1 libraries.", "version": "1.0" }, "last_serial": 1392597, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "10fa6042e744d1bb2a1c580a456efcd8", "sha256": "caf2f0e7b7cd413e8f97c4450bafc87e32546f134a7a4d7c3b00718d12e51f8c" }, "downloads": -1, "filename": "cudnn-python-wrappers-0.1.tar.gz", "has_sig": false, "md5_digest": "10fa6042e744d1bb2a1c580a456efcd8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11805, "upload_time": "2014-11-27T01:03:32", "url": "https://files.pythonhosted.org/packages/57/b7/72086476ddb0f82e45c2b3afd8b458c4d7f336d62937e0c711889016212b/cudnn-python-wrappers-0.1.tar.gz" } ], "1.0": [ { "comment_text": "", "digests": { "md5": "a506b87add6dafdc57ef1cfc8b4400c3", "sha256": "e4f2d8d898d8aa15d55b5b8956366eb95a72a50f98c2a00fdeaa2aa6cc4bf98e" }, "downloads": -1, "filename": "cudnn-python-wrappers-1.0.tar.gz", "has_sig": false, "md5_digest": "a506b87add6dafdc57ef1cfc8b4400c3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10656, "upload_time": "2015-01-19T16:01:57", "url": "https://files.pythonhosted.org/packages/49/f6/15cd2f0135c0e8a14907aa1889da99246461a5a6fc7129a3f1d4f3c2f5a8/cudnn-python-wrappers-1.0.tar.gz" } ], "2.0b": [ { "comment_text": "", "digests": { "md5": "d4f8d88824ef281da7a28d5cf40797c8", "sha256": "c82097619f3e800d55eb5ce7ce5f7aa137eb14efd5a18c63f7cad727d1c9d253" }, "downloads": -1, "filename": "cudnn-python-wrappers-2.0b.tar.gz", "has_sig": false, "md5_digest": "d4f8d88824ef281da7a28d5cf40797c8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12610, "upload_time": "2015-01-19T19:29:46", "url": "https://files.pythonhosted.org/packages/5d/b3/c16fcb80b241fef000067fd4209e5d8003054b6ce6b3c90a4f42697b9b52/cudnn-python-wrappers-2.0b.tar.gz" } ], "2.0b2": [ { "comment_text": "", "digests": { "md5": "54d8ebeb5c8268abb02ffc6445acd919", "sha256": "73fcd1b706f9c8297922b5af7b7752ea8ee995a6305aa91f15bf6985af629dd9" }, "downloads": -1, "filename": "cudnn-python-wrappers-2.0b2.tar.gz", "has_sig": false, "md5_digest": "54d8ebeb5c8268abb02ffc6445acd919", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12695, "upload_time": "2015-01-23T00:05:17", "url": "https://files.pythonhosted.org/packages/2a/5c/d040d0b1c6646c915fdd11551e8ff02aacac7ce59cb27d78fc50eed48b62/cudnn-python-wrappers-2.0b2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a506b87add6dafdc57ef1cfc8b4400c3", "sha256": "e4f2d8d898d8aa15d55b5b8956366eb95a72a50f98c2a00fdeaa2aa6cc4bf98e" }, "downloads": -1, "filename": "cudnn-python-wrappers-1.0.tar.gz", "has_sig": false, "md5_digest": "a506b87add6dafdc57ef1cfc8b4400c3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10656, "upload_time": "2015-01-19T16:01:57", "url": "https://files.pythonhosted.org/packages/49/f6/15cd2f0135c0e8a14907aa1889da99246461a5a6fc7129a3f1d4f3c2f5a8/cudnn-python-wrappers-1.0.tar.gz" } ] }