Skip to content

CUDA (General)

For the example source code please refer to CUDA Program Source Code (Example)


Pre-configured template script path → /home/$USER/job_template/slurm_job

#!/bin/bash
#SBATCH --job-name=cuda_hello_world ## Job Name
#SBATCH --partition=shared_gpu_l40 ## Partition for Running Job
#SBATCH --nodes=1 ## Number of Compute Node
#SBATCH --ntasks-per-node=1 # Number of Task per Compute Node
#SBATCH --cpus-per-task=2 ## Number of CPU per task
#SBATCH --time=60:00 ## Job Time Limit (i.e. 60 Minutes)
#SBATCH --mem=10GB ## Total Memory for Job
#SBATCH --gres=gpu:l40:2 # Number of GPUs per node (i.e. 1 x L40 GPU)
#SBATCH --output=./%x%j.out ## Output File Path
#SBATCH --error=./%x%j.err ## Error Log Path
## Initiate Environment Module
source /usr/share/modules/init/profile.sh
## Reset the Environment Module components
module purge
## Load Module
module load cuda/12.6
## Run user command
nvcc -o ./cuda_hw /home/${USER}/job_template/C/cuda_hello_world.cu
./cuda_hw
## Clean up
rm cuda_hw
## Clear Environment Module Components
module purge

Guides for submitting HPC job, please refer to: HPC Job Submission (For CLI) and HPC Job Submission (For Web Portal)