Skip to content

Instantly share code, notes, and snippets.

@cenit
Last active June 27, 2018 08:15
Show Gist options
  • Save cenit/71c3cd987ccd91d56b0c to your computer and use it in GitHub Desktop.
Save cenit/71c3cd987ccd91d56b0c to your computer and use it in GitHub Desktop.
#!/bin/bash
NUMERO_TOTALE_CORE_DA_USARE=56
NUMERO_TOTALE_SCHEDE_VIDEO_DA_USARE=1
SYM_TYPE="CPU"
GPU_TYPE="k40"
BLENDER_FILE=benchmark.blend
IMAGE_TYPE=PNG
START_FRAME=2467
END_FRAME=2473
stderr_file=stderr.txt
stdout_file=stdout.txt
WORK_FOLDER=$(pwd)
job=job_test_blender.cmd
job_name=blender
python_script_name=script.py
NOME_ESEGUIBILE="/shared/software/blender/blender/blender"
###########################
rm -f $job ${python_script_name} ${stderr_file} ${stdout_file}
touch $job
chmod 755 $job
touch $python_script_name
chmod 755 $python_script_name
touch ${stderr_file}
touch ${stdout_file}
echo "import bpy" > $python_script_name
echo "Scenename = \"Scene\"" >> $python_script_name
echo "bpy.ops.wm.open_mainfile(filepath=\"${BLENDER_FILE}\")" >> $python_script_name
if [ ${SYM_TYPE} == "GPU" ]; then
echo "bpy.context.scene.render.engine = 'CYCLES'" >> $python_script_name
echo "bpy.context.user_preferences.system.compute_device_type = 'CUDA'" >> $python_script_name
echo "bpy.data.scenes[Scenename].cycles.device= 'GPU'" >> $python_script_name
echo "bpy.context.scene.render.tile_x = 256" >> $python_script_name
echo "bpy.context.scene.render.tile_y = 256" >> $python_script_name
elif [ ${SYM_TYPE} == "CPU" ]; then
echo "bpy.context.scene.render.engine = 'CYCLES'" >> $python_script_name
echo "bpy.context.scene.render.tile_x = 1" >> $python_script_name
echo "bpy.context.scene.render.tile_y = 1" >> $python_script_name
fi
echo "bpy.data.scenes[Scenename].frame_start = ${START_FRAME}" >> $python_script_name
echo "bpy.data.scenes[Scenename].frame_end = ${END_FRAME}" >> $python_script_name
echo "bpy.context.scene.render.image_settings.file_format = '${IMAGE_TYPE}'" >> $python_script_name
echo "bpy.data.scenes[Scenename].render.filepath = '${WORK_FOLDER}/'" >> $python_script_name
echo "bpy.ops.render.render(animation=True,scene=Scenename)" >> $python_script_name
echo "#!/bin/sh" > $job
echo "#BSUB -J ${job_name}.${SYM_TYPE}" >> $job
echo "#BSUB -o %J.out" >> $job
echo "#BSUB -e %J.err" >> $job
if [ ${SYM_TYPE} == "GPU" ]; then
queue=hpc_gpu
echo "#BSUB -n ${NUMERO_TOTALE_SCHEDE_VIDEO_DA_USARE}" >> $job
echo "#BSUB -q ${queue}" >> $job
#echo "#BSUB -m gpu${GPU_TYPE} -R \"rusage [ngpus_excl_p=2]\"" >> $job
echo "#BSUB -m 'hpc-200-06-01' -R \"rusage [ngpus_excl_p=2]\" " >> $job
#echo "module load compilers/cuda-6.5" >> $job
echo "module load compilers/cuda-7.5" >> $job
echo "nvidia-smi >> ${stdout_file} 2>> ${stderr_file} " >> $job
elif [ ${SYM_TYPE} == "CPU" ]; then
queue=hpc_56inf
echo "#BSUB -n ${NUMERO_TOTALE_CORE_DA_USARE}" >> $job
echo "#BSUB -q ${queue}" >> $job
#echo "#BSUB -R \"span[ptile=32]\"" >> $job
echo "export OMP_NUM_THREADS=${NUMERO_TOTALE_CORE_DA_USARE}" >> $job
fi
echo "cd ${WORK_FOLDER}" >> $job
echo "${NOME_ESEGUIBILE} -b --python ${python_script_name} >> ${stdout_file} 2>> ${stderr_file}" >> $job
bsub < $job
echo "Job partito!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment