examples
This is an old revision of the document!
PyTorch
Consider the following simple python test script( “pytorch_test.py”):
import torch def test_pytorch(): print("PyTorch version:", torch.__version__) print("CUDA available:", torch.cuda.is_available()) if torch.cuda.is_available(): print("CUDA device:", torch.cuda.get_device_name(0)) device = torch.device("cuda") else: device = torch.device("cpu") # Simple tensor operation x = torch.tensor([1.0, 2.0, 3.0], device=device) y = torch.tensor([4.0, 5.0, 6.0], device=device) z = x + y print("Tensor operation result:", z) test_pytorch()
To test it on the unite cluster you can use the folling sbatch scrpit to run it:
#!/bin/bash #SBATCH --job-name=pytorch_test #SBATCH --output=pytorch_test.out #SBATCH --error=pytorch_test.err #SBATCH --time=00:10:00 #SBATCH --partition=a40 #SBATCH --gres=gpu:1 #SBATCH --mem=4G #SBATCH --cpus-per-task=2 # Load necessary modules (modify based on your system) module load python/pytorch-2.5.1-llvm-cuda-12.3-python-3.13.1-llvm # Activate your virtual environment if needed # source ~/your_env/bin/activate # Run the PyTorch script python3.13 pytorch_test.py
examples.1743458958.txt.gz · Last modified: 2025/03/31 22:09 by nshegunov