Intel® DevCloud
Help for those needing help starting or connecting to the Intel® DevCloud
Announcements
The Intel sign-in experience is changing in February to support enhanced security controls. If you sign in, click here for more information.
1216 Discussions

Not able to change conda environment inside a job script

musical-one
Beginner
124 Views

I am using OneAPI. I am trying to change the conda environment to the one I created. But I am getting the following error.

 

Job submission

qsub -l nodes=1:ppn=2 test.sh

 

test.sh

echo "$(conda activate neuralmmo)"
python --version

 

test.sh.e2056343

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'.

I even tried doing conda init bash but did not work.

But when I try to activate it in interactive mode it works.

(intelpython-python3.9) u178728@s001-n007:~/nmmo$ qsub -I -l nodes=1:ppn=2
qsub: waiting for job 2056348.v-qsvr-1.aidevcloud to start
qsub: job 2056348.v-qsvr-1.aidevcloud ready


########################################################################
# Date: Fri 25 Nov 2022 10:42:04 AM PST
# Job ID: 2056348.v-qsvr-1.aidevcloud
# User: u178728
# Resources: cput=35:00:00,neednodes=1:ppn=2,nodes=1:ppn=2,walltime=06:00:00
########################################################################

u178728@s001-n061:~$ conda activate neuralmmo
(neuralmmo) u178728@s001-n061:~$

 

Please help. Or how to quite the interactive environment without stopping the job because the job ends when doing logout. Either one can help! 

0 Kudos
1 Solution
JyothisV_Intel
Moderator
97 Views

Hi,

 

Good day to you.

 

Thanks for posting in Intel Communities.

 

The command "conda activate <env_name>" is intended to be used for interactive shell sessions. This is a limitation of conda. It cannot be used in scripts.

 

If you wish to activate your conda environment in script, you need to hook conda to your shell as given below in the job script:

eval "$(conda shell.bash hook)"
conda activate myenv
python --version

 

 

 

(See attached screenshot for reference)

 

If this clears your query, kindly click the “Accept as Solution” button to indicate that your issue is resolved. This will also help others with a similar issue.

 

Thanks and Regards,

Jyothis V James

 

View solution in original post

2 Replies
JyothisV_Intel
Moderator
98 Views

Hi,

 

Good day to you.

 

Thanks for posting in Intel Communities.

 

The command "conda activate <env_name>" is intended to be used for interactive shell sessions. This is a limitation of conda. It cannot be used in scripts.

 

If you wish to activate your conda environment in script, you need to hook conda to your shell as given below in the job script:

eval "$(conda shell.bash hook)"
conda activate myenv
python --version

 

 

 

(See attached screenshot for reference)

 

If this clears your query, kindly click the “Accept as Solution” button to indicate that your issue is resolved. This will also help others with a similar issue.

 

Thanks and Regards,

Jyothis V James

 

JyothisV_Intel
Moderator
89 Views

Hi,


Glad to know that your issue is resolved. We will no longer monitor this thread. If you require additional assistance from Intel, please start a new thread. Any further interaction in this thread will be considered community only.


Regards,

Jyothis V James


Reply