【问题标题】:How do I have condor automatically import my conda environment when running my python jobs?运行 python 作业时,如何让 condor 自动导入我的 conda 环境?
【发布时间】:2021-02-05 13:45:26
【问题描述】:

我正在向 condor 提交我的工作,但它说没有安装 tensorboard,这是错误的,因为我在一个交互式工作中运行,所以它安装。

如何让 conda 使用我当前的活动 conda 环境?

我的神鹰提交脚本:

####################
#
# Experiments script
# Simple HTCondor submit description file
#
# reference: https://gitlab.engr.illinois.edu/Vision/vision-gpu-servers/-/wikis/HTCondor-user-guide#submit-jobs
#
# chmod a+x test_condor.py
# chmod a+x experiments_meta_model_optimization.py
# chmod a+x meta_learning_experiments_submission.py
# chmod a+x download_miniImagenet.py
#
# condor_submit -i
# condor_submit job.sub
#
####################

# Executable   = meta_learning_experiments_submission.py
# Executable = automl-proj/experiments/meta_learning/meta_learning_experiments_submission.py
# Executable = ~/automl-meta-learning/automl-proj/experiments/meta_learning/meta_learning_experiments_submission.py
Executable = /home/miranda9/automl-meta-learning/automl-proj/experiments/meta_learning/meta_learning_experiments_submission.py

## Output Files
Log          = condor_job.$(CLUSTER).log.out
Output       = condor_job.$(CLUSTER).stdout.out
Error        = condor_job.$(CLUSTER).err.out

# Use this to make sure 1 gpu is available. The key words are case insensitive.
REquest_gpus = 1
# requirements = ((CUDADeviceName = "Tesla K40m")) && (TARGET.Arch == "X86_64") && (TARGET.OpSys == "LINUX") && (TARGET.Disk >= RequestDisk) && (TARGET.Memory >= RequestMemory) && (TARGET.Cpus >= RequestCpus) && (TARGET.gpus >= Requestgpus) && ((TARGET.FileSystemDomain == MY.FileSystemDomain) || (TARGET.HasFileTransfer))
# requirements = (CUDADeviceName == "Tesla K40m")
# requirements = (CUDADeviceName == "Quadro RTX 6000")
requirements = (CUDADeviceName != "Tesla K40m")

# Note: to use multiple CPUs instead of the default (one CPU), use request_cpus as well
Request_cpus = 8

# E-mail option
Notify_user = me@gmail.com
Notification = always

Environment = MY_CONDOR_JOB_ID= $(CLUSTER)

# "Queue" means add the setup until this line to the queue (needs to be at the end of script).
Queue

我的提交脚本的前几行直到失败行:

#!/home/miranda9/.conda/bin/python3.7

import torch
import torch.nn as nn
import torch.optim as optim
# import torch.functional as F
from torch.utils.tensorboard import SummaryWriter

相关cmets:

我确实看到了这个问题how to run a python program on Condor? 和这个http://chtc.cs.wisc.edu/python-jobs.shtml,但我不敢相信我们必须这样做。集群中的其他所有人都不会做任何复杂的事情,而我之前已经运行了我的脚本,而不必做任何复杂的事情,我非常怀疑是否需要这样做。 p>

【问题讨论】:

    标签: distributed-computing hpc condor


    【解决方案1】:

    我真的不明白 condor 是如何工作的,但似乎一旦我将正确的 python 路径放在当前环境的顶部,它就开始工作了。所以检查你的python命令在哪里:

    (automl-meta-learning) miranda9~/automl-meta-learning $ which python
    ~/miniconda3/envs/automl-meta-learning/bin/python
    

    然后将其复制粘贴到 python 提交脚本的顶部:

    #!/home/miranda9/miniconda3/envs/automl-meta-learning/bin/python
    

    我希望我可以将所有这些都包含在 job.sub 中。如果你知道怎么做,请告诉我。


    参考解决方案:https://stackoverflow.com/a/64484025/1601580


    回声的克里斯蒂娜的解决方案

    输入你的工作脚本:

    getenv = True
    
    

    我当前的提交脚本:

    ####################
    #
    # Experiments script
    # Simple HTCondor submit description file
    #
    # reference: https://gitlab.engr.illinois.edu/Vision/vision-gpu-servers/-/wikis/HTCondor-user-guide#submit-jobs
    #
    # chmod a+x test_condor.py
    # chmod a+x experiments_meta_model_optimization.py
    # chmod a+x meta_learning_experiments_submission.py
    # chmod a+x download_miniImagenet.py
    # chmod a+x ~/meta-learning-lstm-pytorch/main.py
    # chmod a+x /home/miranda9/automl-meta-learning/automl-proj/meta_learning/datasets/rand_fc_nn_vec_mu_ls_gen.py
    # chmod a+x /home/miranda9/automl-meta-learning/automl-proj/experiments/meta_learning/supervised_experiments_submission.py
    # chmod a+x /home/miranda9/automl-meta-learning/results_plots/is_rapid_learning_real.py
    # chmod a+x /home/miranda9/automl-meta-learning/test_condor.py
    # chmod a+x /home/miranda9/ML4Coq/main.sh
    # chmod a+x /home/miranda9/ML4Coq/ml4coq-proj/PosEval/download_data.py
    # chmod a+x /home/miranda9/ML4Coq/ml4coq-proj/pos_eval/create_pos_eval_dataset.sh
    # chmod a+x /home/miranda9/ML4Coq/ml4coq-proj/embeddings_zoo/tree_nns/main_brando.py
    # chmod a+x /home/miranda9/ML4Coq/main.sh
    # condor_submit -i
    # condor_submit job.sub
    #
    ####################
    
    # Executable = /home/miranda9/automl-meta-learning/automl-proj/experiments/meta_learning/supervised_experiments_submission.py
    
    # Executable = /home/miranda9/automl-meta-learning/automl-proj/experiments/meta_learning/meta_learning_experiments_submission.py
    # SUBMIT_FILE = meta_learning_experiments_submission.py
    
    # Executable = /home/miranda9/meta-learning-lstm-pytorch/main.py
    # Executable = /home/miranda9/automl-meta-learning/automl-proj/meta_learning/datasets/rand_fc_nn_vec_mu_ls_gen.py
    
    # Executable = /home/miranda9/automl-meta-learning/results_plots/is_rapid_learning_real.py
    # SUBMIT_FILE = is_rapid_learning_real.py
    
    # Executable = /home/miranda9/automl-meta-learning/test_condor.py
    
    # Executable = /home/miranda9/ML4Coq/ml4coq-proj/embeddings_zoo/tree_nns/main_brando.py
    # SUBMIT_FILE = main_brando.py
    
    # Executable = /home/miranda9/ML4Coq/ml4coq-proj/PosEval/download_data.py
    # SUBMIT_FILE = ml4coq-proj/PosEval/download_data.py
    
    # Executable = /home/miranda9/ML4Coq/ml4coq-proj/pos_eval/create_pos_eval_dataset.sh
    # SUBMIT_FILE = create_pos_eval_dataset.sh
    
    Executable = /home/miranda9/ML4Coq/main.sh
    SUBMIT_FILE = main.sh
    
    # Output Files
    Log          = $(SUBMIT_FILE).log$(CLUSTER)
    Output       = $(SUBMIT_FILE).o$(CLUSTER)
    Error        = $(SUBMIT_FILE).o$(CLUSTER)
    
    getenv = True
    # cuda_version = 10.2
    # cuda_version = 11.0
    
    # Use this to make sure 1 gpu is available. The key words are case insensitive.
    # REquest_gpus = 1
    REquest_gpus = 2
    requirements = (CUDADeviceName != "Tesla K40m")
    requirements = (CUDADeviceName != "GeForce GTX TITAN X")
    # requirements = (CUDADeviceName == "Quadro RTX 6000")
    # requirements = ((CUDADeviceName != "Tesla K40m")) && (TARGET.Arch == "X86_64") && (TARGET.OpSys == "LINUX") && (TARGET.Disk >= RequestDisk) && (TARGET.Memory >= RequestMemory) && (TARGET.Cpus >= RequestCpus) && (TARGET.gpus >= Requestgpus) && ((TARGET.FileSystemDomain == MY.FileSystemDomain) || (TARGET.HasFileTransfer))
    # requirements = (CUDADeviceName == "Tesla K40m")
    # requirements = (CUDADeviceName == "GeForce GTX TITAN X")
    
    # Note: to use multiple CPUs instead of the default (one CPU), use request_cpus as well
    # Request_cpus = 1
    Request_cpus = 4
    # Request_cpus = 5
    # Request_cpus = 8
    # Request_cpus = 16
    # Request_cpus = 32
    
    # E-mail option
    Notify_user = brando.science@gmail.com
    Notification = always
    
    Environment = MY_CONDOR_JOB_ID= $(CLUSTER)
    
    # "Queue" means add the setup until this line to the queue (needs to be at the end of script).
    Queue
    

    【讨论】:

      【解决方案2】:

      HTCondor 在交互式和批处理作业中使用不同的默认环境。交互式作业复制与您的登录会话相同的 shell 环境(包括激活的 conda 环境)。批处理作业从一个非常精简的环境开始(要查看实际情况,请尝试使用/usr/bin/env 作为可执行文件运行测试作业);激活的 conda 环境不会被带入批处理作业环境。

      HTCondor 手册中描述了此行为和潜在的提交文件解决方案:https://htcondor.readthedocs.io/en/latest/users-manual/services-for-jobs.html?highlight=environment#environment-variables

      【讨论】:

      • 我已经尝试过了,但我仍然认为它找不到其他命令,例如它没有找到module add <software> 这是一个非常大的问题......我错过了什么吗?模块添加不应该工作吗?
      • 可能需要设置 MODULEPATHMODULEHOME 环境变量才能使模块命令正常工作。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-22
      • 1970-01-01
      • 2020-07-23
      • 1970-01-01
      • 2015-06-23
      • 1970-01-01
      相关资源
      最近更新 更多