Skip to content

Update outputs of conda commands to match whatever platform we decide to use #36

Open

Description

@SJaffa

My quick test of the new JupyterHub instance found that conda does work (the command exists, I can list and create environments, install packages) but things like the default channels are different.

Activity

  1. SJaffa commented on Jan 24, 2025

    @SJaffa
    ContributorAuthor

    After creating the environment when I try to activate I get the error CondaError: Run 'conda init' before 'conda activate'. I ran conda init bash and retry activating, it still gives the error. I close nad repoen terminal and try activating, it still gives the error.

    However source ~/.bashrc does work to activate the conda base env and allow me to then activate my env.

  2. SJaffa commented on Jan 24, 2025

    @SJaffa
    ContributorAuthor

    Also a couple of times when trying to install packages (conda install astropy pint) the terminal crashes or hangs.

    When it crashed and I open a new terminal my environment no longer exists (conda env list only shows base)

  3. ianhinder commented on Jan 24, 2025

    @ianhinder

    conda init adds stuff to your shell startup files, and can't modify your current environment, so I think you would always have to log out and back in again to see the changes, as you did. It's odd that it doesn't find them when you logged back in. Can you check you actually are in bash, not something else like zsh? If it crashes and you open a new terminal, do you still see the environments in ~/.conda/envs? It's possible that your jupyter session is running in a container which crashes, and when you get a new one, you don't have the content of your home directory anymore, as you get a fresh container. Is anything else still there, after such a crash? The home directory would need to be persisted in a volume, rather than just existing in the ephemeral container itself.

  4. ianhinder commented on Jan 24, 2025

    @ianhinder

    Turns out I can log into that system, so I poked around. Is it open to everyone?

    You do get a container for your session, and it has no .bashrc file or other shell startup files at all.

    This link explains the reason that .bashrc might not be run in Terminal on a mac, and I suspect it is the same thing happening here.

    The Jupyter Terminal is probably giving you a "login shell", and when bash is a "login shell", it doesn't run .bashrc, it runs .profile or .bash_profile. Usually, these would then source .bashrc. But since there is no .profile or .bash_profile, .bashrc is not being run.

    Creating .bash_profile with "source .bashrc" in it does the trick for me, and when I open a new Terminal, it runs .bashrc.

  5. ianhinder commented on Jan 24, 2025

    @ianhinder

    Also a couple of times when trying to install packages (conda install astropy pint) the terminal crashes or hangs.

    This might be due to the system being overloaded, or perhaps memory limits being placed on the containers, and these being too low for conda. You could run "watch free" in one Terminal while you try to install packages in another, to see if the memory is going up too much.

    When it crashed and I open a new terminal my environment no longer exists (conda env list only shows base)

    When you have an environment, where does it end up being created? I previously said .conda/envs, but when I create an environment, it goes in /opt:

    jovyan@jupyter-ian-hinder---ee0c9d7a:~$ conda env list
    
    # conda environments:
    #
    base                 * /opt/conda
    ian                    /opt/conda/envs/ian
    

    As an aside, to avoid the "conda init" fiasco of modifying your startup files and tying you to always use a specific conda installation for everything on your system, I prefer to activate environments with "source activate ". This is deprecated, as they want you to use the "conda" function and the shell startup thing, but I prefer it, and I doubt it is going away soon.

  6. ianhinder commented on Jan 24, 2025

    @ianhinder

    If I stop my jupyter server with File -> Hub control panel -> Stop server, and then restart it, I also lose my conda env in /opt/conda/envs, and I'm left with just the base environment, consistent with what you saw. So probably your server container crashed and had to be restarted, and /opt/conda is not being persisted.

    Looking at the output of the "mount" command, we have

    jovyan@jupyter-ian-hinder---ee0c9d7a:~$ mount|grep home
    127.0.0.1:/ on /home/jovyan type nfs4 (rw,relatime,vers=4.1,rsize=1048576,wsize=1048576,namlen=255,hard,noresvport,proto=tcp,port=20651,timeo=600,retrans=2,sec=sys,clientaddr=127.0.0.1,local_lock=none,addr=127.0.0.1)
    

    showing that /home/jovyan (your home directory) is an NFS mount from the host, and is likely persistent. However, there is nothing for /opt, so this will be obtained from the container image when it is started. You probably want to ask them to either configure conda to use your home directory, or to make /opt/conda persistent somehow. The former is probably more straightforward.

  7. ianhinder commented on Jan 24, 2025

    @ianhinder

    Here is a link that explains about how this can be done (on their end).

    You could make conda store its envs in your home dir by creating .condarc in your home dir and adding

    envs_dirs:
      - ~/.conda/envs
    

    But we need to get this effect for all the course participants, if we want their environments to persist across possible server crashes.

  8. SJaffa commented on Jan 27, 2025

    @SJaffa
    ContributorAuthor

    Thanks for all the help @ianhinder, I'll get back to the admins and see if they can fix this for us.

  9. douglowe commented on Jan 27, 2025

    @douglowe
    Member

    This does look to be a very promising solution.

    Rather than create an extra config file we could ask the participants to move the .bashrc file:

    mv .bashrc .profile
    

    Getting the participants to add to their environment directory list can be done using conda config:

    conda config --add envs_dirs /home/jovyan/.conda/envs
    

    (and then conda config --show envs_dirs).

    I think this is a nice example of how to adapt your conda configuration - and shouldn't be too much extra mental load for the learners.

  10. ianhinder commented on Jan 27, 2025

    @ianhinder

    For the admins, a better solution than storing the envs path in .condarc is to set the environment variable

    CONDA_ENVS_PATH=/home/jovyan/.conda/envs
    

    in the container when it starts. In the absence of their help, we can ask the participants to set the path directly, as you say, which sounds like a good idea.

    Regarding .bashrc, are you meaning to get them to mv .bashrc .profile after conda init has written to it? I guess that would work. I can see them getting confused and doing things in the wrong order, though.

    It would be better to get the admins to provide a more standard shell environment, so we don't have to make the participants do this sort of thing.

    I know Doug sees these things as learning opportunities, but I'm hesitant. They are learning opportunities for the experts; they are just confusion and friction for the beginners who are struggling to follow as it is.

  11. douglowe commented on Jan 27, 2025

    @douglowe
    Member

    I can consistently crash the IT-Services VM when trying to install astropy in the base environment. Attached is the system info as I'm trying to do this. Even though only one core and ~1/3 of the RAM is being used, it seems that the VM doesn't like having 1 CPU working heavily.

    Image

  12. ianhinder commented on Jan 28, 2025

    @ianhinder

    The conda process itself is using between 1 and 2 GB, and the other processes are using some as well. If I look at

    jovyan@jupyter-ian-hinder---ee0c9d7a:~$ cat /sys/fs/cgroup/memory.max 
    2147483648
    

    then I see a 2 GB limit. (Found this here -- I assume they are using Kubernetes on AWS, though EKS or similar) Apparently the memory limitation stuff in containers is quite complicated, and there are lots of different places to look, but this suggests that the admins have imposed a 2 GB limit on each server container. @nigeldgreen, if you are in contact with the admins of this system, please can you ask them to increase the limit to 4 GB? I don't know if they should do this just for course participants, or globally. The former would need them to maintain a list of participants, whereas at the moment it seems to be open to everyone? At least, it was open to me without requesting anything. Maybe because I am in ITS?

  13. douglowe commented on Jan 28, 2025

    @douglowe
    Member

    That's a strange limit to have, given the VM seems to have 4 cores and 16Gb RAM.

  14. ianhinder commented on Jan 28, 2025

    @ianhinder

    But how many users?

  15. ianhinder commented on Jan 28, 2025

    @ianhinder

    I don't think this is mainly for us, right?

  16. douglowe commented on Jan 31, 2025

    @douglowe
    Member

    I have requested that the 2Gb limit is increased to 4Gb. This doesn't look to have been actioned yet, so I still can't install astropy into the existing base environment.

  17. douglowe commented on Jan 31, 2025

    @douglowe
    Member

    @ianhinder - how do I open a new conda environment within a jupyter notebook? Do I need to have jupyter installed within that environment, or can we open a separate, specialised environment within a notebook?

  18. ianhinder commented on Jan 31, 2025

    @ianhinder

    That was the reason for my question about whether we actually tell users how to make use of the conda environments they are creating!

    https://medium.com/@nrk25693/how-to-add-your-conda-environment-to-your-jupyter-notebook-in-just-4-steps-abeab8b8d084

    Essentially, in your environment, install ipykernel, then run a command which registers the kernel with Jupyter. In the Launcher, you should then see an additional Python box for the new environment.

    I would have been able to tell you that I had tested it on the ITS server, but conda is still spinning and I'm getting bored....

  19. douglowe commented on Feb 4, 2025

    @douglowe
    Member

    The maximum memory limit has not been increased for the central jupyterlab instance. I will ask again, but I suspect that it will not be done in time for this training course.

  20. ianhinder commented on Feb 4, 2025

    @ianhinder

    Can this be escalated?

  21. douglowe commented on Feb 5, 2025

    @douglowe
    Member

    Possibly. But given how close we are to running the course I think it'll be better for us to use our known solution this time (our VM solution). We can continue testing the jupyterlab server with the idea of using it in May.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions