https://github.com/alessandrobessi/cuda-lab
Playing with CUDA and GPUs in Google Colab
https://github.com/alessandrobessi/cuda-lab
cuda cuda-kernels gpu gpu-acceleration gpu-programming parallel-algorithm parallel-computing
Last synced: 30 days ago
JSON representation
Playing with CUDA and GPUs in Google Colab
- Host: GitHub
- URL: https://github.com/alessandrobessi/cuda-lab
- Owner: alessandrobessi
- License: gpl-3.0
- Created: 2019-01-16T07:08:42.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-01-18T09:42:56.000Z (over 6 years ago)
- Last Synced: 2025-04-15T19:16:43.052Z (30 days ago)
- Topics: cuda, cuda-kernels, gpu, gpu-acceleration, gpu-programming, parallel-algorithm, parallel-computing
- Language: Cuda
- Homepage:
- Size: 35.2 KB
- Stars: 9
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cuda-lab
Playing with CUDA and GPUs in Google Colab.## Usage
1. Open a Colab notebook: https://colab.research.google.com/
2. Create a new Python 3 notebook
3. Change runtime type selecting GPU as hardware accelerator
4. Git clone this repository:
```
!git clone https://github.com/alessandrobessi/cuda-lab.git
```
5. Change permissions:
```
!chmod 755 cuda-lab/INSTALL.sh
```
6. Install cuda, nvcc, gcc, and g++:
```
!./cuda-lab/INSTALL.sh
```7. Add `/usr/local/cuda/bin` to `PATH`:
```python
import os
os.environ['PATH'] += ':/usr/local/cuda/bin'
```8. Compile an existing Cuda source:
```
!nvcc cuda-lab/add.cu -o add -Wno-deprecated-gpu-targets
```9. Run the compiled Cuda source using the Nvidia profiler tool:
```
!nvprof ./add
```10. or just time it:
```
!time ./add
```You can also create a Cuda source file using the magic command `%%writefile `:
```
%%writefile snippet.cu
#include
#include
#include
...
```and then compile and run it!
```
!nvcc snippet.cu -o snippet -Wno-deprecated-gpu-targets
!nvprof ./snippet
```