| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 |
- github
- MyAnimeList
- ansible
- cached
- pandas
- Jupyter Notebook
- directories
- SCV
- GIT
- noob
- python
- JSON
- strings
- workbench
- Methods
- commands
- Filecoin
- crawler
- MySQL
- Blockchain
- .gitignore
- Django
- project
- DATABASE
- API
- Classes
- basics
- Linux
- Anime
- forks
- Today
- Total
제니 블로그
CUDA on Linux (22.04 Ubuntu) 본문
CUDA (Compute Unified Device Architecture) is a parallel computing platform and application programming interface (API) model created by NVIDIA. IT enables CUDA-enabled graphics processing unit for general-purpose preprocessing. It extended the capabilities of the GPU to handle computational workloads beyond graphic.
Key Features:
- Parallel Computing: CUDA enables running thousands of threads concurrently, making it beneficial for highly parallel tasks.
- Heterogeneous Computing: It allows for the integration of both CPU and GPU computation in a unified programming model. This means you can offload computationally intensive tasks to the GPU while the CPU handles other tasks.
- High-Performance Computing: CUDA offers significant speedup for certain computational tasks compared to traditional CPU-only computation, especially in fields like machine learning, scientific simulations, and financial modeling.
- Rich Ecosystem: There are many libraries, tools, and frameworks that support CUDA, including but not limited to cuBLAS, cuFFT, and cuDNN for tasks like linear algebra, Fourier transforms, and deep learning respectively.
- C/C++ Based: CUDA extends C/C++ with keywords to allow for parallel execution on the GPU.
- Cross-Platform: CUDA is available for Windows, Linux, and macOS, although the full feature set is best supported on Linux.
- Versioning: CUDA has been through several versions, each bringing performance improvements and additional features.
How Does It Work?
- Kernel Launch: A function running on the CPU (known as the "host") launches a function to be run on the GPU (known as the "device"). This function is called a "kernel."
- Thread Hierarchy: Each kernel is executed by multiple threads on the GPU. Threads are organized into blocks, and blocks are organized into a grid.
- Memory Management: CUDA provides various types of memory (global, shared, constant, etc.) optimized for different use-cases.
- Synchronization: CUDA provides mechanisms to synchronize threads and manage resources.
- Data Transfer: Data is often transferred from the CPU memory to the GPU memory before computation and back after computation.
- CUDA is particularly popular in fields that require heavy computational power, such as deep learning, scientific research, and real-time systems.
Installing Nvidia-driver + CUDA v12.0
You need to download the CUDA from the NVIDIA CUDA Downloads page to download the appropriate version of the CUDA toolkit for the system.
$ wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pin
$ sudo mv cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600
$ wget https://developer.download.nvidia.com/compute/cuda/12.0.0/local_installers/cuda-repo-ubuntu2204-12-0-local_12.0.0-525.60.13-1_amd64.deb
$ sudo dpkg -i cuda-repo-ubuntu2204-12-0-local_12.0.0-525.60.13-1_amd64.deb
$ sudo cp /var/cuda-repo-ubuntu2204-12-0-local/cuda-*-keyring.gpg /usr/share/keyrings/
$ sudo apt-get update
$ sudo apt-get -y install cuda
After the installation, you need to set the path for CUDA in bashrc to locate the program.
$ vi ~/.bashrc
export PATH="$PATH:/usr/local/cuda-12.2/bin:/usr/local/go/bin"
export LD_LIBRARY_PATH="/usr/local/cuda-12.2/lib64:$LD_LIBRARY_PATH"
export CUDA_HOME="/usr/local/cuda"
$ source ~/.bashrc
If installed successfully and set up , then running the command nvcc --version will give a result below.
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2023 NVIDIA Corporation
Built on Fri_Jan__6_16:45:21_PST_2023
Cuda compilation tools, release 12.0, V12.0.140
Build cuda_12.0.r12.0/compiler.32267302_0
CUDA is used for many purposes, but the one that I mainly work with currently is for GPU computing for Lotus, the software program for Filecoin.
Filecoin is built on blockchain and as a storage provider, we currently store data on the blockchain network, sealing the data in process which involves having a powerful GPU (ex : GeForceRTX 3080 or above) using the CUDA architecture.