Using and Installing Python Packages with CondaInitializing CondaUsers have access to conda to install packages locally in their account. For a cheat sheet on conda commands, see: https://docs.conda.io/projects/conda/en/latest/user-guide/cheatsheet.html Example for setting up a local conda environment: Code Block |
---|
| module load anaconda/2020
conda init bash # only needs to be run one time in your account
source ~/.bashrc # Makes the init changes live. Only needs to be run after the one-time initialization
conda create --name py37 python=3.7 # Build a local environment with a specific version of python
conda activate py37 # activate your environment. |
Once your environment is activated, you will be able to download and use custom packages with conda . It should be noted that the conda init bash step will modify your ~/.bashrc file so that Anaconda is automatically activated every time you log in. This behavior is known to cause some issues when using HPC resources such as OOD Desktop sessions (For information, see: FAQ -- resolving Anaconda issues). One way to more effectively control your environment is to turn off conda's auto-activation feature. This can be done by running the command: Code Block |
---|
| conda config --set auto_activate_base false |
Warning |
---|
Not running the above command after initial conda setup can lead to errors with Open On Demand. This step is necessary to prevent such errors. It only needs to be performed once. |
This will prevent Anaconda from being loaded into your environment until you manually activate it using: If you have turned off auto-activation, you can still use Anaconda in a batch script using: Code Block |
---|
| source ~/.bashrc && conda activate |
Installing Packages with CondaOnce conda has been configured following the steps above, users can often install software they need to run if it comes as a conda package.
Tip |
---|
It is almost always preferable to install new software in a separate environment so that conda can more easily manage dependencies. Installing multiple packages within a single environment can lead to issues! Only attempt to do this (1) in a new environment other than "base" and (2) if you absolutely need to have those packages installed in the same environment. |
If you wish to install and run a new conda package, please follow these steps: 1. Access an interactive session. This can be done quickly by running Code Block |
---|
| elgato
interactive -a <your_group> |
You will still be able to run any software installed this way on either Puma or Ocelote. Switching to El Gato is preferable for quickly accessing a compute node. 2. Create an environment for your new software. Give the environment a title related to the software you are installing so that you can keep track. This is especially helpful if you plan on having more than one additional conda environment. Code Block |
---|
| conda create -n <my_new_env>
conda activate <my_new_env> |
You can then check your available environments with 3. Follow the software-specific installation instructions. This may be as simple as running "conda install <my_package>", or it may involve installing a handful of dependencies. If the installation instructions ask you to create a new environment, you do not have to repeat this step. You should then be able to access your software within this environment! If you are unable to load your software, check your active environment with and the installed packages with 4. (optional) Sometimes, installing the package from conda isn't sufficient. After you have the source code installed, you may want to clone the git repo with examples and useful scripts. Naturally, this is very much dependent on the software you are using and the resources the developers provide.
|