Giter Site home page Giter Site logo

cudainline's Introduction

CUDAInline

This is just another attempt to enable a CUDA interface within Python.

In ThrustRTC, I implemented most of the algorithms of Thrust in C++ and made Python/C#/JAVA bindings. This made things over-complicated, and writing wrapping layers is tedious.

This project is a distillation of the engine part of ThrustRTC. It provides the minimal interfaces to Python that are just enough for user to use CUDA in Python and to do more complicated stuff fully within Python, without the need of writting more C++ code.

It is possible to extend the code in Python to do all the Thrust stuff. Also possible to wrap the C++ engine to interface C#/JAVA. However, to implement everything provided by ThrustRTC, we may end up with even more code, which is against the essense of the project: keep it light-weighted, make things simple and easy.

Installation

Install from Source Code

Source code of CUDAInline is available at: https://github.com/fynv/CUDAInline

The code does not actually contain any CUDA device code that need to be prebuilt, therefore CUDA SDK is not a requirement at building time.

At build time, you will only need:

  • UnQLite source code, as submodule: thirdparty/unqlite
  • CMake 3.x

After cloning the repo from github and resolving the submodules, you can build it with CMake.

$ mkdir build
$ cd build
$ cmake .. -DBUILD_PYTHON_BINDINGS=true -DBUILD_TESTS=true -DINCLUDE_TESTS=true
$ make
$ make install

You will get the library headers, binaries and examples in the "install" directory.

Install PyCUDAInline from PyPi

Builds for Win64/Linux64 + Python 3.x are available from Pypi. If your environment matches, you can try:

$ pip3 install CUDAInline

Runtime Dependencies

  • CUDA driver (up-to-date)

  • Shared library of NVRTC

    • Windows: nvrtc64*.dll, default location: %CUDA_PATH%/bin
    • Linux: libnvrtc.so, default location: /usr/local/cuda/lib64

    If the library is not at the default location, you need to call:

    • set_libnvrtc_path() from C++ or
    • CUDAInline.set_libnvrtc_path() from Python

    at run-time to specify the path of the library.

For Python

  • Python 3
  • cffi
  • numpy
  • numba (optional)

Functionality

CUDAInlines lets you run CUDA kernels embedded in Python code just like in ThrustRTC.

The 'DVCombine' interface is provide for user to implement custom DeviceViewable classes without using C++.

The 'DVVector' class in this project is implemented using the 'DVCombine' interface, as a combination of a general DVBuffer and a DVUInt64 (for size info), in contrast to the implementation in ThrustRTC, which is wrapping of the underlying C++ class.

License

I've decided to license this project under '"Anti 996" License'

Basically, you can use the code any way you like unless you are working for a 996 company.

996.icu

cudainline's People

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.