Web Content Display

Independently of Jupyter, Marvin cluster can also run Python files. For example, here we have a simple python code we can run on the cluster:

 

          a = 5

          b = 2

          print(a*b)

 

As we can suppose, the output we expect is 10.

 

Open the VI text editor through the terminal and copy the above code. Save this code as an Python file (i.e. your_code.py). 

 

Next, proceed to create a sbatch file with the same text editor that has the following structure:

 

          #!/bin/bash

          #SBATCH --job-name=test

          #SBATCH --cpus-per-task=1

          #SBATCH --mem-per-cpu=8G

          #SBATCH --mail-type=END

          #SBATCH [email protected]

 

          # For the next step, choose the module Python/X.X.X that you need (module av to see available modules):

          module load Python/X.X.X  

          python your_code.py

 

Save it as a sbatch file (sbatch_example.sh), and upload it to your cluster account using an application such as FileZilla (for macOS and windows), or uploading it from your terminal if you are working with linux/ubuntu using the command:

 

$ scp ~/(path of the file in yout computer) [email protected]:/homes/users/user_name/(folder where you want your file to be or the name of the file)

 

Next, log in to the cluster from a terminal, go to the corresponding folder where your files are saved and run the sbatch file:

 

$ sbatch sbatch_exampe.sh

 

This will generate a slurm file (slurm-[number].out) that will let you check the output of your code using the command:

 

$ more slurm-[number].out