markjay4k / morknn

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Morknn

A deep learning library written mostly from scratch with the goal of using only the Python standard library, numpy, and CUDA.

Current Status (incomplete)

matmul.so is a shared object that can do matrix multiplication using a single GPU. Currently, matmul.so performs worse than numpy.matmul.

Install

  1. Install Nvidia driver
  2. Install a compatible version of CUDA toolkit
  3. Install CUDNN
  4. clone repo and run make to build the shared objects
    git clone https://github.com/markjay4k/morknn
    cd morknn
    make
  1. Create a python virtual environment
    python3 -m venv venv
    source venv/bin/activate
    pip install -r requirements.txt

examples

    import PyInit_matmul as mm
    import numpy as np


    n = 2 ** 12
    A = np.random.rand(n, n).astype(np.float32)
    B = np.random.rand(n, n).astype(np.float32)
    print(f'multiplying {A.shape} by {B.shape} matrices')
    result = mm.matmulcuda(A, B)

Requirements

you will need an Nvidia GPU and the CUDA toolkit installed

About

License:The Unlicense


Languages

Language:Jupyter Notebook 99.3%Language:Python 0.6%Language:Cuda 0.1%Language:Makefile 0.0%