From cfd38cfddd796b2e1013ac285682f0676b0b9a7e Mon Sep 17 00:00:00 2001 From: TennisGazelle Date: Mon, 24 May 2021 22:24:36 -0700 Subject: [PATCH 1/2] feat(gpu): init gpu dockerfile --- config.yaml | 6 +++--- scripts/Dockerfile.gpu | 45 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 scripts/Dockerfile.gpu diff --git a/config.yaml b/config.yaml index ccaaadb..5073d55 100644 --- a/config.yaml +++ b/config.yaml @@ -3,7 +3,7 @@ stages: buffer_frames: 1-90 force_update: false render_output: 'imgs/buffer/' - engine: CYCLES # todo: figure out how to do EEVEE + engine: EEVEE # todo: figure out how to do EEVEE blend_file: scene.blend render_format: PNG blender_flags: '' @@ -47,9 +47,9 @@ model_output_format: '{model}_{angle}_{map}' # experimental below, do not alter docker: - image: tennisgazelle/blender-pipeline:latest + image: tennisgazelle/blender-pipeline-gpu:latest #render_cmd: docker run --rm -v {cwd}/blender/:/blender/ -v {cwd}/imgs:/imgs ikester/blender blender/{blend_file} -o {output_location} -E {engine} -F {format} -t 8 {flags} - render_cmd: docker run --rm -v {cwd}/blender/:/blender/ -v {cwd}/imgs:/imgs tennisgazelle/blender-pipeline:latest blender/{blend_file} -E {engine} -F {format} -t 8 {flags} + render_cmd: docker run --rm -v {cwd}/blender/:/blender/ -v {cwd}/imgs:/imgs tennisgazelle/blender-pipeline-gpu:latest blender/{blend_file} -E {engine} -F {format} -t 8 {flags} # python_cmd: docker run --rm -v ${cwd}/blender/:/blender/ -v ${cwd}/scripts:/scripts -v ${cwd}/config.yaml:/config.yaml tennisgazelle/blender-pipeline:latest blender/scene.blend --python scripts/get_path.py var_defaults: engine: CYCLES diff --git a/scripts/Dockerfile.gpu b/scripts/Dockerfile.gpu new file mode 100644 index 0000000..6c7458e --- /dev/null +++ b/scripts/Dockerfile.gpu @@ -0,0 +1,45 @@ +# ARG IMAGE_NAME +# FROM ${IMAGE_NAME}:11.3.0-runtime-ubuntu20.04 +# LABEL maintainer "NVIDIA CORPORATION " +# ENV CUDNN_VERSION 8.2.0.53 +# LABEL com.nvidia.cudnn.version="${CUDNN_VERSION}" +# RUN apt-get update && apt-get install -y --no-install-recommends \ +# libcudnn8=$CUDNN_VERSION-1+cuda11.3 \ +# && apt-mark hold libcudnn8 && \ +# rm -rf /var/lib/apt/lists/* + +FROM nvidia/cuda:10.0-devel-ubuntu18.04 + +LABEL authors="Daniel Lopez " + +# set up deps for blender +RUN apt-get update && \ + apt-get install -y \ + curl \ + libfreetype6 \ + libglu1-mesa \ + libxi6 \ + libxrender1 \ + xz-utils && \ + apt-get -y autoremove + +# Download blender +ENV BLENDER_MAJOR 2.82 +ENV BLENDER_VERSION 2.82a +ENV BLENDER_URL https://download.blender.org/release/Blender${BLENDER_MAJOR}/blender-${BLENDER_VERSION}-linux64.tar.xz + +RUN curl -L ${BLENDER_URL} | tar -xJ -C /usr/local/ \ + && mv /usr/local/blender-${BLENDER_VERSION}-linux64 /usr/local/blender + +# run the pip install for the bundled python +RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py \ + && ls /usr/local/blender/${BLENDER_MAJOR}/python/lib \ + && /usr/local/blender/${BLENDER_MAJOR}/python/bin/python3.7m get-pip.py \ + && /usr/local/blender/${BLENDER_MAJOR}/python/bin/python3.7m -m pip install pyyaml yamale --user + +# Get the config common library near the blender executable +COPY common.py /usr/local/blender/${BLENDER_MAJOR}/python/lib/python3.7/ + +VOLUME /media +WORKDIR / +ENTRYPOINT ["/usr/local/blender/blender", "-b"] \ No newline at end of file From 26708779f8e5d0f12a63ae096fae79cb96c997cf Mon Sep 17 00:00:00 2001 From: TennisGazelle Date: Mon, 24 May 2021 22:27:08 -0700 Subject: [PATCH 2/2] feat(template): init template gen and compare scritps --- scripts/compare_template.py | 39 ++++++++++++++++++++++++++++++++++++ scripts/generate_template.py | 36 +++++++++++++++++++++++++++++++++ template_files.yaml | 5 +++++ 3 files changed, 80 insertions(+) create mode 100644 scripts/compare_template.py create mode 100644 template_files.yaml diff --git a/scripts/compare_template.py b/scripts/compare_template.py new file mode 100644 index 0000000..bee725a --- /dev/null +++ b/scripts/compare_template.py @@ -0,0 +1,39 @@ +import filecmp +import yaml +import json + +config = {} +sandbox_header_dir = 'sandbox/' + +def load_files_to_gen(): + with open ('template_files.yaml', 'r') as template_files: + config['template_files'] = yaml.load(template_files) + + print(json.dumps(config, indent=3)) + + +## start here: + +import argparse + +parser = argparse.ArgumentParser(description='Generate a template in the indicated directory') +parser.add_argument('--template', metavar='-t', type=str, required=True, + help='the generated template dir') +parser.add_argument('--yours', metavar='-y', type=str, required=True, + help='your project root dir') +args = parser.parse_args() + +load_files_to_gen('sandbox/') + + +# preview of file diffing +for file in config['template_files']: + if 'blend' in file: + continue + + print('checking for differences in {}{}'.format(sandbox_header_dir, file)) + areEqual = filecmp.cmp(file, '{}{}'.format(sandbox_header_dir, file)) + if areEqual: + print(' -- good') + else: + print(' -- not equal') \ No newline at end of file diff --git a/scripts/generate_template.py b/scripts/generate_template.py index e69de29..31e59fb 100644 --- a/scripts/generate_template.py +++ b/scripts/generate_template.py @@ -0,0 +1,36 @@ +import yaml +import json +import os +import shutil + +config = {} +def load_files_to_gen(): + with open ('template_files.yaml', 'r') as template_files: + config['template_files'] = yaml.load(template_files) + + print(json.dumps(config, indent=3)) + +def make_files(sandbox_header_dir): + print('refreshing sandbox/') + shutil.rmtree(sandbox_header_dir) + os.mkdir(sandbox_header_dir) + os.mkdir(sandbox_header_dir + 'blender/') + os.mkdir(sandbox_header_dir + 'scripts/') + os.mkdir(sandbox_header_dir + 'logs/') + + for file in config['template_files']: + shutil.copy(file, '{}{}'.format(sandbox_header_dir, file)) + print('file created in sandbox: {}{}'.format(sandbox_header_dir, file)) + +## start here: + +import argparse + +parser = argparse.ArgumentParser(description='Generate a template in the indicated directory') +parser.add_argument('out', metavar='o', type=str, + help='the output dir location (will create it if not there already)') + +args = parser.parse_args() + +load_files_to_gen() +make_files(args.out + "/") \ No newline at end of file diff --git a/template_files.yaml b/template_files.yaml new file mode 100644 index 0000000..f50750c --- /dev/null +++ b/template_files.yaml @@ -0,0 +1,5 @@ + - blender/scene.blend + - blender/edit.blend + - scripts/render.py + - config.yaml + - Makefile \ No newline at end of file