本地通过apt安装Slurm后无法找到sbatch.c文件的技术问询
Hey there! Let's break down why you can't locate the sbatch.c file after installing Slurm via sudo apt-get install -y slurm-wlm slurm-wlm-doc, and how to fix it:
为什么找不到sbatch.c?
The slurm-wlm and slurm-wlm-doc packages you installed are precompiled binary packages—they only include ready-to-run executables (like the sbatch command), configuration files, and documentation. Source code files like sbatch.c aren't included in these packages by default.
获取sbatch.c的两种方法
方法1:通过APT获取对应版本的源码包
APT has a built-in way to download the source code for packages you've installed. Here's how:
- First, install tools needed to handle source packages:
sudo apt-get install -y dpkg-dev - Next, ensure your system can access source repositories. Open
/etc/apt/sources.listwith a text editor (like nano) and check for lines starting withdeb-src(matching your Ubuntu version's main repository). If missing, add a line like this (replacejammywith your Ubuntu codename, e.g.,focalfor 20.04):deb-src http://archive.ubuntu.com/ubuntu/ jammy main universe - Update your package lists:
sudo apt update - Download the Slurm source code:
This will create a directory in your current folder with the Slurm source code. You'll findapt source slurm-wlmsbatch.cinsideslurm-<version>/src/sbatch/.
方法2:从Slurm的Git仓库克隆源码
If you want the latest (or a specific) version of the source code, clone the official repository:
- Clone the repo:
git clone https://github.com/SchedMD/slurm.git - Switch to the branch/tag matching your installed Slurm version (check with
sbatch --version):cd slurm git checkout <version-tag> # e.g., git checkout slurm-23.02.6 - Navigate to the sbatch source directory:
You'll findcd src/sbatch/sbatch.chere.
额外提示:如果只是测试sbatch命令
If you don't actually need the source code and just want to test using the sbatch command, you don't need sbatch.c at all. Create a simple test script (e.g., test_job.sh):
#!/bin/bash #SBATCH --job-name=test_job #SBATCH --output=test_output.txt echo "Hello from Slurm!" date
Then submit it with:
sbatch test_job.sh
You'll get a job ID, and the output will be in test_output.txt once the job runs.
内容的提问来源于stack exchange,提问作者addrienne lagua

