We should test if `qsub`/`msub` allows having multiple `-l` option, if so I would recommend to reformat the following lines to split the "nodes" and "memory" request. It will remove some of those `if` statements and be cleaner.

For example:
```
qsub_file.write('#PBS -l nodes=1:ppn=1:gpus=1\n')
qsub_file.write('#PBS -l pmem=' +pmem+'\n')
```