User Tools

Site Tools


howto:python:start

Python

There are a number of python versions installed on Lengau compiled with either gcc or the intel compiler, including python 2.7.11 to 2.7.15, python 3.5-3.7 and anaconda installs for python 2 and 3. Use this command to get a full list:

  module avail chpc/python

All python modules should have mpi4py, numpy and scipy installed; however if matplotlib is required, please use anaconda (which also has the biggest range of 3rd-party python modules). The module chpc/python/3.5.2_gcc-6.2.0 also has a working matplotlib installation.

To use tensorflow, the anaconda module for python3 is also recommended.

User Package installation with Anaconda

Modules for anaconda version 2 and 3 are installed on lengau.To load these modules, use the following command (either from the command-line in an interactive session, or in a script:

  module add chpc/python/anaconda/2

or:

  module add chpc/python/anaconda/3-2019.10

Using virtualenv with anaconda is not recommended. However, Anaconda does include a similar functionality, which allows users to create an anaconda virtual environment.

The following instructions to set up your virtual environment. YOU NEED ONLY DO THEM ONCE. Please replace USERNAME with your actual username wherever it occurs below.

1. log into lengau.chpc.ac.za

2. ssh chpclic1 Unlike the compute nodes, chpcviz1 and chpclic1 have a connection to the internet, which is needed here

3. module load chpc/python/anaconda/3-2019.10

you can substitute chpc/anaconda/2 if you want python 2

4. conda init bash

5. conda create –prefix /home/USERNAME/myenv python=3.6 anaconda

change python=3.6 to python=2.7 if you're using anaconda/2

6. conda activate /home/USERNAME/myenv

You don't have to use “myenv”, just replace it consistently with whatever name you prefer for your virtual environment. “myenv” will work, though.

7. You can now install whatever packages you need, that are not installed already for instance, for rpy2, type:

 conda install rpy2

8. you can now type:

conda deactivate /home/USERNAME/myenv

to exit the virtual environment.

Now, once you've done this, you can log out, and ready your job for submission from the login node. You must do the following in your job-submit script: Put it all near the top of your script, but after the #PBS directives:

module add chpc/python/anaconda/3-2019.10
conda activate /home/USERNAME/myenv

and at the end:

conda deactivate /home/USERNAME/myenv

Then submit your script as normal with qsub.

if you ever need to install new python packages, just repeat steps 1, 2, 3, 6, 7 and 8 from above. (omit 4 and 5).

/var/www/wiki/data/pages/howto/python/start.txt · Last modified: 2020/06/22 17:08 by agill