An open API service indexing awesome lists of open source software.

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

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
```