- Create a script
install-python.sh
with the following content:
#!/bin/bash
sudo apt update
sudo apt upgrade -y
sudo apt install software-properties-common -y
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install -y python3.10
# set as default version
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1
- Next run this locally on the Head Node to change the default version:
$ bash install-python.sh
$ python3 --version
Python 3.10.13
- Run with
srun
to customize all the compute nodes, note that -N 8
should be the number of instances in your cluster. This takes about 20 minutes. Each node is done in parallel.
srun -N 8 bash install-python.sh
- Finally verify the version was correctly set:
srun -N 8 python3 --version
- This should print out
python3.10
for all compute nodes:
Python 3.10.13
Python 3.10.13
Python 3.10.13
Python 3.10.13
Python 3.10.13
Python 3.10.13
Python 3.10.13
Python 3.10.13