TensorFlow
TensorFlow is a free and open-source software library for machine learning and artificial intelligence. It can be used across a range of tasks but has a particular focus on training and inference of deep neural networks. TensorFlow can be used in a wide variety of programming languages, including Python, JavaScript, C++, and Java. This flexibility lends itself to a range of applications in many different sectors.
Slurm Script
#!/bin/bash
#SBATCH -J mytensorjob # Job name
#SBATCH -o mytensor.%j.out # Name of stdout output file (%j expands to jobId)
#SBATCH -p CUIQue # Queue name
#SBATCH -N 1 # Total number of nodes requested
#SBATCH -n 16 # Total number of mpi tasks requested
module load py-tensorflow/2.7.0 python/3.8.12 py-numpy/1.22.4
python3.8 basicOperations.py
basicOperations.py Code
#!/usr/bin/env python # coding: utf-8 # # Basic Tensor Operations from __future__ import print_function import tensorflow as tf # Define tensor constants. a = tf.constant(2) b = tf.constant(3) c = tf.constant(5) # Various tensor operations. # Note: Tensors also support python operators (+, *, ...) add = tf.add(a, b) sub = tf.subtract(a, b) mul = tf.multiply(a, b) div = tf.divide(a, b) # Access tensors value. print("add =", add.numpy()) print("sub =", sub.numpy()) print("mul =", mul.numpy()) print("div =", div.numpy()) # Some more operations. mean = tf.reduce_mean([a, b, c]) sum = tf.reduce_sum([a, b, c]) # Access tensors value. print("mean =", mean.numpy()) print("sum =", sum.numpy()) # Matrix multiplications. matrix1 = tf.constant([[1., 2.], [3., 4.]]) matrix2 = tf.constant([[5., 6.], [7., 8.]]) product = tf.matmul(matrix1, matrix2) print(product.numpy())
Submit the job to the scheduler as
sbatch pytensorflowexample.slurm
For managing your “job” , refer to this guide.
For more on Tensorflow framework, refer to their official documentation
https://www.tensorflow.org/overview