A deep learning library written mostly from scratch with the goal of using only the Python standard library, numpy, and CUDA.
matmul.so
is a shared object that can do matrix multiplication using a single
GPU. Currently, matmul.so
performs worse than numpy.matmul
.
- Install Nvidia driver
- Install a compatible version of CUDA toolkit
- Install CUDNN
- clone repo and run
make
to build the shared objects
git clone https://github.com/markjay4k/morknn
cd morknn
make
- Create a python virtual environment
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
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)
you will need an Nvidia GPU and the CUDA toolkit installed