Reputation: 443
I have a code of python in lets say test.py. I need to run it using Slurm in a remote location. Thats why I am trying to make a .sh file.
In Putty, I am doing these:
touch main.sh
echo #!/bin/bash > main.sh
....
echo #SBATCH --gres=gpu:1 >> main.sh
....
echo python3 train.py >> main.sh
Then I make it executable with
chmod u+x main.sh
And I try to run it with
bash main.sh
But I am getting this error:
sbatch: error: This does not look like a batch script. The first
sbatch: error: line must start with #! followed by the path to an interpreter.
sbatch: error: For instance: #!/bin/sh
As I try to check
file main.sh
I am getting
main.sh: ASCII text
I am a novice in bash. So I cant understand what the issue is. Can someone help?
Upvotes: 0
Views: 323
Reputation: 163
The only difference is that I used single quotes
touch main.sh
echo '#!/bin/bash' > main.sh
echo '#SBATCH --gres=gpu:1' >> main.sh
echo 'python3 --version' >> main.sh
echo 'python3 /home/Desktop/train.py' >> main.sh
If train.py is in another directory, you will have to indicate the location
Upvotes: 2