Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

⚒️ CUDA by Example: An Introduction to General-Purpose GPU Programming ⚒️

License

Notifications You must be signed in to change notification settings

Zerohertz/cuda-by-example

Repository files navigation

⚒️ CUDA by Example ⚒️

An Introduction to General-Purpose GPU Programming

Build System
Languages
Compilers
Infrastructure

👷 Setup 👷

$ make docker
docker run \
-d --name gpu \
-v ./:/workspace \
-w /workspace \
zerohertzkr/gpu
566c42b4cc083fff284fd35b518465552699ebda67162987d755fb812da51c9a
$ make exec
docker exec -it gpu zsh
$ make init
...
$ make rm
docker rm -f gpu
gpu

⚙️ Build & Run ⚙️

Clang++ NVCC
$ make clang
rm -rf build && \
cmake -S . -B build \
-DUSE_NVCC=OFF \
-- Using Clang++ compiler
-- The C compiler identification is GNU 13.3.0
-- The CXX compiler identification is Clang 18.1.3
-- The CUDA compiler identification is Clang 18.1.3
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting CUDA compiler ABI info
-- Detecting CUDA compiler ABI info - done
-- Check for working CUDA compiler: /usr/bin/clang++ - skipped
-- Detecting CUDA compile features
-- Detecting CUDA compile features - done
-- Found CUDAToolkit: /usr/local/cuda/include (found version "12.6.85")
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so
-- Configuring done (8.2s)
-- Generating done (0.0s)
-- Build files have been written to: /workspace/build

$ make nvcc
rm -rf build && \
cmake -S . -B build \
-DUSE_NVCC=ON \
-- Using NVCC compiler
-- The C compiler identification is GNU 13.3.0
-- The CXX compiler identification is Clang 18.1.3
-- The CUDA compiler identification is NVIDIA 12.6.85
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting CUDA compiler ABI info
-- Detecting CUDA compiler ABI info - done
-- Check for working CUDA compiler: /usr/local/cuda/bin/nvcc - skipped
-- Detecting CUDA compile features
-- Detecting CUDA compile features - done
-- Found CUDAToolkit: /usr/local/cuda/targets/x86_64-linux/include (found version "12.6.85")
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so
-- Configuring done (8.1s)
-- Generating done (0.0s)
-- Build files have been written to: /workspace/build

$ cd build
$ make 01_hello_world && ./01_hello_world
[ 50%] Building CUDA object CMakeFiles/01_hello_world.dir/src/chapter03/01_hello_world.cu.o
clang++: warning: CUDA version is newer than the latest supported version 12.3 [-Wunknown-cuda-version]
[100%] Linking CUDA executable 01_hello_world
[100%] Built target 01_hello_world
[2025-09-03 23:28:58] [src/chapter03/01_hello_world.cu:5] ℹ️ Hello, World!
[2025-09-03 23:28:58] [src/chapter03/01_hello_world.cu:6] ⚠️ Hello, World!
[2025-09-03 23:28:58] [src/chapter03/01_hello_world.cu:7] ❌ Hello, World!
$ cd build
$ make 01_hello_world && ./01_hello_world
[ 50%] Building CUDA object CMakeFiles/01_hello_world.dir/src/chapter03/01_hello_world.cu.o
[100%] Linking CUDA executable 01_hello_world
[100%] Built target 01_hello_world
[2025-09-03 23:20:13] [src/chapter03/01_hello_world.cu:5] ℹ️ Hello, World!
[2025-09-03 23:20:13] [src/chapter03/01_hello_world.cu:6] ⚠️ Hello, World!
[2025-09-03 23:20:13] [src/chapter03/01_hello_world.cu:7] ❌ Hello, World!

📖 Study Info 📖

Study Info

📢 GPU/CUDA 프로그래밍을 배워보세요! 북클럽 나란에서 두 가지 레벨의 스터디를 모집합니다. 📢

최근 AI 열풍으로 AI Engineering 분야도 상당히 뜨겁습니다. AI Engineering에서 GPU/CUDA 아키텍쳐는 반드시 알아야할 핵심 지식입니다. 이에 NVIDIA GPU와 Google Colab을 활용해 실습 중심으로 GPU 병렬 프로그래밍을 통해 GPU/CUDA 아키텍쳐도 배우고 GPU/CUDA 프로그래밍에 필요한 지식들을 배우는 스터디 그룹을 만들었습니다.

스터디 그룹은 입문반과 중급반으로 나누었습니다. 필요에 따라 원하는 레벨을 선택하여 참여할 수 있습니다.

참가를 원하시는 분들은 참가 신청폼을 작성해주세요. 참가 신청폼을 작성해주신 분들에게는 자세한 참가 방법을 보내드립니다. (정원이 초과하는 경우 신청폼의 내용을 기반으로 참가지를 선정할 수 있습니다.)

🚀 GPU 프로그래밍 세계에 도전하고 싶은 분들의 많은 참여를 기다립니다!


📜 References 📜

About

⚒️ CUDA by Example: An Introduction to General-Purpose GPU Programming ⚒️

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •