英文:
check if conda environment has changed
问题
我正在更改我的conda环境在一个slurm脚本中,所以我想确保环境已经改成了我想要的。我该如何做到这一点?
我看到了用于“设置”环境变量的代码,但我没有找到用于“获取”环境变量的任何内容。(如果这甚至是我所需要的话)。
英文:
I am changing my conda environment in a slurm script, so I want to make sure the environment has changed to what I intended. How can I do that?
I see codes for "setting" the environment variable, but I didn't find anything for "getting" the environment variable. (if this is even what I need).
答案1
得分: 1
The conda info --envs
命令将显示当前可访问的每个conda环境以及其位置。这个命令可以在您的slurm脚本中使用,以查看所需的环境是否存在。
为了验证conda环境是否已激活,您还可以在激活之前和之后使用which python
命令。
在您的slurm脚本中,确保在激活环境之前包括eval "$(conda shell.bash hook)"
。这是因为在执行slurm作业时未提供您的~/.bashrc
,这会阻止它初始化Conda环境的shell。
英文:
The conda info --envs
command will show every conda environment that is currently accessible along with its location. This command can be used in your slurm script to see if the desired environment is present.
In order to verify whether the conda environment has been active or not, you can also use the which python
command before and after doing so.
In your slurm script, make sure to include eval "$(conda shell.bash hook)"
before activating the environment. This is due to the fact that your ~/.bashrc
is not supplied when slurm jobs are being done, which prevents it from initialising the shell for Conda environments.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论