Welcome to the official GitHub repository containing all the examples and exercises related to the GPU section of the Parallel Computing (PAC) course at the Fachhochschule Nordwestschweiz (FHNW). This repository is designed to help students manage and execute their code using Visual Studio Code as their IDE.
- Comprehensive Examples and Exercises: Each CUDA file contains relevant examples and exercises as per the PAC curriculum focused on GPU computing.
- IDE Support: Configured to use Visual Studio Code, enhancing the development experience with features tailored for GPU programming.
- Dynamic Compilation and Execution: Compile, run, debug, and profile tasks are set up to operate on the "current file" opened in VS Code, making it straightforward to work on individual exercises and examples.
- Weekly Updates: New exercises will be added weekly, corresponding with the course schedule. Ensure you pull the latest changes to stay up to date.
-
Install VS Code: Download and instal VS Code
-
Install Plugins: Install "Azure Virtual Machines" and "Remote Development" Plugin inside your VS Code.
-
Access to your GPU VM: Login with your students mail account in the Azure plugin. Start your virtual machine there. Make a remote connection to the public IP of your server inside the Remote Dev plugin. The SSH key can be downloaded in MS teams. Make sure the file permissions of the SSH keys are read-only for your user (400 in Linux).
ssh -i id_rsa_pac [email protected]
-
Install CUDA Toolkit: Download and install the specified CUDA Toolkit. Do NOT install the Nvidia Driver. The driver already installed on your VM matched the CUDA version.
wget https://developer.download.nvidia.com/compute/cuda/12.4.1/local_installers/cuda_12.4.1_550.54.15_linux.run sudo sh cuda_12.4.1_550.54.15_linux.run
Enable performance counters for debugging. Create a new file and add the line:
sudo vi /etc/modprobe.d/nvidia.conf options nvidia NVreg_RestrictProfilingToAdminUsers=0
As noted in the CUDA installation output, make sure PATH and LD_LIBRARY_PATH are extended with CUDA. Update /etc/environment and restart the VM and ALL your VS Code instances:
PATH="/usr/local/cuda-12.4/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin" LD_LIBRARY_PATH="/usr/local/cuda-12.4/lib64"
Lower the Linux paranoid level to be able to do profiling:
sudo sysctl kernel.perf_event_paranoid=0
-
Install nsight VS code plugin: Install on the remote VS code instance the "Nsight" plugin from Nvidia. This enables GPU debugging inside VS Code.
-
Install Nsight profiling Tools: Install Nsight Systems and Nsight Compute locally on your machine. This enables you to open the profiling files generated on the GPU enabled remote system.
To get started with the repository, clone it to your GPU enabled machine and open the directory using VS Code.
- Open a file: Navigate to the file you wish to work on.
- Compile/Run: Use the pre-configured tasks in VS Code (accessible via Terminal -> Run Task in VS Code).
- Debug/Profile: Launch the debugging or profiling tools through the Run menu in VS Code.
Ensure that your development environment is set up with all the necessary dependencies for GPU computing, including the correct drivers and SDKs. Install the Nvidia VS Code extension "nsight"
Feel free to fork this repository and submit pull requests to contribute to the exercises. For major changes, please open an issue first to discuss what you would like to change.
If you encounter any problems, please ask in classes or write in the MS Teams Forum.
Happy Coding!