前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >FAQ about PBS

FAQ about PBS

作者头像
一只羊
发布2020-11-05 23:01:24
1.4K0
发布2020-11-05 23:01:24
举报
文章被收录于专栏:生信了生信了

FAQ about PBS

1. What is PBS?

Portable Batch System (or simply PBS) is the name of computer software that performs job scheduling. Its primary task is to allocate computational tasks, i.e., batch jobs, among the available computing resources. It is often used in conjunction with UNIX cluster environments. (fromPBS Wiki page [1])

2. How to submit a task to PBS?

You could submit a task to PBS with qsub from command line, e.g.,

代码语言:javascript
复制
qsub -q <queue_name> -N <job_name> -l nodes=1:ppn=1,mem=1gb,walltime=01:00:00 \
     -o <path_to_out_log> -e <path_to_err_log> <script_to_run>

or through a qsub script (recommended). One simple qsub script is like ( modified from this script [2])

代码语言:javascript
复制
#!/bin/bash
# declare a name for this job
#PBS -N <job_name>
# request the queue for this job
#PBS -q <queue_name>
# request a total of x processors for this job (y nodes and z processors per node)
#PBS -l nodes=1:ppn=1
# request memory
#PBS -l mem=1gb
# specify walltime
#PBS -l walltime=01:00:00
# out log file
#PBS -o <path_to_out_log>
# err log file
#PBS -e <path_to_err_log>

# By default, PBS scripts execute in your home directory, not the 
# directory from which they were submitted. The following line 
# places you in the directory from which the job was submitted.  
cd $PBS_O_WORKDIR

# run the program
/path_to_executable/program_name arg1 arg2 ...
exit 0

3. Frequently used PBS commands

copied from this page [3]

代码语言:javascript
复制
#qsub              #submit a job, see man qsub
#qdel -p jobid     #will force purge the job if it is not killed by qdel 
#qstat             #list information about queues and jobs
#showq             #calculated guess which job will run next
#xpbs              #GUI to PBS commands
#qstat -q          #list all queues on system
#qstat -Q          #list queue limits for all queues
#qstat -a          #list all jobs on system
#qstat -s          #list all jobs with status comments
#qstat -r          #list all running jobs
#qstat -f jobid    #list full information known about jobid
#qstat -Qf queueid #list all information known about queueid
#qstat -B          #list summary information about the PBS server
#qstat -iu userid  #get info for queued jobs of userid
#qstat -u userid   #get info for all the jobs of userid
#qstat -n -1 jobid #will list nodes on which jobid is running in one line
#checkjob jobid    #will list job details

4. Use conda in PBS system

4.1 Activate conda environment inside a bash script

Sometimes we failed to run a bash script in PBS when required Apps were installed into a conda environment. One solution is to use absolute pathes to the Apps, which is not convenient, especially when the number of the Apps is big. So it would be nice if there was a way to activate conda environment inside a bash script.

Here's one solution (credit to this page [4])

EDIT: seems the issue [5] has been fixed in the new version of conda, so if you are using conda v4.9.0 or above (version below v4.9.0 not tested), no need to add eval "$(conda shell.bash hook)" in script.

代码语言:javascript
复制
source ~/.bashrc                   # this cmd will activate conda base env.
eval "$(conda shell.bash hook)"    # this will allow runing conda inside shell scripts.
/path/to/conda activate $conda_env

codes of required Apps here ...

/path/to/conda deactivate

4.2 One example: install R package to certain conda environment

Sometimes installing R packages could be a challenge on institutional HPC clusters for it may violate the CPU or memory limits. Submitting the installing task to PBS is a solution. e.g. to install package ggplot2 to conda env named R-4.0.2,

代码语言:javascript
复制
#!/bin/bash
#PBS -N install_r_pkg
#PBS -q <queue_name>
#PBS -l nodes=1:ppn=1
#PBS -l mem=10gb
#PBS -l walltime=01:00:00
#PBS -o install_r_pkg.out
#PBS -e install_r_pkg.err

source ~/.bashrc                   
eval "$(conda shell.bash hook)"    
conda activate R-4.0.2             # replace R-4.0.2 with your own conda env name

Rscript -e 'install.packages("ggplot2", repos = "http://cran.r-project.org")'

conda deactivate

save the codes above to a script named install_ggplot.sh and then run

代码语言:javascript
复制
chmod u+x install_ggplot.sh
qsub install_ggplot.sh

[1] https://en.wikipedia.org/wiki/Portable_Batch_System [2] https://www.dartmouth.edu/~rc/HPC/Sample_Qsub_script.html [3] http://physics.princeton.edu/it/faq/pbs-maui-cmds.html [4] https://github.com/conda/conda/issues/7980 [5] https://github.com/conda/conda/issues/7980

本文参与?腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2020-10-29,如有侵权请联系?cloudcommunity@tencent.com 删除

本文分享自 生信了 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与?腾讯云自媒体分享计划? ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • FAQ about PBS
    • 1. What is PBS?
      • 2. How to submit a task to PBS?
        • 3. Frequently used PBS commands
          • 4. Use conda in PBS system
            • 4.1 Activate conda environment inside a bash script
            • 4.2 One example: install R package to certain conda environment
        领券
        问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
        http://www.vxiaotou.com