If you do not want to change your home directory permissions you will need to use the shared directory in home for environments.

Please refer to these instructions for how to do this: Creating shareable environments with conda outside of /home/.

There is a shared environment folder on the HPC at /home/SE/ that you can put your environments in.

You still should do steps 1, 3, 4, and 5 even if you're creating a shared environment outside of your /home/

  1. Run the following command to switch your conda from a personal install to the global install of conda maintained by the HPC staff:
/opt/conda/bin/conda init bash

Note: this will change how conda functions if you have a local installation. Any environment created before this change will need to be activated using the full path (i.e. conda activate /home/<username>/*conda/envs/my_env). Any environment created after this change by default will be located under /home/<username>/.conda/envs. Named environments will only work for environments located in the ~/.conda/envs folder. 

      2. Create the environment for your course (we recommend you to use the following naming convention – BMIG_course#_initials):

conda create -n BMIG_XXXX_YY

Note: For your students to use your environment you must install the appropriate kernel for the languages used in the environment. The following commands should be run while the target environment is active.

To install the python kernel run: conda install -c anaconda ipykernel

To install the R kernel run: conda install -c r r-irkernel

      3. Have your students check where they are running conda from by using the following command:

which conda

If the return is something other than /opt/conda/bin/conda the student will need to run /opt/conda/bin/conda init bash

    4. If your students have not created an environment using the /opt/conda they need to create an empty environment to auto generate the ~/.conda directory

conda create -n test_env

      5. Have your students run the following command where you substitute the full filepath to your env folder:

echo “/home/SE/BMIG_XXX_YY” >> /home/${USER}/.conda/environments.txt

It is critical that you have your permissions set so students can read but not write to your ~/.conda/envs folder.

Without this permission, students will not be able to use your environment in their Jupyter Notebooks on the HPC.

You can do this with the command: chmod a+r with the location of your env folder after the '+r '.

If you want to have all shared environments visible and able to be activated by name alone, simply run the following command

conda config --append envs_dirs /home/SE

To enable your students to leverage the environment switching inside Jupyter Notebook you will need to install the appropriate kernels for the languages you have inside the environment in order for them to be able to switch kernels.

You can do this with the following commands within the environment you want to share:

To install the python kernel run: conda install -c anaconda ipykernel

To install the R kernel run: conda install -c r r-irkernel

  • No labels