SBATCH – GPU Job Example

Users with codes explicitly written to run on GPUs can utilize the GPU resources. A user requests a single GPU on the ‘gpuv100’ partition. and it can then make use of the requested GPU resources. It’s worth noting that multiple GPUs can be requested for a single job, with each GPU node having 4 GPUs available. For instance, let’s request a GPU node and verify that PyTorch can access the GPU.

The gpu_test.sl Slurm file as follows.

And the corresponding python script:

$ torch_test.py
----------------------------------------------------------
import torch
if torch.cuda.is_available():
device = torch.device("cuda")
else:
device = torch.device("cpu")
print(f"Device = {device}")

Submitting this job should output “Device = cuda”, indicating that the GPU is available to do work in PyTorch.

Scroll to Top