*** Wartungsfenster jeden ersten Mittwoch vormittag im Monat ***

Skip to content
Snippets Groups Projects
Commit 55807b92 authored by Muck, Katrin's avatar Muck, Katrin
Browse files

added a pytorch cuda example

parent 8eb49752
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
##############################################################################
# User Request:
# - allocate single gpu node using 1 A40 GPU
# - run python script
#
# Provided Allocation:
# - 1 shared gpu node
# - 1 A40 GPU
# - 8 physical cores / 16 logical cores
# - 128 GB memory
#
# VSC policy:
# - '--ntasks-per-node' & '--ntasks' implicitly set to 8
#
# Accounting:
# - 1x 8 core hours / hour
##############################################################################
#SBATCH --partition=zen2_0256_a40x2
#SBATCH --qos=zen2_0256_a40x2
#SBATCH --gres=gpu:1
# optionally activate a conda or python environment
module load miniconda3
eval "$(conda shell.bash hook)"
conda activate pytorch-cuda
# run python code
python pytorch-test.py
# Pytorch CUDA Environment
To install the environment simply use conda
```bash
module load miniconda3
eval "$(conda shell.bash hook)"
conda env create -f environment.yaml
```
To run a test use `01-pytorch-python-single-gpu.sh`
```bash
sbatch 01-pytorch-python-single-gpu.sh
```
## Compiling CUDA codes
https://conda-forge.org/docs/user/faq/#how-can-i-compile-cuda-host-or-device-codes-in-my-environment
For this to work we have to load a CUDA toolkit installation from our cuda-zen spack environment e.g.
```bash
cuz # switch to cuda-zen spack env
module load cuda/12.3.0-gcc-9.5.0-imxfeek
```
Alternatively it should be possible to use the nvidia packages (e.g. `nvidia::cuda-toolkit`) instead of the
conda-forge ones. However in this case we need to be careful with the dependencies so that we dont mix the packages
and installations of the different sources ...
\ No newline at end of file
name: pytorch-cuda
channels:
- pytorch
- conda-forge
- bioconda
- nvidia
- defaults
dependencies:
- python=3.*
- pip
- pytorch=*=*cuda12*cudnn8.9*
- cudnn=8.9*
- cuda-version=12.1*
- nvcc
- keras
- nccl
from torch import cuda
print("CUDA Available: ", cuda.is_available())
print("Num GPUs Available: ", cuda.device_count())
print("First Device Info: ", cuda.get_device_name(cuda.current_device()))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment