PyTorch

 PyTorch is an open source machine learning framework with GPU acceleration and deep neural networks that is based on the automatic differentiation in the Torch library of tensors.

Availability and Restrictions

Access 

OSC does not provide general access to PyTorch.  However, we are available to assist with the configuration of local individual/research-group installations on all our clusters.  If you have any questions, please contact OSC Help.

Installing PyTorch Locally

Here is a quick recipe that was used in February 2022 to install a GPU enabled version compatible with the CUDA drivers on the clusters at that time:

module load python/3.7-2019.10  cuda/11.1.1
; module list ;
conda create -n pytorch
; source activate pytorch
; pip install -t ~/local/pytorch torch==1.10.2+cu111 torchvision==0.11.3+cu111 -f https://download.pytorch.org/whl/cu111/torch_stable.html

This uses a local install directory hierarchy described here and can be tested via:

module load python/3.7-2019.10 cuda/11.1.1
; module list ;
source activate pytorch
python <<EOF
import torch

x = torch.rand(5, 3)
print("torch.rand(5, 3) =", x)

print( "Is cuda available =", torch.cuda.is_available() )
exit
EOF

 

Here is an older recipe with explanations.

Create a local python environment (e.g., pytorch-test) for Pytorch installation:

Load a python module:

module load python/3.6-conda5.2

Create a local python environment (e.g., pytorch-test) for Pytorch installation:

conda create -n pytorch-test python=3.6 anaconda

Activate the environment:

source activate pytorch-test

Install Pytorch:

pip install torch torchvision

Please refer here if you want a different version of the Pytorch.

Please follow this link for more information.

Feel free to contact OSC Help if you have any issues with installation.

Publisher/Vendor/Repository and License Type

https://pytorch.org, Open source.

Usage on Owens

Usage on Owens

Setup on Owens

 To configure the Owens cluster for the use of Pytorch, use the following commands:

module load python/3.6 cuda

Batch Usage on Owens

Batch jobs can request multiple nodes/cores and compute time up to the limits of the OSC systems. Refer to Queues and Reservations for Owens, and Scheduling Policies and Limits for more info.  In particular, Pytorch should be run on a GPU-enabled compute node.

An Example Batch Script Templte

Below is an example batch script (job.pbs) for using PyTorch.

Contents of job.pbs

#PBS -N pytorch
#PBS -l nodes=1:ppn=28:gpus=1:default
#PBS -l walltime=30:00
#PBS -j oe
#PBS -S /bin/bash 
#PBS -A yourprojectID

cd $PBS_O_WORKDIR
module load python/3.6 cuda
source activate your-local-python-environment-name
python your-pytorch-script.py

In order to run it via the batch system, submit the job.pbs  file with the following command:

qsub job.pbs

Further Reading

PyTorch Homepage

Supercomputer: 
Service: 
Technologies: 
Fields of Science: