├── .dockerignore
├── python
├── scanner
│ ├── __init__.py
│ └── engine
│ │ └── __init__.py
└── scannerpy
│ ├── job.py
│ ├── io.py
│ ├── build_flags.py
│ ├── partitioner.py
│ └── util.py
├── .gdbinit
├── examples
├── tutorials
│ ├── resize_op
│ │ ├── .gitignore
│ │ ├── resize.proto
│ │ ├── Makefile
│ │ └── CMakeLists.txt
│ ├── workerpy.py
│ ├── masterpy.py
│ ├── 09_defining_cpp_sources.py
│ ├── 10_defining_cpp_sinks.py
│ ├── 07_profiling.py
│ ├── 08_defining_cpp_ops.py
│ ├── 03_sampling.py
│ └── README.md
├── apps
│ ├── open-reid-feature-extraction
│ │ ├── .gitignore
│ │ ├── Dockerfile
│ │ └── Readme.md
│ ├── object_detection_tensorflow
│ │ └── README.md
│ ├── gcp_kubernetes
│ │ ├── config.toml
│ │ ├── master.py
│ │ ├── Dockerfile.master
│ │ ├── Dockerfile.worker
│ │ ├── worker.py
│ │ ├── deploy.sh
│ │ ├── start_cluster.sh
│ │ ├── master.yml.template
│ │ ├── worker.yml.template
│ │ └── example.py
│ ├── aws_kubernetes
│ │ ├── Dockerfile.master
│ │ ├── Dockerfile.worker
│ │ ├── master.py
│ │ ├── scanner-config.yaml.template
│ │ ├── worker.py
│ │ ├── sync-dirs.sh
│ │ ├── delete_eks_cluster.sh
│ │ ├── spawn_staging_machine.sh
│ │ ├── kubeconfig.template
│ │ ├── master.yml.template
│ │ ├── worker.yml.template
│ │ ├── example.py
│ │ ├── build_and_deploy.sh
│ │ └── scale_eks_workers.sh
│ ├── detectron
│ │ ├── Dockerfile
│ │ ├── README.md
│ │ └── main.py
│ ├── walkthroughs
│ │ └── grayscale_conversion.py
│ └── pose_detection
│ │ └── main.py
├── how-tos
│ ├── halide
│ │ ├── resize.proto
│ │ ├── CMakeLists.txt
│ │ └── resize_op.cpp
│ ├── python_kernel
│ │ └── python.py
│ └── caffe
│ │ └── resnet.py
└── util.py
├── docs
├── guide
│ ├── installation.rst
│ ├── extensions.rst
│ ├── tutorial.rst
│ ├── kubernetes.rst
│ └── quickstart.rst
├── overview.rst
├── api
│ └── scanner.rst
├── scanner_logo.png
├── _static
│ ├── trace_viz.jpg
│ ├── trace_worker.jpg
│ ├── face_detection.jpg
│ ├── pose_detection.jpg
│ ├── object_detection.jpg
│ ├── trace_processes.jpg
│ ├── trace_worker_expand.jpg
│ ├── grayscale_conversion.jpg
│ └── tvnews_host_narcissism.jpg
├── _templates
│ └── guidetoc.html
├── index.rst
├── Makefile
├── api.rst
├── publications.rst
├── guide.rst
└── overview_h.html
├── scripts
├── doxypypy-filter.sh
├── startup_node.sh
├── travis-test.sh
├── travis-build.sh
└── travis-publish.sh
├── tests
├── pytest.ini
├── conftest.py
├── test_ops.proto
├── spawn_worker.py
├── CMakeLists.txt
└── videos.h
├── scanner
├── video
│ ├── intel
│ │ ├── CMakeLists.txt
│ │ └── intel_video_decoder.h
│ ├── nvidia
│ │ └── CMakeLists.txt
│ ├── software
│ │ ├── CMakeLists.txt
│ │ ├── software_video_decoder.h
│ │ └── software_video_encoder.h
│ ├── CMakeLists.txt
│ ├── video_decoder.h
│ └── video_encoder.h
├── CMakeLists.txt
├── api
│ ├── CMakeLists.txt
│ ├── enumerator.cpp
│ ├── source.cpp
│ └── sink.cpp
├── util
│ ├── halide_context.h
│ ├── halide_context.cpp
│ ├── bbox.h
│ ├── jsoncpp.h
│ ├── types.h
│ ├── glog.h
│ ├── glog.cpp
│ ├── CMakeLists.txt
│ ├── image.h
│ ├── queue.h
│ ├── cuda.h
│ ├── halide.h
│ ├── profiler.inl
│ ├── ffmpeg.h
│ ├── fs.h
│ ├── profiler.h
│ └── common.cpp
├── engine
│ ├── build_flags.in.cpp
│ ├── source_args.proto
│ ├── sample_kernel.h
│ ├── CMakeLists.txt
│ ├── slice_op.cpp
│ ├── sample_op.cpp
│ ├── unslice_op.cpp
│ ├── space_op.cpp
│ ├── python_kernel.h
│ ├── op_registry.h
│ ├── sampler_registry.h
│ ├── sink_registry.h
│ ├── source_registry.h
│ ├── enumerator_registry.h
│ ├── enumerator_registry.cpp
│ ├── kernel_registry.h
│ ├── column_enumerator.h
│ ├── ingest.h
│ ├── kernel_registry.cpp
│ ├── enumerator_factory.h
│ ├── table_meta_cache.h
│ ├── source_registry.cpp
│ ├── op_registry.cpp
│ ├── source_factory.h
│ ├── video_index_entry.h
│ ├── column_source.h
│ ├── column_sink.h
│ ├── load_worker.h
│ └── sink_registry.cpp
├── sink_args.proto
├── types.proto
├── source_args.proto
├── doxygen.md
└── sampler_args.proto
├── setup.cfg
├── .travis
├── travisci_rsa.enc
├── travisci_rsa_brew.enc
├── travisci_rsa_brew.pub
└── travisci_rsa.pub
├── thirdparty
└── resources
│ ├── cuda
│ ├── libnvcuvid.so.367.48
│ └── libnvcuvid.so.387.26
│ └── mkl
│ └── silent.cfg
├── docker
├── ubuntu16.04
│ ├── requirements.txt
│ ├── Dockerfile.gpu9
│ ├── Dockerfile.gpu10
│ ├── Dockerfile.gpu8
│ ├── Dockerfile.cpu
│ └── Dockerfile.base
├── docker-compose.yml
├── Dockerfile.scanner
└── build-all-base.sh
├── .scanner.example.toml
├── .gitignore
├── deps_openvino.sh
├── cmake
└── Modules
│ ├── FindNVCUVID.cmake
│ ├── FindHwang.cmake
│ ├── FindHalide.cmake
│ ├── FindEigen.cmake
│ ├── FindStruck.cmake
│ ├── FindGipuma.cmake
│ ├── FindTinyToml.cmake
│ ├── FindFolly.cmake
│ ├── FindProxygen.cmake
│ ├── FindGlog.cmake
│ ├── FindGoogleTest.cmake
│ ├── FindGFlags.cmake
│ ├── FindIconv.cmake
│ └── FindGRPC.cmake
└── google.md
/.dockerignore:
--------------------------------------------------------------------------------
1 | .gitignore
--------------------------------------------------------------------------------
/python/scanner/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/python/scanner/engine/__init__.py:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.gdbinit:
--------------------------------------------------------------------------------
1 | handle SIG40 nostop noprint
2 |
--------------------------------------------------------------------------------
/examples/tutorials/resize_op/.gitignore:
--------------------------------------------------------------------------------
1 | build
2 |
--------------------------------------------------------------------------------
/docs/guide/installation.rst:
--------------------------------------------------------------------------------
1 | .. _installation:
2 |
3 |
--------------------------------------------------------------------------------
/docs/overview.rst:
--------------------------------------------------------------------------------
1 | .. raw:: html
2 | :file: overview_h.html
3 |
--------------------------------------------------------------------------------
/scripts/doxypypy-filter.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | doxypypy -a -c $1
3 |
--------------------------------------------------------------------------------
/tests/pytest.ini:
--------------------------------------------------------------------------------
1 | [pytest]
2 | markets =
3 | gpu: test requires GPU to run.
--------------------------------------------------------------------------------
/docs/api/scanner.rst:
--------------------------------------------------------------------------------
1 | Scanner C++ API
2 | ===============
3 |
4 | .. toctree::
5 |
--------------------------------------------------------------------------------
/docs/scanner_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scanner-research/scanner/HEAD/docs/scanner_logo.png
--------------------------------------------------------------------------------
/examples/apps/open-reid-feature-extraction/.gitignore:
--------------------------------------------------------------------------------
1 | model_best.pth.tar
2 | *.mp4
3 | reid_features.npy
--------------------------------------------------------------------------------
/scanner/video/intel/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_library(video_intel OBJECT
2 | intel_video_decoder.cpp)
3 |
--------------------------------------------------------------------------------
/scanner/video/nvidia/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_library(video_nvidia OBJECT
2 | nvidia_video_decoder.cpp)
3 |
--------------------------------------------------------------------------------
/setup.cfg:
--------------------------------------------------------------------------------
1 | [aliases]
2 | test=pytest
3 |
4 | [tool:pytest]
5 | addopts = -vvs
6 | testpaths = tests
7 |
--------------------------------------------------------------------------------
/.travis/travisci_rsa.enc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scanner-research/scanner/HEAD/.travis/travisci_rsa.enc
--------------------------------------------------------------------------------
/docs/_static/trace_viz.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scanner-research/scanner/HEAD/docs/_static/trace_viz.jpg
--------------------------------------------------------------------------------
/examples/apps/object_detection_tensorflow/README.md:
--------------------------------------------------------------------------------
1 | sudo apt-get install python3-tk
2 | pip3 install pillow
3 |
--------------------------------------------------------------------------------
/.travis/travisci_rsa_brew.enc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scanner-research/scanner/HEAD/.travis/travisci_rsa_brew.enc
--------------------------------------------------------------------------------
/docs/_static/trace_worker.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scanner-research/scanner/HEAD/docs/_static/trace_worker.jpg
--------------------------------------------------------------------------------
/docs/_static/face_detection.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scanner-research/scanner/HEAD/docs/_static/face_detection.jpg
--------------------------------------------------------------------------------
/docs/_static/pose_detection.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scanner-research/scanner/HEAD/docs/_static/pose_detection.jpg
--------------------------------------------------------------------------------
/docs/_static/object_detection.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scanner-research/scanner/HEAD/docs/_static/object_detection.jpg
--------------------------------------------------------------------------------
/docs/_static/trace_processes.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scanner-research/scanner/HEAD/docs/_static/trace_processes.jpg
--------------------------------------------------------------------------------
/docs/_static/trace_worker_expand.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scanner-research/scanner/HEAD/docs/_static/trace_worker_expand.jpg
--------------------------------------------------------------------------------
/examples/apps/gcp_kubernetes/config.toml:
--------------------------------------------------------------------------------
1 | [storage]
2 | type = "gcs"
3 | bucket = "k8s-test-buck"
4 | db_path = "test/scanner_db"
5 |
--------------------------------------------------------------------------------
/docs/_static/grayscale_conversion.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scanner-research/scanner/HEAD/docs/_static/grayscale_conversion.jpg
--------------------------------------------------------------------------------
/docs/_static/tvnews_host_narcissism.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scanner-research/scanner/HEAD/docs/_static/tvnews_host_narcissism.jpg
--------------------------------------------------------------------------------
/examples/how-tos/halide/resize.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | message ResizeArgs {
4 | int32 width = 1;
5 | int32 height = 2;
6 | }
7 |
--------------------------------------------------------------------------------
/scanner/video/software/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_library(video_software OBJECT
2 | software_video_decoder.cpp
3 | software_video_encoder.cpp)
4 |
--------------------------------------------------------------------------------
/examples/tutorials/resize_op/resize.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | message MyResizeArgs {
4 | int32 width = 1;
5 | int32 height = 2;
6 | }
7 |
--------------------------------------------------------------------------------
/examples/tutorials/workerpy.py:
--------------------------------------------------------------------------------
1 | from scannerpy import Client
2 | sc = Client()
3 |
4 | sc.start_worker()
5 |
6 | import time
7 | time.sleep(1000)
8 |
--------------------------------------------------------------------------------
/thirdparty/resources/cuda/libnvcuvid.so.367.48:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scanner-research/scanner/HEAD/thirdparty/resources/cuda/libnvcuvid.so.367.48
--------------------------------------------------------------------------------
/thirdparty/resources/cuda/libnvcuvid.so.387.26:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/scanner-research/scanner/HEAD/thirdparty/resources/cuda/libnvcuvid.so.387.26
--------------------------------------------------------------------------------
/examples/tutorials/masterpy.py:
--------------------------------------------------------------------------------
1 | from scannerpy import Client
2 | sc = Client(workers=['ocean.pdl.local.cmu.edu:15559', 'crissy.pdl.local.cmu.edu:15559'])
3 |
--------------------------------------------------------------------------------
/examples/tutorials/09_defining_cpp_sources.py:
--------------------------------------------------------------------------------
1 | # This tutorial is still being written. Send an email to apoms@cs.cmu.edu if you are interested in this feature.
2 |
--------------------------------------------------------------------------------
/examples/tutorials/10_defining_cpp_sinks.py:
--------------------------------------------------------------------------------
1 | # This tutorial is still being written. Send an email to apoms@cs.cmu.edu if you are interested in this feature.
2 |
--------------------------------------------------------------------------------
/tests/conftest.py:
--------------------------------------------------------------------------------
1 | import pytest
2 |
3 | def pytest_addoption(parser):
4 | parser.addoption('--runslow', action='store_true',
5 | help='Run slow tests')
6 |
--------------------------------------------------------------------------------
/scanner/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | set(SCANNER_OBJS)
2 | add_subdirectory(api)
3 | add_subdirectory(engine)
4 | add_subdirectory(video)
5 | add_subdirectory(util)
6 | set(SCANNER_OBJS ${SCANNER_OBJS} PARENT_SCOPE)
7 |
--------------------------------------------------------------------------------
/scanner/api/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | set(SOURCE_FILES
2 | frame.cpp
3 | kernel.cpp
4 | op.cpp
5 | source.cpp
6 | sink.cpp
7 | enumerator.cpp
8 | database.cpp)
9 |
10 | add_library(api OBJECT
11 | ${SOURCE_FILES})
12 |
--------------------------------------------------------------------------------
/docs/_templates/guidetoc.html:
--------------------------------------------------------------------------------
1 |
2 |
4 | {{
5 | toctree(maxdepth=2, collapse=False, includehidden=True)
6 | }}
7 |
8 |
9 |
--------------------------------------------------------------------------------
/docs/guide/extensions.rst:
--------------------------------------------------------------------------------
1 | .. _extensions:
2 |
3 | Extensions
4 | ==========
5 |
6 | Scanner supports extending the system in four ways:
7 |
8 | - Ops:
9 |
10 | - Sources:
11 |
12 | - Sinks
13 |
14 | - Storage backends:
15 |
--------------------------------------------------------------------------------
/scanner/util/halide_context.h:
--------------------------------------------------------------------------------
1 | #include "scanner/util/cuda.h"
2 |
3 | #pragma once
4 |
5 | namespace Halide {
6 | namespace Runtime {
7 | namespace Internal {
8 | namespace Cuda {
9 | extern CUcontext context;
10 | }
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/examples/apps/aws_kubernetes/Dockerfile.master:
--------------------------------------------------------------------------------
1 | FROM scannerresearch/scanner:cpu-latest
2 | WORKDIR /app
3 |
4 | COPY master.py .
5 |
6 | ENV LD_LIBRARY_PATH /usr/local/lib/python3.5/dist-packages/scannerpy:$LD_LIBRARY_PATH
7 | CMD python3 master.py
8 |
--------------------------------------------------------------------------------
/examples/apps/aws_kubernetes/Dockerfile.worker:
--------------------------------------------------------------------------------
1 | FROM scannerresearch/scanner:cpu-latest
2 | WORKDIR /app
3 |
4 | COPY worker.py .
5 |
6 | ENV LD_LIBRARY_PATH /usr/local/lib/python3.5/dist-packages/scannerpy:$LD_LIBRARY_PATH
7 | CMD python3 worker.py
8 |
--------------------------------------------------------------------------------
/scanner/util/halide_context.cpp:
--------------------------------------------------------------------------------
1 | #include "scanner/util/cuda.h"
2 |
3 | #ifdef HAVE_CUDA
4 | namespace Halide {
5 | namespace Runtime {
6 | namespace Internal {
7 | namespace Cuda {
8 | CUcontext context = 0;
9 | }
10 | }
11 | }
12 | }
13 | #endif
14 |
--------------------------------------------------------------------------------
/scanner/engine/build_flags.in.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | int main() {
3 | std::cout << "@dirs@" << std::endl;
4 | #ifdef HAVE_CUDA
5 | std::cout << "-DHAVE_CUDA" << std::endl;
6 | #else
7 | std::cout << std::endl;
8 | #endif
9 | return 0;
10 | }
11 |
--------------------------------------------------------------------------------
/scanner/sink_args.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package scanner.proto;
4 |
5 | message ColumnSinkArgs {
6 | // For creating storehouse adapter
7 | string storage_type = 1;
8 | string bucket = 2;
9 | string region = 3;
10 | string endpoint = 4;
11 | }
12 |
--------------------------------------------------------------------------------
/examples/apps/aws_kubernetes/master.py:
--------------------------------------------------------------------------------
1 | import scannerpy
2 | import os
3 |
4 | if __name__ == "__main__":
5 | scannerpy.start_master(port='8080',
6 | block=True,
7 | watchdog=False,
8 | no_workers_timeout=180)
9 |
--------------------------------------------------------------------------------
/examples/apps/gcp_kubernetes/master.py:
--------------------------------------------------------------------------------
1 | import scannerpy
2 | import os
3 |
4 | if __name__ == "__main__":
5 | scannerpy.start_master(port='8080',
6 | block=True,
7 | watchdog=False,
8 | no_workers_timeout=180)
9 |
--------------------------------------------------------------------------------
/examples/apps/gcp_kubernetes/Dockerfile.master:
--------------------------------------------------------------------------------
1 | FROM scannerresearch/scanner:cpu-latest
2 | WORKDIR /app
3 |
4 | COPY config.toml /root/.scanner/config.toml
5 | COPY master.py .
6 |
7 | ENV LD_LIBRARY_PATH /usr/local/lib/python3.5/dist-packages/scannerpy:$LD_LIBRARY_PATH
8 | CMD python3 master.py
9 |
--------------------------------------------------------------------------------
/examples/apps/gcp_kubernetes/Dockerfile.worker:
--------------------------------------------------------------------------------
1 | FROM scannerresearch/scanner:cpu-latest
2 | WORKDIR /app
3 |
4 | COPY config.toml /root/.scanner/config.toml
5 | COPY worker.py .
6 |
7 | ENV LD_LIBRARY_PATH /usr/local/lib/python3.5/dist-packages/scannerpy:$LD_LIBRARY_PATH
8 | CMD python3 worker.py
9 |
--------------------------------------------------------------------------------
/python/scannerpy/job.py:
--------------------------------------------------------------------------------
1 |
2 |
3 | class Job(object):
4 | """
5 | A specification of a table to produce as output of a bulk job.
6 | """
7 | def __init__(self, op_args):
8 | self._op_args = op_args
9 |
10 | def op_args(self):
11 | return self._op_args
12 |
--------------------------------------------------------------------------------
/tests/test_ops.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | message BlurArgs {
4 | int32 kernel_size = 1;
5 | float sigma = 2;
6 | }
7 |
8 | message ResizeArgs {
9 | int32 width = 1;
10 | int32 height = 2;
11 | bool min = 3;
12 | bool preserve_aspect = 4;
13 | string interpolation = 5;
14 | }
15 |
--------------------------------------------------------------------------------
/docs/guide/tutorial.rst:
--------------------------------------------------------------------------------
1 | .. _tutorial:
2 |
3 | Tutorials
4 | =========
5 |
6 | Scanner provides a set of tutorials that provide step-by-step examples of many
7 | of the basic features provided by Scanner. These tutorials can be found
8 | `here `__.
9 |
--------------------------------------------------------------------------------
/examples/apps/aws_kubernetes/scanner-config.yaml.template:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | kind: ConfigMap
3 | data:
4 | config.toml: |
5 | [storage]
6 | type = "s3"
7 | bucket =
8 | db_path = "scanner_dbs/"
9 | region = "us-west-2"
10 | endpoint = "s3.us-west-2.amazonaws.com"
11 |
12 | metadata:
13 | name: scanner-configmap
14 |
--------------------------------------------------------------------------------
/examples/apps/open-reid-feature-extraction/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM scannerresearch/scanner:gpu-9.1-cudnn7
2 | WORKDIR /opt/openreid
3 |
4 | RUN cd /opt/openreid && \
5 | git clone https://github.com/Cysu/open-reid.git && \
6 | cd open-reid && \
7 | pip3 install http://download.pytorch.org/whl/cu91/torch-0.4.0-cp35-cp35m-linux_x86_64.whl && \
8 | python3 setup.py install
9 |
--------------------------------------------------------------------------------
/scanner/util/bbox.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "scanner/util/common.h"
4 |
5 | namespace scanner {
6 |
7 | std::vector best_nms(const std::vector& boxes,
8 | f32 overlap);
9 |
10 | std::vector average_nms(const std::vector& boxes,
11 | f32 overlap);
12 | }
13 |
--------------------------------------------------------------------------------
/docker/ubuntu16.04/requirements.txt:
--------------------------------------------------------------------------------
1 | ipython==5.3.0
2 | numpy==1.12.0
3 | protobuf==3.2.0
4 | toml==0.9.2
5 | youtube-dl
6 | scipy==0.18.1
7 | scikit-learn==0.18.1
8 | scikit-image==0.12.3
9 | matplotlib==2.0.0
10 | seaborn==0.7.1
11 | grpcio==1.7.0
12 | doxypypy==0.8.8.6
13 | pytest==3.0.6
14 | twine==1.8.1
15 | ipaddress==1.0.18
16 | plotly==2.0.6
17 | jupyter==1.0.0
18 | pandas==0.19.0
19 |
--------------------------------------------------------------------------------
/examples/apps/aws_kubernetes/worker.py:
--------------------------------------------------------------------------------
1 | import scannerpy
2 | import os
3 |
4 | if __name__ == "__main__":
5 | scannerpy.start_worker('{}:{}'.format(
6 | os.environ['SCANNER_MASTER_SERVICE_HOST'],
7 | os.environ['SCANNER_MASTER_SERVICE_PORT']),
8 | block=True,
9 | watchdog=False,
10 | port=5002)
11 |
--------------------------------------------------------------------------------
/examples/apps/gcp_kubernetes/worker.py:
--------------------------------------------------------------------------------
1 | import scannerpy
2 | import os
3 |
4 | if __name__ == "__main__":
5 | scannerpy.start_worker('{}:{}'.format(
6 | os.environ['SCANNER_MASTER_SERVICE_HOST'],
7 | os.environ['SCANNER_MASTER_SERVICE_PORT']),
8 | block=True,
9 | watchdog=False,
10 | port=5002)
11 |
--------------------------------------------------------------------------------
/.scanner.example.toml:
--------------------------------------------------------------------------------
1 | scanner_path = "/opt/scanner"
2 |
3 | [storage]
4 | type = "posix"
5 | db_path = "/opt/scanner-db"
6 |
7 | # [storage]
8 | # type = "gcs"
9 | # key_path = "/path/to/gcs.key"
10 | # cert_path = "/path/to/gcs.cert"
11 | # bucket = "gcs-bucket"
12 |
13 | [network]
14 | master = "localhost"
15 | master_port = "5001"
16 | worker_port = "5002"
17 |
--------------------------------------------------------------------------------
/.travis/travisci_rsa_brew.pub:
--------------------------------------------------------------------------------
1 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCw2maYHWQ6cdBi9UJ2Dzv4okW/bw0pmZAKAFZvXOjZ8rRcrhgu8pK289t42Hwso9dsCROJxxVegDTZeOh8jyuQqKziBXu1MqN/3+KuRWJfw3QGwOQNOuwPkBOEn+TZpkgiyz2GMDfvy1WseWxgKzadY2C/R4lHafnmc4Dr/6k2uNST3s73CAyHlGpORItlqZ+oc/IX74qz27PsjMjZsjarCEHDb3UWlsG95D1ymMWrwXUpx6/azyuAJEiWJp/UtdfL8oJVec9vXqK9pzI6IykLdFm0y72FYXtMwBDARugDGpqTpO1xmba0kSAoMe5Ip24nbNHB6gIHL8dnAD9qrbzF apoms@AlexandersMBP2.lan
2 |
--------------------------------------------------------------------------------
/examples/apps/gcp_kubernetes/deploy.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | export PROJECT=$(gcloud config get-value project)
4 |
5 | docker build -f Dockerfile.master -t gcr.io/$PROJECT/scanner-master:cpu .
6 | docker build -f Dockerfile.worker -t gcr.io/$PROJECT/scanner-worker:cpu .
7 |
8 | gcloud docker -- push gcr.io/$PROJECT/scanner-master:cpu
9 | gcloud docker -- push gcr.io/$PROJECT/scanner-worker:cpu
10 |
11 | kubectl delete deploy --all
12 | kubectl create -f master.yml
13 | kubectl create -f worker.yml
14 |
--------------------------------------------------------------------------------
/docs/index.rst:
--------------------------------------------------------------------------------
1 | .. scanner documentation master file, created by
2 | sphinx-quickstart on Sun Nov 26 19:06:21 2017.
3 | You can adapt this file completely to your liking, but it should at least
4 | contain the root `toctree` directive.
5 |
6 | .. raw:: html
7 | :file: index_h.html
8 |
9 | .. toctree::
10 | :hidden:
11 |
12 | guide/quickstart
13 | guide/getting-started
14 | guide/walkthrough
15 | guide/graphs
16 | guide/ops
17 | guide/stored-streams
18 | guide/profiling
19 | guide/kubernetes
20 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Warning: this is also used as the .dockerignore, and the matching patterns are
2 | # similar but **not quite** the same. If you add a file here, make sure that
3 | # the Docker build still works.
4 |
5 | dependencies.txt
6 | nvidia-docker-compose.yml
7 | .cache
8 | build
9 | **/*.pyc
10 | **/*.trace
11 | thirdparty
12 | !thirdparty/resources
13 | !thirdparty/CMakeLists.txt
14 | python/*.egg-info
15 | docker/**/deps.sh
16 | docker/**/thirdparty
17 | **/*.mp4
18 | **/*.mkv
19 | docker/*.log
20 |
21 | python/scannerpy/include
22 | dist
--------------------------------------------------------------------------------
/examples/apps/aws_kubernetes/sync-dirs.sh:
--------------------------------------------------------------------------------
1 | #!/usr/local/bin/bash
2 |
3 | DEFAULT_SERVER=localhost
4 | DEFAULT_PORT=8022
5 |
6 | LOCAL_DIR=$1
7 | REMOTE_DIR=$2
8 | REMOTE_SERVER=${3:-$DEFAULT_SERVER}
9 | SSH_KEY=${4}
10 |
11 | CMD="rsync -avz -e \"ssh -i $SSH_KEY\" \
12 | --exclude build \
13 | --exclude .git* \
14 | --exclude \#* \
15 | -r $LOCAL_DIR/ \
16 | $REMOTE_SERVER:$REMOTE_DIR"
17 | eval $CMD
18 |
19 | # inotifywait, linux
20 | while fswatch -r $LOCAL_DIR/* -1; do
21 | eval $CMD || break;
22 | done
23 |
--------------------------------------------------------------------------------
/scanner/types.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package scanner.proto;
4 |
5 | message Frame {
6 | int64 buffer = 1;
7 | int32 width = 2;
8 | int32 height = 3;
9 | }
10 |
11 | message BoundingBox {
12 | float x1 = 1;
13 | float y1 = 2;
14 | float x2 = 3;
15 | float y2 = 4;
16 | float score = 5;
17 | int32 track_id = 6;
18 | double track_score = 7;
19 | int32 label = 8;
20 | }
21 |
22 | message Point {
23 | float x = 1;
24 | float y = 2;
25 | float score = 3;
26 | }
27 |
28 | message ImageEncoderArgs {
29 | string format = 1;
30 | }
31 |
--------------------------------------------------------------------------------
/docker/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: "2.3"
2 | services:
3 | gpu:
4 | image: scannerresearch/scannertools:gpu-9.1-cudnn7-latest
5 | command: bash -c "cd /opt/scanner && jupyter notebook --allow-root --ip=0.0.0.0 --port=8888"
6 | ports:
7 | - "8888:8888"
8 | volumes:
9 | - .:/app
10 | runtime: nvidia
11 | cpu:
12 | image: scannerresearch/scannertools:cpu-latest
13 | command: bash -c "cd /opt/scanner && jupyter notebook --allow-root --ip=0.0.0.0 --port=8888"
14 | ports:
15 | - "8888:8888"
16 | volumes:
17 | - .:/app
18 |
--------------------------------------------------------------------------------
/examples/apps/gcp_kubernetes/start_cluster.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | ZONE=us-west1-b
4 |
5 | gcloud container clusters create example-cluster \
6 | --zone "$ZONE" \
7 | --machine-type "n1-standard-2" \
8 | --num-nodes 1
9 |
10 | gcloud container clusters get-credentials example-cluster --zone "$ZONE"
11 |
12 | gcloud container node-pools create workers \
13 | --zone "$ZONE" \
14 | --cluster example-cluster \
15 | --machine-type "n1-standard-2" \
16 | --num-nodes 1 \
17 | --enable-autoscaling \
18 | --min-nodes 0 \
19 | --max-nodes 5 \
20 | --preemptible
21 |
--------------------------------------------------------------------------------
/scanner/engine/source_args.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package scanner.proto;
4 |
5 | message LoadSample {
6 | int32 table_id = 1;
7 | int32 column_id = 2;
8 | repeated int64 input_row_ids = 3 [packed=true];
9 | }
10 |
11 | message ColumnEnumeratorArgs {
12 | int32 table_id = 1;
13 | int32 column_id = 2;
14 | }
15 |
16 | message ColumnSourceArgs {
17 | // For creating storehouse adapter
18 | string storage_type = 1;
19 | string bucket = 2;
20 | string region = 3;
21 | string endpoint = 4;
22 | }
23 |
24 | message ColumnElementArgs {
25 | int32 table_id = 1;
26 | int32 column_id = 2;
27 | int64 row_id = 3;
28 | }
29 |
--------------------------------------------------------------------------------
/deps_openvino.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | if [[ "$OSTYPE" == "linux-gnu" ]]; then
4 | OPENVINO_REQ_PKGS=(
5 | libusb-1.0-0-dev
6 | libgstreamer1.0-0
7 | gstreamer1.0-plugins-base
8 | gstreamer1.0-plugins-good
9 | gstreamer1.0-plugins-bad
10 | )
11 | apt update
12 | apt install -y ${OPENVINO_REQ_PKGS[@]}
13 | # ...
14 | elif [[ "$OSTYPE" == "darwin"* ]]; then
15 | echo "Support for Scanner with OpenVINO in Mac OSX is not available at this time."
16 | exit 1
17 | # Mac OSX
18 | else
19 | # Unknown.
20 | echo "Unknown OSTYPE: $OSTYPE. Exiting."
21 | exit 1
22 | fi
23 |
24 |
--------------------------------------------------------------------------------
/examples/apps/aws_kubernetes/delete_eks_cluster.sh:
--------------------------------------------------------------------------------
1 | programname=$0
2 |
3 | function usage {
4 | echo "usage: $programname name"
5 | echo " name name of the cluster"
6 | exit 1
7 | }
8 |
9 | if [ $# == 0 ]; then
10 | usage
11 | fi
12 |
13 | NAME=$1
14 |
15 | CLUSTER_NAME=$NAME
16 | ROLE_ARN=arn:aws:iam::459065735846:role/eksServiceRole
17 |
18 | ### 1. Delete worker nodes
19 | aws cloudformation delete-stack --stack-name $CLUSTER_NAME-workers
20 |
21 | ### 2. Delete kubectl config for connecting to cluster
22 | rm ~/.kube/config-$CLUSTER_NAME
23 |
24 | ### 3. Delete the EKS cluster
25 |
26 | aws eks delete-cluster --name $CLUSTER_NAME
27 |
--------------------------------------------------------------------------------
/examples/apps/aws_kubernetes/spawn_staging_machine.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | AMI=
4 |
5 | INSTANCE_ID=$(
6 | aws ec2 run-instances \
7 | --image-id $AMI \
8 | --security-group-ids sg-a6558ed8 \
9 | --count 1 \
10 | --instance-type m5.12xlarge \
11 | --block-device-mappings "[{\"DeviceName\": \"/dev/sda1\",\"Ebs\":{\"VolumeSize\":128}}]" \
12 | --key-name ec2-key \
13 | --query 'Instances[0].InstanceId' \
14 | --output text)
15 |
16 | TEMP=$(aws ec2 describe-instances \
17 | --instance-ids $INSTANCE_ID \
18 | --query 'Reservations[0].Instances[0].PublicIpAddress' \
19 | --output text)
20 |
21 | echo $TEMP
22 |
--------------------------------------------------------------------------------
/scanner/source_args.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package scanner.proto;
4 |
5 | message LoadSample {
6 | int32 table_id = 1;
7 | int32 column_id = 2;
8 | repeated int64 input_row_ids = 3 [packed=true];
9 | }
10 |
11 | message ColumnEnumeratorArgs {
12 | string table_name = 1;
13 | string column_name = 2;
14 | }
15 |
16 | message ColumnSourceArgs {
17 | // For creating storehouse adapter
18 | string storage_type = 1;
19 | string bucket = 2;
20 | string region = 3;
21 | string endpoint = 4;
22 | // Performance flags
23 | int32 load_sparsity_threshold = 5;
24 | }
25 |
26 | message ColumnElementArgs {
27 | int32 table_id = 1;
28 | int32 column_id = 2;
29 | int64 row_id = 3;
30 | }
31 |
--------------------------------------------------------------------------------
/scanner/engine/sample_kernel.h:
--------------------------------------------------------------------------------
1 | #include "scanner/api/kernel.h"
2 | #include "scanner/api/op.h"
3 | #include "scanner/util/memory.h"
4 | #include "scanner/metadata.pb.h"
5 |
6 | #include
7 | #include
8 |
9 | namespace scanner {
10 |
11 | class SampleKernel : public Kernel {
12 | public:
13 | SampleKernel(const KernelConfig& config, const std::string& kernel_str,
14 | const std::string& pickled_config);
15 |
16 | ~SamplehonKernel();
17 |
18 | void execute(const BatchedElements& input_columns,
19 | BatchedElements& output_columns) override;
20 |
21 | private:
22 | KernelConfig config_;
23 | DeviceHandle device_;
24 | };
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/.travis/travisci_rsa.pub:
--------------------------------------------------------------------------------
1 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDQVJh7T9r1y2R8a3Ml0K59D7Wj4tVUGKmPC594YGQ9l6GLwE/BGp5pfVkyyBWS/GEy9oVdygaGPVKIpY2L4diygAaVRxp6jBiP3lFXygFsOh7lRShmdQwlCduDPoMQCRjcrYyod8Exk0argEdYPr3FfpY1bl5s0rjjBYsbiVhO7g5LfILi/V5s07sLQUUCmmhR67M2ljBeXF6DtvVbpy9tBoucefVFKz6UILJTnMuSzAMXl5HvbXCng+Rdv8T/mN/tGwMFzP7q5YOFZxtxg0pYkRgBQO4rk5LUMH8wNvMGnoifnf72wK8Na4V+ZnW4BiHLrXxvYBFCvAg5ndqfra7nBuGArD+O7debVjMzpKA4Ok/kbOICDKZfG85J93R6YeKB4gTE+i55RKy80CxjGsW3pwLTVqFEUO73dwIrEBc4+i5L6iRHYTx3TducOEbQWI9DklQykYYMPD1QGC9jn0RT/pA/NUXb7qu7lVxST49guNm+6/zfBWz1em1C503FQAKv5UFM0x089Z/TvOWNS9T4z+yv6Irby0GInMMeBM1UZs1Uwn00eiz375KWG+Cel3cYQD9aTqhS+7hwYuAvi35Ng09IWv7EFCX1EbQlKE5EuLO5ZChusAr5GlljCyeCZQoTwPs4j644JFeYd8mPIZqJ8vRIPjEascUfPJa3oxCbeQ== wcrichto@cs.stanford.edu
2 |
--------------------------------------------------------------------------------
/scanner/util/jsoncpp.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2016 Carnegie Mellon University, NVIDIA Corporation
2 | *
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | */
15 |
16 | #pragma once
17 |
18 | #include
19 |
--------------------------------------------------------------------------------
/scanner/util/types.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2016 Carnegie Mellon University, NVIDIA Corporation
2 | *
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | */
15 |
16 | #pragma once
17 |
18 | namespace scanner {}
19 |
--------------------------------------------------------------------------------
/examples/apps/aws_kubernetes/kubeconfig.template:
--------------------------------------------------------------------------------
1 | apiVersion: v1
2 | clusters:
3 | - cluster:
4 | server:
5 | certificate-authority-data:
6 | name: kubernetes
7 | contexts:
8 | - context:
9 | cluster: kubernetes
10 | user: aws
11 | name: aws
12 | current-context: aws
13 | kind: Config
14 | preferences: {}
15 | users:
16 | - name: aws
17 | user:
18 | exec:
19 | apiVersion: client.authentication.k8s.io/v1alpha1
20 | command: heptio-authenticator-aws
21 | args:
22 | - "token"
23 | - "-i"
24 | - ""
25 | # - "-r"
26 | # - ""
27 | # env:
28 | # - name: AWS_PROFILE
29 | # value: ""
30 |
--------------------------------------------------------------------------------
/docs/guide/kubernetes.rst:
--------------------------------------------------------------------------------
1 | .. _kubernetes:
2 |
3 | Kubernetes Integration
4 | ======================
5 |
6 | The easiest way to scale out using Scanner is via `kubernetes `__.
7 | Kubernetes is tool for automating the deployment and management of a cluster of
8 | machines that run `containers `__
9 | (a container is akin to a light-weight VM image).
10 |
11 | We provide a step-by-step example of getting Scanner up and running on your own
12 | kubernetes cluster using either `Google Cloud Platform `__
13 | or `Amazon Web Services `__.
14 |
--------------------------------------------------------------------------------
/tests/spawn_worker.py:
--------------------------------------------------------------------------------
1 | from scannerpy import protobufs, Config, start_worker
2 | import time
3 | import grpc
4 | import sys
5 |
6 | c = Config(None)
7 |
8 | import scanner.metadata_pb2 as metadata_types
9 | import scanner.engine.rpc_pb2 as rpc_types
10 | import scanner.types_pb2 as misc_types
11 | import scannerpy._python as bindings
12 |
13 | con = Config(config_path='/tmp/config_test')
14 |
15 | master_address = str(con.master_address) + ':' + str(con.master_port)
16 | port = int(sys.argv[1])
17 |
18 | params = bindings.default_machine_params()
19 | mp = protobufs.MachineParameters()
20 | mp.ParseFromString(params)
21 | del mp.gpu_ids[:]
22 | params = mp.SerializeToString()
23 |
24 | start_worker(master_address, machine_params=params, config=con, block=True,
25 | port=port,
26 | watchdog=False)
27 |
--------------------------------------------------------------------------------
/scanner/doxygen.md:
--------------------------------------------------------------------------------
1 | API Overview {#mainpage}
2 | =========
3 |
4 | This is the auto-generated documentation for Scanner's C++ API. You should look here if you are implementing a C++ kernel and want to see, for example, what functions a kernel is expected to implement.
5 |
6 | * Custom kernels: [scanner::BaseKernel](@ref scanner::BaseKernel) and [scanner::Kernel](@ref scanner::Kernel)
7 | * Stream elements: [scanner::Element](@ref scanner::Element) and [scanner::Frame](@ref scanner::Frame)
8 | * Custom sources: [scanner::Source](@ref scanner::Source) and [scanner::Enumerator](@ref scanner::Enumerator)
9 | * Custom sources: [scanner::Sink](@ref scanner::Sink)
10 | * Profiling: [scanner::Profiler](@ref scanner::Profiler)
11 |
12 | System internals are not well documented, please read the source code or contact the authors if you have questions about that.
13 |
--------------------------------------------------------------------------------
/examples/how-tos/python_kernel/python.py:
--------------------------------------------------------------------------------
1 | import scannerpy
2 | import os
3 | import struct
4 |
5 | from scannerpy import Database, Job, FrameType, DeviceType, Kernel
6 | from typing import Tuple
7 |
8 | @scannerpy.register_python_op()
9 | class MyOpKernel(Kernel):
10 | def __init__(self, config, protobufs):
11 | self.protobufs = protobufs
12 |
13 | def close(self):
14 | pass
15 |
16 | def execute(self, frame: FrameType) -> bytes:
17 | return struct.pack('=q', 9000)
18 |
19 |
20 | with Database() as db:
21 | frame = db.sources.FrameColumn()
22 | test = db.ops.MyOp(frame=frame)
23 | output = db.sinks.Column(columns={'test': test})
24 |
25 | job = Job(op_args={
26 | frame: db.table('example').column('frame'),
27 | output: 'example_py'
28 | })
29 | db.run(output=output, jobs=[job])
30 |
--------------------------------------------------------------------------------
/cmake/Modules/FindNVCUVID.cmake:
--------------------------------------------------------------------------------
1 | # - Try to find NVCUVID
2 | #
3 | # The following variables are optionally searched for defaults
4 | # NVCUVID_DIR: Base directory where NVCUVID can be found
5 | #
6 | # The following are set after configuration is done:
7 | # NVCUVID_FOUND
8 | # NVCUVID_LIBRARY
9 |
10 | include(FindPackageHandleStandardArgs)
11 |
12 | set(NVCUVID_ROOT_DIR "" CACHE PATH "Folder contains NVCUVID")
13 |
14 | if (NOT "$ENV{NVCUVID_DIR}" STREQUAL "")
15 | set(NVCUVID_ROOT_DIR
16 | $ENV{NVCUVID_DIR} CACHE PATH "Folder contains NVCUVID" FORCE)
17 | endif()
18 |
19 | find_library(NVCUVID_LIBRARY nvcuvid
20 | PATHS
21 | ${NVCUVID_ROOT_DIR}/lib
22 | /usr/local/cuda/lib64)
23 |
24 | find_package_handle_standard_args(NVCUVID DEFAULT_MSG NVCUVID_LIBRARY)
25 |
26 | if(NVCUVID_FOUND)
27 | set(NVCUVID_LIBRARIES ${NVCUVID_LIBRARY})
28 | endif()
29 |
--------------------------------------------------------------------------------
/scanner/engine/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | get_property(dirs DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
2 | configure_file(build_flags.in.cpp build_flags.cpp)
3 |
4 | add_executable(build_flags build_flags.cpp)
5 |
6 | set(SOURCE_FILES
7 | runtime.cpp
8 | master.cpp
9 | worker.cpp
10 | ingest.cpp
11 | video_index_entry.cpp
12 | load_worker.cpp
13 | evaluate_worker.cpp
14 | save_worker.cpp
15 | sampler.cpp
16 | dag_analysis.cpp
17 | metadata.cpp
18 | kernel_registry.cpp
19 | op_registry.cpp
20 | source_registry.cpp
21 | sink_registry.cpp
22 | column_source.cpp
23 | column_enumerator.cpp
24 | column_sink.cpp
25 | enumerator_registry.cpp
26 | table_meta_cache.cpp
27 | python_kernel.cpp
28 | sample_op.cpp
29 | space_op.cpp
30 | slice_op.cpp
31 | unslice_op.cpp)
32 |
33 | add_library(engine OBJECT
34 | ${SOURCE_FILES})
35 |
--------------------------------------------------------------------------------
/tests/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | find_package(OpenCV COMPONENTS core imgproc highgui video)
2 |
3 | if (OpenCV_FOUND)
4 | include(${CMAKE_SOURCE_DIR}/cmake/Util/Op.cmake)
5 | build_op(LIB_NAME scanner_tests CPP_SRCS test_ops.cpp PROTO_SRC test_ops.proto NO_FLAGS ON)
6 |
7 | target_link_libraries(scanner_tests PUBLIC ${OpenCV_LIBRARIES} scanner)
8 | target_include_directories(scanner_tests PUBLIC ${OpenCV_INCLUDE_DIR})
9 |
10 | add_test(
11 | NAME PythonTests
12 | COMMAND pytest ${CMAKE_CURRENT_SOURCE_DIR} -x -vv)
13 | else()
14 | message("Scanner tests are disabled. OpenCV not found which is required for building the tests.")
15 | endif()
16 |
17 | if (NO_FFMPEG STREQUAL "false")
18 | add_executable(FfmpegTest ffmpeg_test.cpp)
19 | target_link_libraries(FfmpegTest ${GTEST_LIBRARIES} ${GTEST_LIB_MAIN} scanner)
20 | add_test(FfmpegTests FfmpegTest)
21 | endif()
22 |
--------------------------------------------------------------------------------
/docker/ubuntu16.04/Dockerfile.gpu9:
--------------------------------------------------------------------------------
1 | # Scanner base GPU image for Ubuntu 16.04 CUDA 9.X
2 |
3 | ARG base_tag
4 | FROM ${base_tag}
5 | MAINTAINER Will Crichton "wcrichto@cs.stanford.edu"
6 | ARG cores=1
7 |
8 | ADD thirdparty/resources/cuda/libnvcuvid.so.387.26 /usr/lib/x86_64-linux-gnu/libnvcuvid.so
9 | RUN ln -s /usr/local/cuda/targets/x86_64-linux/lib/stubs/libcuda.so \
10 | /usr/local/cuda/targets/x86_64-linux/lib/stubs/libcuda.so.1
11 | ENV CUDA_LIB_PATH /usr/local/cuda/lib64/stubs
12 |
13 | RUN bash ./deps.sh --root-install --install-all --prefix /usr/local --use-gpu && \
14 | rm -rf /opt/scanner-base
15 |
16 | ENV LD_LIBRARY_PATH /usr/local/intel/mkl/lib:${LD_LIBRARY_PATH}
17 | ENV PYTHONPATH /usr/local/python:${PYTHONPATH}
18 | ENV PYTHONPATH /usr/local/lib/python3.5/site-packages:${PYTHONPATH}
19 | ENV PYTHONPATH /usr/local/lib/python3.5/dist-packages:${PYTHONPATH}
20 |
21 | WORKDIR /
22 |
--------------------------------------------------------------------------------
/scanner/util/glog.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2017 Carnegie Mellon University
2 | *
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | */
15 |
16 | #pragma once
17 |
18 | #include "glog/logging.h"
19 |
20 | #include
21 | #include
22 | #include
23 |
24 | namespace scanner {
25 |
26 | void init_glog(const char* program_name);
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/docker/ubuntu16.04/Dockerfile.gpu10:
--------------------------------------------------------------------------------
1 | # Scanner base GPU image for Ubuntu 16.04 CUDA 10.X
2 |
3 | ARG base_tag
4 | FROM ${base_tag}
5 | MAINTAINER Will Crichton "wcrichto@cs.stanford.edu"
6 | ARG cores=1
7 |
8 | ADD thirdparty/resources/cuda/libnvcuvid.so.387.26 /usr/lib/x86_64-linux-gnu/libnvcuvid.so
9 | RUN ln -s /usr/local/cuda/targets/x86_64-linux/lib/stubs/libcuda.so \
10 | /usr/local/cuda/targets/x86_64-linux/lib/stubs/libcuda.so.1
11 | ENV CUDA_LIB_PATH /usr/local/cuda/lib64/stubs
12 |
13 | RUN bash ./deps.sh --root-install --install-all --prefix /usr/local --use-gpu && \
14 | rm -rf /opt/scanner-base
15 |
16 | ENV LD_LIBRARY_PATH /usr/local/intel/mkl/lib:${LD_LIBRARY_PATH}
17 | ENV PYTHONPATH /usr/local/python:${PYTHONPATH}
18 | ENV PYTHONPATH /usr/local/lib/python3.5/site-packages:${PYTHONPATH}
19 | ENV PYTHONPATH /usr/local/lib/python3.5/dist-packages:${PYTHONPATH}
20 |
21 | WORKDIR /
22 |
--------------------------------------------------------------------------------
/docker/ubuntu16.04/Dockerfile.gpu8:
--------------------------------------------------------------------------------
1 | # Scanner base GPU image for Ubuntu 16.04 CUDA 8.0
2 |
3 | ARG base_tag
4 | FROM ${base_tag}
5 | MAINTAINER Will Crichton "wcrichto@cs.stanford.edu"
6 | ARG cores=1
7 |
8 | ADD thirdparty/resources/cuda/libnvcuvid.so.367.48 /usr/lib/x86_64-linux-gnu/libnvcuvid.so
9 | RUN ln -s /usr/local/cuda-8.0/targets/x86_64-linux/lib/stubs/libcuda.so \
10 | /usr/local/cuda-8.0/targets/x86_64-linux/lib/stubs/libcuda.so.1
11 | ENV CUDA_LIB_PATH /usr/local/cuda/lib64/stubs
12 |
13 | RUN bash ./deps.sh --root-install --install-all --prefix /usr/local --use-gpu && \
14 | rm -rf /opt/scanner-base
15 |
16 | ENV LD_LIBRARY_PATH /usr/local/intel/mkl/lib:${LD_LIBRARY_PATH}
17 | ENV PYTHONPATH /usr/local/python:${PYTHONPATH}
18 | ENV PYTHONPATH /usr/local/lib/python3.5/site-packages:${PYTHONPATH}
19 | ENV PYTHONPATH /usr/local/lib/python3.5/dist-packages:${PYTHONPATH}
20 |
21 | WORKDIR /
22 |
--------------------------------------------------------------------------------
/python/scannerpy/io.py:
--------------------------------------------------------------------------------
1 | from scannerpy.common import ScannerException
2 | from scannerpy.storage import StoredStream
3 |
4 | class IOGenerator:
5 | def __init__(self, sc):
6 | self._sc = sc
7 |
8 | def Input(self, streams):
9 | if not isinstance(streams, list) or not isinstance(streams[0], StoredStream):
10 | raise ScannerException("io.Input must take a list of streams as input")
11 |
12 | example = streams[0]
13 | source = example.storage().source(self._sc, streams)
14 | source._streams = streams
15 | return source
16 |
17 | def Output(self, op, streams):
18 | if not isinstance(streams, list) or not isinstance(streams[0], StoredStream):
19 | raise ScannerException("io.Output must take a list of streams as input")
20 |
21 | example = streams[0]
22 | sink = example.storage().sink(self._sc, op, streams)
23 | sink._streams = streams
24 | return sink
25 |
--------------------------------------------------------------------------------
/scanner/sampler_args.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package scanner.proto;
4 |
5 | // Sampler args
6 | message StridedSamplerArgs {
7 | int64 stride = 1;
8 | }
9 |
10 | message StridedRangeSamplerArgs {
11 | int64 stride = 1;
12 | repeated int64 starts = 2;
13 | repeated int64 ends = 3;
14 | }
15 |
16 | message GatherSamplerArgs {
17 | repeated int64 rows = 1 [packed=true];
18 | }
19 |
20 |
21 | message SpaceNullSamplerArgs {
22 | int64 spacing = 1;
23 | }
24 |
25 | message SpaceRepeatSamplerArgs {
26 | int64 spacing = 1;
27 | }
28 |
29 | message StridedPartitionerArgs {
30 | int64 stride = 1;
31 | int64 group_size = 2;
32 | }
33 |
34 | message StridedRangePartitionerArgs {
35 | int64 stride = 1;
36 | repeated int64 starts = 2;
37 | repeated int64 ends = 3;
38 | }
39 |
40 | message GatherPartitionerArgs {
41 | message GatherList {
42 | repeated int64 rows = 1 [packed=true];
43 | }
44 |
45 | repeated GatherList groups = 1;
46 | }
47 |
--------------------------------------------------------------------------------
/cmake/Modules/FindHwang.cmake:
--------------------------------------------------------------------------------
1 | # FindHwang.cmake
2 |
3 | set(HWANG_ROOT_DIR "" CACHE PATH "Folder contains Hwang")
4 |
5 | if (NOT "$ENV{Hwang_DIR}" STREQUAL "")
6 | set(HWANG_ROOT_DIR $ENV{Hwang_DIR} CACHE PATH "Folder contains Hwang"
7 | FORCE)
8 | elseif (Hwang_DIR)
9 | set(HWANG_ROOT_DIR ${Hwang_DIR} CACHE PATH "Folder contains Hwang"
10 | FORCE)
11 | endif()
12 |
13 | find_library(HWANG_LIBRARIES
14 | NAMES hwang
15 | HINTS ${HWANG_ROOT_DIR}/lib
16 | )
17 |
18 | find_path(HWANG_INCLUDE_DIR
19 | NAMES hwang/common.h
20 | HINTS ${HWANG_ROOT_DIR}/include
21 | )
22 |
23 | include(FindPackageHandleStandardArgs)
24 | find_package_handle_standard_args(Hwang DEFAULT_MSG
25 | HWANG_LIBRARIES
26 | HWANG_INCLUDE_DIR
27 | )
28 |
29 | set(HWANG_LIBRARY ${HWANG_LIBRARIES})
30 | set(HWANG_INCLUDE_DIRS ${HWANG_INCLUDE_DIR})
31 |
32 | mark_as_advanced(
33 | HWANG_ROOT_DIR
34 | HWANG_LIBRARY
35 | HWANG_LIBRARIES
36 | HWANG_INCLUDE_DIR
37 | HWANG_INCLUDE_DIRS
38 | )
39 |
--------------------------------------------------------------------------------
/docs/Makefile:
--------------------------------------------------------------------------------
1 | # Minimal makefile for Sphinx documentation
2 | #
3 |
4 | # You can set these variables from the command line.
5 | SPHINXOPTS =
6 | SPHINXBUILD = sphinx-build
7 | SPHINXPROJ = scanner
8 | SOURCEDIR = .
9 | BUILDDIR = ../build/docs
10 |
11 | # Put it first so that "make" without argument is like "make help".
12 | help:
13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14 |
15 | .PHONY: help Makefile
16 |
17 | # Catch-all target: route all unknown targets to Sphinx using the new
18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19 | %: Makefile
20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
21 |
22 | serve: autobuild notifywait
23 |
24 | autobuild:
25 | sphinx-autobuild "$(SOURCEDIR)" $(BUILDDIR)/html -b html $(SPHINXOPTS) $(O) -j `nproc` -p 4567 -H 0.0.0.0
26 |
27 | notifywait:
28 | inotifywait -e close_write,moved_to,create -mr . --format '%f' | while read FILE; do echo $${FILE}; done
29 |
--------------------------------------------------------------------------------
/docs/api.rst:
--------------------------------------------------------------------------------
1 | API Reference
2 | =============
3 |
4 | Scanner has three main components to its API:
5 |
6 | * The :ref:`Scanner Python API `, for defining/executing computation graphs and Python kernels
7 | * The :ref:`Scannertools API `, a standard library of pre-made kernels
8 | * The `Scanner C++ API `_, for defining C++ kernels
9 |
10 | scannerpy - the main scanner API
11 | --------------------------------
12 |
13 | * :any:`scannerpy.client`: entrypoint for running computation graphs, similar to TensorFlow Session
14 | * :any:`scannerpy.kernel`: defining custom Python kernels
15 | * :any:`scannerpy.storage`: defining custom inputs/outputs to Scanner graphs
16 | * :any:`scannerpy.kube`: Kubernetes API
17 | * :any:`scannerpy.profiler`: handle to profiling data output by Scanner
18 |
19 | scannertools - the Scanner standard library
20 | -------------------------------------------
21 |
22 | .. toctree::
23 | :maxdepth: 3
24 |
25 | api/scannertools
26 |
--------------------------------------------------------------------------------
/scanner/util/glog.cpp:
--------------------------------------------------------------------------------
1 | /* Copyright 2017 Carnegie Mellon University
2 | *
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | */
15 |
16 | #include "glog/logging.h"
17 |
18 | #include
19 |
20 | namespace scanner {
21 | namespace {
22 | std::atomic_flag glog_initialized;
23 | }
24 |
25 | void init_glog(const char* prog_name) {
26 | if (!glog_initialized.test_and_set()) {
27 | google::InitGoogleLogging(prog_name);
28 | }
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/examples/tutorials/resize_op/Makefile:
--------------------------------------------------------------------------------
1 | # Scanner outputs build flags that add Scanner to your library and include paths
2 | # as well as cover common flags for building a shared library.
3 | SCANNER_CFLAGS = `python3 -c "import scannerpy.build_flags as b; b.print_compile_flags()"`
4 | SCANNER_LD_FLAGS = `python3 -c "import scannerpy.build_flags as b; b.print_link_flags()"`
5 |
6 | # Change this to wherever you installed deps.sh to
7 | INSTALL_DIR=../../../thirdparty/install
8 |
9 | all: build/libresize_op.so
10 |
11 | clean:
12 | rm -rf build/*
13 |
14 | # protoc generates the Python and C++ bindings for the ResizeArgs class.
15 | build/resize.pb.cc: resize.proto
16 | protoc resize.proto --python_out=build --cpp_out=build
17 |
18 | # g++ builds the op library
19 | build/libresize_op.so: build/resize.pb.cc resize_op.cpp
20 | g++ -shared -fPIC $^ -o $@ ${SCANNER_CFLAGS} ${SCANNER_LD_FLAGS} \
21 | -I ${INSTALL_DIR}/include -I build \
22 | -L ${INSTALL_DIR}/lib -lprotobuf -lglog -lopencv_core -lopencv_imgproc
23 |
24 | .PHONY: clean
25 |
--------------------------------------------------------------------------------
/cmake/Modules/FindHalide.cmake:
--------------------------------------------------------------------------------
1 | # FindHalide.cmake
2 | # ... shamelessly based on FindJeMalloc.cmake
3 |
4 | set(HALIDE_ROOT_DIR "" CACHE PATH "Folder contains Halide")
5 |
6 | if (NOT "$ENV{Halide_DIR}" STREQUAL "")
7 | set(HALIDE_ROOT_DIR $ENV{Halide_DIR} CACHE PATH "Folder contains Halide"
8 | FORCE)
9 | elseif (Halide_DIR)
10 | set(HALIDE_ROOT_DIR ${Halide_DIR} CACHE PATH "Folder contains Halide"
11 | FORCE)
12 | endif()
13 |
14 | find_library(HALIDE_LIBRARIES
15 | NAMES Halide
16 | HINTS ${HALIDE_ROOT_DIR}/lib
17 | )
18 |
19 | find_path(HALIDE_INCLUDE_DIR
20 | NAMES Halide.h HalideRuntime.h
21 | HINTS ${HALIDE_ROOT_DIR}/include
22 | )
23 |
24 | include(FindPackageHandleStandardArgs)
25 | find_package_handle_standard_args(Halide DEFAULT_MSG
26 | HALIDE_LIBRARIES
27 | HALIDE_INCLUDE_DIR
28 | )
29 |
30 | set(HALIDE_LIBRARY ${HALIDE_LIBRARIES})
31 | set(HALIDE_INCLUDE_DIRS ${HALIDE_INCLUDE_DIR})
32 |
33 | mark_as_advanced(
34 | HALIDE_ROOT_DIR
35 | HALIDE_LIBRARY
36 | HALIDE_LIBRARIES
37 | HALIDE_INCLUDE_DIR
38 | HALIDE_INCLUDE_DIRS
39 | )
40 |
--------------------------------------------------------------------------------
/docker/Dockerfile.scanner:
--------------------------------------------------------------------------------
1 | ARG tag=gpu
2 | FROM scannerresearch/scanner-base:ubuntu16.04-${tag}
3 | MAINTAINER Will Crichton "wcrichto@cs.stanford.edu"
4 | ARG cores=1
5 | ARG gpu=ON
6 | ARG deps_opt=''
7 |
8 | ADD . /opt/scanner
9 | WORKDIR /opt/scanner
10 | ENV Caffe_DIR /usr/local
11 | ENV LD_LIBRARY_PATH \
12 | "/usr/lib/x86_64-linux-gnu:/usr/local/cuda/lib64:$LD_LIBRARY_PATH:/usr/local/cuda/lib64/stubs"
13 | ENV PKG_CONFIG_PATH "/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
14 | RUN cd /opt/scanner && \
15 | (if [ "${gpu}" = "ON" ]; then \
16 | bash deps.sh -g --install-none --prefix /usr/local ${deps_opt}; \
17 | else \
18 | bash deps.sh -ng --install-none --prefix /usr/local ${deps_opt}; \
19 | fi) && \
20 | mkdir build && cd build && \
21 | cmake -D BUILD_TESTS=ON \
22 | -D BUILD_CUDA=${gpu} \
23 | -D CMAKE_BUILD_TYPE=RelWithDebinfo \
24 | .. && \
25 | cd .. && \
26 | (yes | pip3 uninstall grpcio protobuf) && \
27 | bash ./build.sh && \
28 | ldconfig
29 |
30 | ENV LC_ALL C.UTF-8
31 | ENV LANG C.UTF-8
32 |
--------------------------------------------------------------------------------
/cmake/Modules/FindEigen.cmake:
--------------------------------------------------------------------------------
1 | # - Try to find Eigen
2 | #
3 | # The following variables are optionally searched for defaults
4 | # EIGEN_ROOT_DIR: Base directory where all Eigen components are found
5 | #
6 | # The following are set after configuration is done:
7 | # EIGEN_FOUND
8 | # EIGEN_INCLUDE_DIRS
9 |
10 | include(FindPackageHandleStandardArgs)
11 |
12 | set(EIGEN_ROOT_DIR "" CACHE PATH "Folder contains Eigen")
13 |
14 | if (NOT "$ENV{Eigen_DIR}" STREQUAL "")
15 | set(EIGEN_ROOT_DIR $ENV{Eigen_DIR} CACHE PATH "Folder contains Eigen" FORCE)
16 | endif()
17 |
18 | # We are testing only a couple of files in the include directories
19 | if(WIN32)
20 | find_path(EIGEN_INCLUDE_DIR Eigen/Core
21 | PATHS ${EIGEN_ROOT_DIR}/src/windows
22 | PATH_SUFFIXES eigen3)
23 | else()
24 | find_path(EIGEN_INCLUDE_DIR Eigen/Core
25 | PATHS ${EIGEN_ROOT_DIR}/include
26 | PATH_SUFFIXES eigen3)
27 |
28 | endif()
29 |
30 | find_package_handle_standard_args(EIGEN DEFAULT_MSG EIGEN_INCLUDE_DIR)
31 |
32 | if(EIGEN_FOUND)
33 | set(EIGEN_INCLUDE_DIRS ${EIGEN_INCLUDE_DIR})
34 | endif()
35 |
--------------------------------------------------------------------------------
/examples/tutorials/resize_op/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # To build your custom op, you can either use our CMake convenience methods
2 | # or do it the slightly harder way in normal Make (see the Makefile).
3 |
4 | cmake_minimum_required(VERSION 3.2.0 FATAL_ERROR)
5 |
6 | execute_process(
7 | OUTPUT_VARIABLE SCANNER_CMAKE_PATH
8 | COMMAND python3 -c "import scannerpy.build_flags as b; b.print_cmake()")
9 | include(${SCANNER_CMAKE_PATH})
10 |
11 | # build_op will create a shared library called lib${LIB_NAME}.so that builds
12 | # from all of the CPP_SRCS. You can also optionally specify a PROTO_SRC that
13 | # points to a Protobuf file and will generate the C++ and Python bindings.
14 | build_op(
15 | LIB_NAME resize_op
16 | CPP_SRCS resize_op.cpp
17 | PROTO_SRC resize.proto)
18 |
19 | # The library specified in build_op is a normal CMake target, so you can use all
20 | # the normal CMake functions with it.
21 | find_package(OpenCV REQUIRED COMPONENTS core imgproc)
22 | target_include_directories(resize_op PUBLIC ${OpenCV_INCLUDE_DIRS})
23 | target_link_libraries(resize_op PUBLIC ${OpenCV_LIBRARIES})
24 |
--------------------------------------------------------------------------------
/scanner/engine/slice_op.cpp:
--------------------------------------------------------------------------------
1 | #include "scanner/api/kernel.h"
2 | #include "scanner/api/op.h"
3 | #include "scanner/util/memory.h"
4 |
5 | namespace scanner {
6 |
7 | // Dummy Kernel
8 | class SliceKernel : public BatchedKernel {
9 | public:
10 | SliceKernel(const KernelConfig& config)
11 | : BatchedKernel(config) {}
12 |
13 | void execute(const BatchedElements& input_columns,
14 | BatchedElements& output_columns) override {
15 | // No implementation
16 | }
17 | };
18 |
19 |
20 | // Reserve Op name as builtin
21 | REGISTER_OP(Slice).input("col").output("out");
22 |
23 | REGISTER_KERNEL(Slice, SliceKernel).device(DeviceType::CPU).num_devices(1);
24 |
25 | REGISTER_KERNEL(Slice, SliceKernel).device(DeviceType::GPU).num_devices(1);
26 |
27 |
28 | REGISTER_OP(SliceFrame).frame_input("col").frame_output("out");
29 |
30 | REGISTER_KERNEL(SliceFrame, SliceKernel)
31 | .device(DeviceType::CPU)
32 | .batch()
33 | .num_devices(1);
34 |
35 | REGISTER_KERNEL(SliceFrame, SliceKernel)
36 | .device(DeviceType::GPU)
37 | .batch()
38 | .num_devices(1);
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/scanner/video/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | set(SOURCE_FILES
2 | h264_byte_stream_index_creator.cpp
3 | decoder_automata.cpp
4 | video_decoder.cpp
5 | video_encoder.cpp)
6 |
7 | if (BUILD_CUDA)
8 | add_definitions(-DHAVE_NVIDIA_VIDEO_HARDWARE)
9 | list(APPEND SOURCE_FILES
10 | nvidia/nvidia_video_decoder.cpp)
11 | endif()
12 |
13 | if (MFX_FOUND)
14 | add_definitions(-DHAVE_INTEL_VIDEO_HARDWARE)
15 | list(APPEND SOURCE_FILES
16 | intel/intel_video_decoder.cpp)
17 | endif()
18 |
19 | if (NO_FFMPEG STREQUAL "false")
20 | list(APPEND SOURCE_FILES
21 | software/software_video_decoder.cpp
22 | software/software_video_encoder.cpp)
23 | endif()
24 |
25 | add_library(video OBJECT
26 | ${SOURCE_FILES})
27 |
28 | set_source_files_properties(${PROTO_SRCS} ${GRPC_PROTO_SRCS} PROPERTIES
29 | GENERATED TRUE)
30 |
31 | # TODO(apoms): fix since change in decoder API
32 | # add_executable(DecoderAutomataTest decoder_automata_test.cpp)
33 | # target_link_libraries(DecoderAutomataTest
34 | # ${GTEST_LIBRARIES} ${GTEST_LIB_MAIN}
35 | # scanner)
36 | # add_test(DecoderAutomataTest DecoderAutomataTest)
37 |
--------------------------------------------------------------------------------
/scanner/engine/sample_op.cpp:
--------------------------------------------------------------------------------
1 | #include "scanner/api/kernel.h"
2 | #include "scanner/api/op.h"
3 | #include "scanner/util/memory.h"
4 |
5 | namespace scanner {
6 |
7 | // Dummy Kernel
8 | class SampleKernel : public BatchedKernel {
9 | public:
10 | SampleKernel(const KernelConfig& config)
11 | : BatchedKernel(config) {}
12 |
13 | void execute(const BatchedElements& input_columns,
14 | BatchedElements& output_columns) override {
15 | // No implementation
16 | }
17 | };
18 |
19 |
20 | // Reserve Op name as builtin
21 | REGISTER_OP(Sample).input("col").output("out");
22 |
23 | REGISTER_KERNEL(Sample, SampleKernel).device(DeviceType::CPU).num_devices(1);
24 |
25 | REGISTER_KERNEL(Sample, SampleKernel).device(DeviceType::GPU).num_devices(1);
26 |
27 |
28 | REGISTER_OP(SampleFrame).frame_input("col").frame_output("out");
29 |
30 | REGISTER_KERNEL(SampleFrame, SampleKernel)
31 | .device(DeviceType::CPU)
32 | .batch()
33 | .num_devices(1);
34 |
35 | REGISTER_KERNEL(SampleFrame, SampleKernel)
36 | .device(DeviceType::GPU)
37 | .batch()
38 | .num_devices(1);
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/scanner/engine/unslice_op.cpp:
--------------------------------------------------------------------------------
1 | #include "scanner/api/kernel.h"
2 | #include "scanner/api/op.h"
3 | #include "scanner/util/memory.h"
4 |
5 | namespace scanner {
6 |
7 | // Dummy Kernel
8 | class UnsliceKernel : public BatchedKernel {
9 | public:
10 | UnsliceKernel(const KernelConfig& config)
11 | : BatchedKernel(config) {}
12 |
13 | void execute(const BatchedElements& input_columns,
14 | BatchedElements& output_columns) override {
15 | // No implementation
16 | }
17 | };
18 |
19 |
20 | // Reserve Op name as builtin
21 | REGISTER_OP(Unslice).input("col").output("out");
22 |
23 | REGISTER_KERNEL(Unslice, UnsliceKernel).device(DeviceType::CPU).num_devices(1);
24 |
25 | REGISTER_KERNEL(Unslice, UnsliceKernel).device(DeviceType::GPU).num_devices(1);
26 |
27 |
28 | REGISTER_OP(UnsliceFrame).frame_input("col").frame_output("out");
29 |
30 | REGISTER_KERNEL(UnsliceFrame, UnsliceKernel)
31 | .device(DeviceType::CPU)
32 | .batch()
33 | .num_devices(1);
34 |
35 | REGISTER_KERNEL(UnsliceFrame, UnsliceKernel)
36 | .device(DeviceType::GPU)
37 | .batch()
38 | .num_devices(1);
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/examples/how-tos/halide/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.2.0 FATAL_ERROR)
2 |
3 | # Uncomment the line below and change the Scanner path to the repo you cloned:
4 | # set(SCANNER_PATH /path/to/scanner)
5 | if(NOT SCANNER_PATH)
6 | message(FATAL_ERROR "You need to update the SCANNER_PATH in halide/CMakeLists.txt first.")
7 | endif()
8 | include(${SCANNER_PATH}/cmake/Util/Op.cmake)
9 |
10 | find_package(Halide REQUIRED)
11 | include(${SCANNER_PATH}/cmake/Util/HalideGenerator.cmake)
12 |
13 | halide_add_generator(halide_resize.generator SRCS halide_resize.cpp)
14 | halide_add_aot_library(halide_resize
15 | GENERATOR_TARGET halide_resize.generator
16 | GENERATOR_ARGS target=cuda)
17 |
18 | build_op(
19 | LIB_NAME resize
20 | CPP_SRCS resize_op.cpp
21 | PROTO_SRC resize.proto)
22 | target_compile_definitions(resize PUBLIC -DHAVE_CUDA)
23 |
24 | add_dependencies(resize halide_resize.exec_generator)
25 | target_include_directories(resize PUBLIC "${HALIDE_INCLUDE_DIR}")
26 | target_include_directories(resize PUBLIC "${PROJECT_BINARY_DIR}/generator_genfiles")
27 | halide_add_aot_library_dependency(resize halide_resize)
28 |
--------------------------------------------------------------------------------
/scanner/engine/space_op.cpp:
--------------------------------------------------------------------------------
1 | #include "scanner/api/kernel.h"
2 | #include "scanner/api/op.h"
3 | #include "scanner/util/memory.h"
4 |
5 | namespace scanner {
6 |
7 | // Dummy Kernel
8 | class SpaceKernel : public BatchedKernel {
9 | public:
10 | SpaceKernel(const KernelConfig& config)
11 | : BatchedKernel(config) {}
12 |
13 | void execute(const BatchedElements& input_columns,
14 | BatchedElements& output_columns) override {
15 | // No implementation
16 | }
17 | };
18 |
19 |
20 | // Reserve Op name as builtin
21 | REGISTER_OP(Space).input("col").output("out");
22 |
23 | REGISTER_KERNEL(Space, SpaceKernel)
24 | .device(DeviceType::CPU)
25 | .batch()
26 | .num_devices(1);
27 |
28 | REGISTER_KERNEL(Space, SpaceKernel)
29 | .device(DeviceType::GPU)
30 | .batch()
31 | .num_devices(1);
32 |
33 | REGISTER_OP(SpaceFrame).frame_input("col").frame_output("out");
34 |
35 | REGISTER_KERNEL(spaceFrame, SpaceKernel)
36 | .device(DeviceType::CPU)
37 | .batch()
38 | .num_devices(1);
39 |
40 | REGISTER_KERNEL(SpaceFrame, SpaceKernel)
41 | .device(DeviceType::GPU)
42 | .batch()
43 | .num_devices(1);
44 | }
45 |
--------------------------------------------------------------------------------
/examples/apps/gcp_kubernetes/master.yml.template:
--------------------------------------------------------------------------------
1 | apiVersion: apps/v1beta1
2 | kind: Deployment
3 | metadata:
4 | name: scanner-master
5 | spec:
6 | replicas: 1
7 | template:
8 | metadata:
9 | labels:
10 | app: scanner-master
11 | spec:
12 | containers:
13 | - name: scanner-master
14 | image: gcr.io/YOUR_PROJECT_ID/scanner-master:cpu
15 | imagePullPolicy: Always
16 | env:
17 | - name: AWS_ACCESS_KEY_ID
18 | valueFrom:
19 | secretKeyRef:
20 | name: aws-storage-key
21 | key: AWS_ACCESS_KEY_ID
22 | - name: AWS_SECRET_ACCESS_KEY
23 | valueFrom:
24 | secretKeyRef:
25 | name: aws-storage-key
26 | key: AWS_SECRET_ACCESS_KEY
27 | - name: GLOG_logtostderr
28 | value: '1'
29 | - name: GLOG_minloglevel
30 | value: '0'
31 | - name: GLOG_v
32 | value: '2'
33 | ports:
34 | - containerPort: 8080
35 | nodeSelector:
36 | cloud.google.com/gke-nodepool: default-pool
37 |
--------------------------------------------------------------------------------
/examples/apps/gcp_kubernetes/worker.yml.template:
--------------------------------------------------------------------------------
1 | apiVersion: apps/v1beta1
2 | kind: Deployment
3 | metadata:
4 | name: scanner-worker
5 | spec:
6 | replicas: 3
7 | template:
8 | metadata:
9 | labels:
10 | app: scanner-worker
11 | spec:
12 | containers:
13 | - name: scanner-worker
14 | image: gcr.io/YOUR_PROJECT_ID/scanner-worker:cpu
15 | imagePullPolicy: Always
16 | env:
17 | - name: AWS_ACCESS_KEY_ID
18 | valueFrom:
19 | secretKeyRef:
20 | name: aws-storage-key
21 | key: AWS_ACCESS_KEY_ID
22 | - name: AWS_SECRET_ACCESS_KEY
23 | valueFrom:
24 | secretKeyRef:
25 | name: aws-storage-key
26 | key: AWS_SECRET_ACCESS_KEY
27 | - name: GLOG_logtostderr
28 | value: '1'
29 | - name: GLOG_minloglevel
30 | value: '0'
31 | - name: GLOG_v
32 | value: '2'
33 | resources:
34 | requests:
35 | cpu: 1.1
36 | nodeSelector:
37 | cloud.google.com/gke-nodepool: workers
38 |
--------------------------------------------------------------------------------
/python/scannerpy/build_flags.py:
--------------------------------------------------------------------------------
1 | import os.path
2 | import sys
3 |
4 | SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
5 |
6 | def get_grpc_version():
7 | with open(os.path.abspath(os.path.join(SCRIPT_DIR, 'cmake', 'grpc_version.txt')), 'r') as f:
8 | return f.read()
9 |
10 | def get_include():
11 | return os.path.abspath(os.path.join(SCRIPT_DIR, 'include'))
12 |
13 | def print_include():
14 | sys.stdout.write(get_include())
15 |
16 | def get_lib():
17 | return os.path.abspath(os.path.join(SCRIPT_DIR, 'lib'))
18 |
19 | def print_lib():
20 | sys.stdout.write(get_lib())
21 |
22 | def get_cmake():
23 | return os.path.abspath(os.path.join(SCRIPT_DIR, 'cmake', 'Op.cmake'))
24 |
25 | def print_cmake():
26 | sys.stdout.write(get_cmake())
27 |
28 | def get_compile_flags():
29 | return (
30 | '-std=c++14 -I{include}'.format(
31 | include=get_include()))
32 |
33 | def get_link_flags():
34 | return (
35 | '-L{libdir} -lscanner'.format(
36 | libdir=get_lib()))
37 |
38 | def print_compile_flags():
39 | sys.stdout.write(get_compile_flags())
40 |
41 | def print_link_flags():
42 | sys.stdout.write(get_link_flags())
43 |
--------------------------------------------------------------------------------
/scanner/engine/python_kernel.h:
--------------------------------------------------------------------------------
1 | #include "scanner/api/kernel.h"
2 | #include "scanner/api/op.h"
3 | #include "scanner/util/memory.h"
4 | #include "scanner/metadata.pb.h"
5 |
6 | namespace scanner {
7 |
8 | class PythonKernel : public StenciledBatchedKernel {
9 | public:
10 | PythonKernel(const KernelConfig& config,
11 | const std::string& op_name,
12 | const std::string& kernel_code,
13 | const bool can_batch,
14 | const bool con_stencil);
15 |
16 | ~PythonKernel();
17 |
18 | void new_stream(const std::vector& args) override;
19 |
20 | void execute(const StenciledBatchedElements& input_columns,
21 | BatchedElements& output_columns) override;
22 |
23 | void reset() override;
24 |
25 | void fetch_resources(proto::Result* result) override;
26 |
27 | void setup_with_resources(proto::Result* result) override;
28 |
29 | private:
30 | KernelConfig config_;
31 | DeviceHandle device_;
32 | bool can_batch_;
33 | bool can_stencil_;
34 | std::string op_name_;
35 | std::string process_name_;
36 | std::string send_pipe_name_;
37 | std::string recv_pipe_name_;
38 | std::string kernel_name_;
39 | };
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/cmake/Modules/FindStruck.cmake:
--------------------------------------------------------------------------------
1 | # - Try to find Struck
2 | #
3 | # The following variables are optionally searched for defaults
4 | # STRUCK_ROOT_DIR: Base directory where all Struck components are found
5 | #
6 | # The following are set after configuration is done:
7 | # STRUCK_FOUND
8 | # STRUCK_INCLUDE_DIRS
9 | # STRUCK_LIBRARIES
10 | # STRUCK_LIBRARY_DIRS
11 |
12 | include(FindPackageHandleStandardArgs)
13 |
14 | set(STRUCK_ROOT_DIR "" CACHE PATH "Folder contains Struck")
15 |
16 | if (NOT "$ENV{Struck_DIR}" STREQUAL "")
17 | set(STRUCK_ROOT_DIR $ENV{Struck_DIR})
18 | endif()
19 |
20 | # We are testing only a couple of files in the include directories
21 | if(WIN32)
22 | find_path(STRUCK_INCLUDE_DIR struck/tracker.h
23 | PATHS ${STRUCK_ROOT_DIR}/src/windows)
24 | else()
25 | find_path(STRUCK_INCLUDE_DIR struck/tracker.h
26 | PATHS ${STRUCK_ROOT_DIR}/include)
27 | endif()
28 |
29 | find_library(STRUCK_LIBRARY caffe PATHS ${STRUCK_ROOT_DIR}/lib)
30 |
31 | find_package_handle_standard_args(STRUCK DEFAULT_MSG
32 | STRUCK_INCLUDE_DIR STRUCK_LIBRARY)
33 |
34 | if(STRUCK_FOUND)
35 | set(STRUCK_INCLUDE_DIRS ${STRUCK_INCLUDE_DIR})
36 | set(STRUCK_LIBRARIES ${STRUCK_LIBRARY})
37 | endif()
38 |
--------------------------------------------------------------------------------
/scanner/util/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Copyright 2016 Carnegie Mellon University, NVIDIA Corporation
2 | #
3 | # Licensed under the Apache License, Version 2.0 (the "License");
4 | # you may not use this file except in compliance with the License.
5 | # You may obtain a copy of the License at
6 | #
7 | # http://www.apache.org/licenses/LICENSE-2.0
8 | #
9 | # Unless required by applicable law or agreed to in writing, software
10 | # distributed under the License is distributed on an "AS IS" BASIS,
11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | # See the License for the specific language governing permissions and
13 | # limitations under the License.
14 |
15 | set(SOURCE_FILES
16 | common.cpp
17 | memory.cpp
18 | profiler.cpp
19 | fs.cpp
20 | bbox.cpp
21 | glog.cpp
22 | lodepng.cpp
23 | image_encoder.cpp)
24 |
25 | if (NO_FFMPEG STREQUAL "false")
26 | list(APPEND SOURCE_FILES
27 | ffmpeg.cpp)
28 | endif()
29 |
30 | add_library(util OBJECT
31 | ${SOURCE_FILES})
32 |
33 | if (BUILD_CUDA)
34 | cuda_add_library(util_cuda
35 | image.cu)
36 | install(TARGETS util_cuda
37 | EXPORT ScannerTarget
38 | ARCHIVE DESTINATION lib
39 | LIBRARY DESTINATION lib)
40 | endif()
41 |
--------------------------------------------------------------------------------
/cmake/Modules/FindGipuma.cmake:
--------------------------------------------------------------------------------
1 | # - Try to find Gipuma
2 | #
3 | # The following variables are optionally searched for defaults
4 | # GIPUMA_ROOT_DIR: Base directory where all Gipuma components are found
5 | #
6 | # The following are set after configuration is done:
7 | # GIPUMA_FOUND
8 | # GIPUMA_INCLUDE_DIRS
9 |
10 | include(FindPackageHandleStandardArgs)
11 |
12 | set(GIPUMA_ROOT_DIR "" CACHE PATH "Folder contains Gipuma")
13 |
14 | if (NOT "$ENV{Gipuma_DIR}" STREQUAL "")
15 | set(GIPUMA_ROOT_DIR $ENV{Gipuma_DIR} CACHE PATH "Folder contains Gipuma" FORCE)
16 | endif()
17 |
18 | # We are testing only a couple of files in the include directories
19 | if(WIN32)
20 | find_path(GIPUMA_INCLUDE_DIR gipuma.h
21 | PATHS ${GIPUMA_ROOT_DIR}/src/windows
22 | PATH_SUFFIXES gipuma)
23 | else()
24 | find_path(GIPUMA_INCLUDE_DIR gipuma.h
25 | PATHS ${GIPUMA_ROOT_DIR}/include
26 | PATH_SUFFIXES gipuma)
27 |
28 | endif()
29 |
30 | find_library(GIPUMA_LIBRARY gipuma PATHS ${GIPUMA_ROOT_DIR}/lib)
31 |
32 | find_package_handle_standard_args(GIPUMA DEFAULT_MSG GIPUMA_INCLUDE_DIR
33 | GIPUMA_LIBRARY)
34 |
35 | if(GIPUMA_FOUND)
36 | set(GIPUMA_INCLUDE_DIRS ${GIPUMA_INCLUDE_DIR})
37 | set(GIPUMA_LIBRARIES ${GIPUMA_LIBRARY})
38 | endif()
39 |
--------------------------------------------------------------------------------
/examples/util.py:
--------------------------------------------------------------------------------
1 | import os.path
2 |
3 | try:
4 | import requests
5 | except ImportError:
6 | print(
7 | 'You need to install requests to run this. Try running:\npip install requests'
8 | )
9 | exit()
10 |
11 | VID_URL = "https://storage.googleapis.com/scanner-data/public/sample-clip.mp4"
12 | VID_PATH = '/tmp/example.mp4'
13 |
14 | IMG_PATH = '/tmp/example.mp4'
15 |
16 |
17 | def download_video():
18 | if not os.path.isfile(VID_PATH):
19 | with open(VID_PATH, 'wb') as f:
20 | resp = requests.get(VID_URL, stream=True)
21 | assert resp.ok
22 | for block in resp.iter_content(1024):
23 | f.write(block)
24 | f.flush()
25 | return VID_PATH
26 |
27 |
28 | def download_images():
29 | img_template = (
30 | 'https://storage.googleapis.com/scanner-data/public/sample-frame-{:d}.jpg')
31 | output_template = 'sample-frame-{:d}.jpg'
32 |
33 | for i in range(1, 4):
34 | with open(output_template.format(i), 'wb') as f:
35 | resp = requests.get(img_template.format(i), stream=True)
36 | assert resp.ok
37 | for block in resp.iter_content(1024):
38 | f.write(block)
39 | f.flush()
40 |
--------------------------------------------------------------------------------
/scanner/engine/op_registry.h:
--------------------------------------------------------------------------------
1 | /* Copyright 2016 Carnegie Mellon University
2 | *
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | */
15 |
16 | #pragma once
17 |
18 | #include "scanner/api/op.h"
19 | #include "scanner/engine/op_info.h"
20 |
21 | #include "scanner/util/common.h"
22 |
23 | #include