Code Monkey home page Code Monkey logo

cuda-compute's Introduction

Cuda Compute

Matrix and Vector computing library with minimal CUDA.

Example usage in scripts/run_module.py

Install

# release build
source setup.sh RELEASE
# or debug build (with debug print-outs)
source setup.sh DEBUG

Dependency

GoogleTest: for unit testing

nanobind: for python binding c++

numpy: for performance comparison

Device Query

python scripts/device_query.py

My Gamer Laptop:

Device Number: 0
NVIDIA GeForce RTX 3060 Laptop GPU
Memory Clock Rate (GHz): 7.001
Memory Bus Width (bits): 192
Peak Memory Bandwidth (GB/s): 336.048
SM Count: 30
Max Threads per Thread Block: 1024
Max Threads per SM: 1536
Max Threads Blocks per SM: 30
StreamPriority: from 0 to -5
ComputeCapability: 8.6

Examples

source run_scripts.sh

Troubleshooting

Encounter an unknown error in runtime

Run the following command

sudo rmmod nvidia_uvm
sudo modprobe nvidia_uvm

Glossary

Runtime or Driver API?

Runtime

Permission issue regarding ncu or nsys

see https://developer.nvidia.com/ERR_NVGPUCTRPERM

Check GPU details

nvidia-smi  -q -i <id>
# e.g. Check memory frequency
nvidia-smi  -q -d CLOCK | grep -A 3 "Max Clocks" | grep "Memory"

nvcc flags

In top-level CMakeLists.txt:

set(CMAKE_CUDA_FLAGS "--expt-relaxed-constexpr")

To set architecture

set(CMAKE_CUDA_FLAGS "--expt-relaxed-constexpr -arch=sm_86")

To set fast math and enable MAD

set(CMAKE_CUDA_FLAGS "--expt-relaxed-constexpr --use_fast_math -fmad=true")

see https://docs.nvidia.com/cuda/archive/11.6.0/pdf/CUDA_Math_API.pdf

If check the number of registers and the size of smem:

set(CMAKE_CUDA_FLAGS "--expt-relaxed-constexpr -Xptxas -v")

If use OpenMP

set(CMAKE_CUDA_FLAGS "--expt-relaxed-constexpr -Xcompiler -fopenmp")

and link the library, e.g. -lgomp

If compile .cu code to ptx

nvcc --ptx -o main.ptx main.cu

Hyper-Q connection setting

export CUDA_DEVICE_MAX_CONNECTIONS=32

cuda-compute's People

Stargazers

Bowen Zhang avatar

Watchers

Bowen Zhang 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.