Git Product home page Git Product logo

learning_cuda's Introduction

learning_cuda

Introduction to cpp/cuda extension for PyTorch and building first cpp bridge.

PyTorch -> Cpp -> CUDA

In this tutorial, we will implement a PyTorch CUDA extension called diff_trilinear_interpolation. The forward and backward modules are implemented in CUDA and the C++ bridge is used to connect the PyTorch and CUDA.

Tutorial Video by YouTuber AI葵 | Github Repo

References

File Structures

.
├── build
├── diff_interpolation                 # cuda implementation
│   ├── backward.cu
│   ├── backward.h
│   ├── forward.cu
│   └── forward.h
├── diff_trilinear_interpolation       # python api
│   ├── __init__.py
├── ext.cpp
├── interpolation.cpp                  # cpp bridge script
├── interpolation.h
├── README.md
├── setup.py                           # pybind build script
└── test.py                            # test script

Test

cd learning_cuda
pip install .

python test.py

results:

CUDA forward time: 0.002805948257446289 s
PyTorch forward time: 0.004231929779052734 s
Forward all close True

CUDA backward time 0.005219936370849609 s
PyTorch backward time 0.03641915321350098 s
Backward all close True

learning_cuda's People

Contributors

cxzhou35 avatar

Stargazers

 avatar

Watchers

 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.