-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to activate conda environment that was created using a .yml file? #506
Comments
Note: It is currently possible to post-hoc activate the custom environment by executing csp@5b5b1344459e:/$ conda activate csp
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run
$ conda init <SHELL_NAME>
Currently supported shells are:
- bash
- fish
- tcsh
- xonsh
- zsh
- powershell
See 'conda init --help' for more information and options.
IMPORTANT: You may need to close and restart your shell after running 'conda init'. |
2nd note: Even after adding
to the latest script it still does not work. Which makes me think that it must have something to do with the different neurodocker versions ( generate_docker() {
docker run -i --rm repronim/neurodocker:0.9.4 generate docker \
--base-image neurodebian:stretch-non-free \
--arg DEBIAN_FRONTEND='noninteractive' \
--pkg-manager apt \
--install opts="--quiet" \
gcc \
g++ \
octave \
--spm12 \
version=r7771 \
--freesurfer \
version=7.1.1 \
--copy $conda_yml_file /tmp/ \
--miniconda \
version=latest \
yaml_file=/tmp/$conda_yml_file \
env_name="csp" \
--env LD_LIBRARY_PATH="/opt/miniconda-latest/envs/csp:$LD_LIBRARY_PATH" \
--run-bash "source activate csp" \
--user csp \
--run 'mkdir /home/csp/data && chmod 777 /home/csp/data && chmod a+s /home/csp/data' \
--run 'mkdir /home/csp/output && chmod 777 /home/csp/output && chmod a+s /home/csp/output' \
--run 'mkdir /home/csp/code && chmod 777 /home/csp/code && chmod a+s /home/csp/code' \
--run 'mkdir /home/csp/.jupyter && echo c.NotebookApp.ip = \"0.0.0.0\" > home/csp/.jupyter/jupyter_notebook_config.py'
} |
3rd note: After checking the differences in Dockerfile when executing the old script with - && sync \
- && sed -i '$isource activate csp' $ND_ENTRYPOINT Why is |
@kaczmarj : I found a workaround for now by using Example (make sure that generate_docker() {
docker run -i --rm repronim/neurodocker:0.9.4 generate docker \
--base-image neurodebian:stretch-non-free \
--yes \
--pkg-manager apt \
--install opts="--quiet" \
gcc \
g++ \
octave \
--spm12 \
version=r7771 \
--freesurfer \
version=7.1.1 \
--copy $conda_yml_file /tmp/ \
--miniconda \
version=latest \
yaml_file=/tmp/$conda_yml_file \
env_name=csp \
--user csp \
--run 'mkdir /home/csp/data && chmod 777 /home/csp/data && chmod a+s /home/csp/data' \
--run 'mkdir /home/csp/output && chmod 777 /home/csp/output && chmod a+s /home/csp/output' \
--run 'mkdir /home/csp/code && chmod 777 /home/csp/code && chmod a+s /home/csp/code' \
--run 'mkdir /home/csp/.jupyter && echo c.NotebookApp.ip = \"0.0.0.0\" > home/csp/.jupyter/jupyter_notebook_config.py' \
--workdir /home/csp/code \
--run 'echo source activate csp >> /home/csp/.bashrc'
}
I will close #16 in our repository for now (though you might find useful links there). I currently just follow this stackoverflow post by user merv who in general seems to know a lot of stuff about conda/Docker (helped me already a couple of times in the past on SO). General takeaways:
A possible solution for this issue: Reintroduce |
we could bring it back but there are some sharp edges. we would have to test that we are activating the environment correctly. the |
I guess the only way to achieve this to either hardcode it to some configuration file like I already tried the first approach which I find more elegant but somehow this doesn't work:
Using an ENTRYPOINT would also mean that you cannot use it for something else then. Afaik there can only be one ENTRYPOINT for each Dockerfile. |
Note: One advantage of using an entrypoint would be that the conda environment could then also be used when you use |
This can be solved by adding #!/bin/bash
#. . . Do whatever you want here . . .
# we want the container to keep running after running the code above so we run this
/usr/bin/env bash |
This is happening because |
This issue is stale because it has been open for 30 days with no activity. |
This issue was closed because it has been inactive for 14 days since being marked as stale. |
This issue is stale because it has been open for 30 days with no activity. |
We would like to create a new conda environment using a
.yml
file. With our current script we end up with a container, where neither the base nor our custom "yml"-environment seem to be activated. E.g.:In old neurodocker versions, there was the
activate=True
option. I always thought this option did exactly that (activating a custom environment). On top of that, I could come up with a script (very close to an old version of generate_docker.sh from the nipype_tutorial) that uses 1.)activate=True
and 2.)--env LD_LIBRARY_PATH="/opt/miniconda-latest/envs/csp:$LD_LIBRARY_PATH"
and 3.)--run-bash "source activate csp"
. Here the activation seem to have worked (I am just not sure which of the three options / or their combination is responsible for that):Pasting both the old/new bash-scripts/Dockerfiles here:
Latest script:
Note that a
.yml
file has to be present in the directory that the script is in. You can execute this script by runningbash generate_dockerfile.sh test_env.yml
. For example usetest_env.yml
as provided in our repoLatest Dockerfile:
Old script uses
kaczmarj/neurodocker:0.7.0
:Old Dockerfile:
The text was updated successfully, but these errors were encountered: