Pytorch
Installed versions
Resource | Version |
---|---|
Dardel/cpe23.12 | 2.0.1 |
General information
PyTorch is an open-source machine learning library for Python, based on Torch. PyTorch provides two high-level features: - Tensor computation (like NumPy) with strong GPU acceleration - Deep neural networks built on a tape-based autodiff system
How to use
PyTorch is installed as a singularity container at PDC. The container includes PyTorch 2.0.1 with support for AMD GPUs using Rocm-5.7. In order to run the PyTorch container, first allocate a GPU node. Then, load the PDC and the singularity modules.
ml add PDC
ml add singularity/4.1.1-cpeGNU-23.12
ls $PDC_SHUB
Singularity>
singularity exec --rocm -B /cfs/klemming /pdc/software/resources/sing_hub/rocm5.7_ubuntu22.04_py3.10_pytorch_2.0.1 python3 <pytorch_script.py>
Installing additional Python packages
There are some restrictions regarding singularity on Dardel. Users cannot write into singularity containers, and therefore, users cannot install additional python packages directly into the container. So if you need additional python packages, you can add them via one of these two following methods: - Download the PyTorch singularity container to your local machine where you have a local installation of singularity. Then, update the image there installing the packages needed, and afterwards upload the image to Dardel again. - Install the additional python packages directly on Dardel, but outside the singularity container. For example, in your home directory (the default behaviour with pip), or in your project directory using the --target flag with the pip command. Remember that if you install additional python packages outside the default python directories, you need to update the PYTHONPATH variable with the path where those new packages are before you run the container.
When installing new packages it is advisable to add the condition numpy==1.21.2
to pip install
in order to prevent pip from upgrading the version of numpy in the container, which would cause compatibility problems. Example:
pip install matplotlib numpy==1.21.2