{"id":13936560,"url":"https://github.com/ctuning/ck-caffe2","last_synced_at":"2026-01-22T19:22:40.217Z","repository":{"id":86885405,"uuid":"90728442","full_name":"ctuning/ck-caffe2","owner":"ctuning","description":"Integration of Caffe2 to Collective Knowledge workflow framework to provide unified CK JSON API for AI (customized builds across diverse libraries and hardware, unified AI API, collaborative experiments, performance optimization and model/data set tuning):","archived":false,"fork":false,"pushed_at":"2021-07-10T12:17:44.000Z","size":596,"stargazers_count":32,"open_issues_count":0,"forks_count":3,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-08-08T23:23:59.930Z","etag":null,"topics":["collaborative-optimization","collective-knowledge","common-ai-api","customized-builds","experimental-workflows","json-api","universal-package-manager"],"latest_commit_sha":null,"homepage":"http://cKnowledge.org/ai","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ctuning.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-09T09:36:00.000Z","updated_at":"2023-11-06T07:11:57.000Z","dependencies_parsed_at":"2023-03-22T23:31:13.596Z","dependency_job_id":null,"html_url":"https://github.com/ctuning/ck-caffe2","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctuning%2Fck-caffe2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctuning%2Fck-caffe2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctuning%2Fck-caffe2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctuning%2Fck-caffe2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ctuning","download_url":"https://codeload.github.com/ctuning/ck-caffe2/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226686729,"owners_count":17666928,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["collaborative-optimization","collective-knowledge","common-ai-api","customized-builds","experimental-workflows","json-api","universal-package-manager"],"created_at":"2024-08-07T23:02:47.205Z","updated_at":"2026-01-22T19:22:40.211Z","avatar_url":"https://github.com/ctuning.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"**All CK components can be found at [cKnowledge.io](https://cKnowledge.io) and in [one GitHub repository](https://github.com/ctuning/ck-mlops)!**\n\n[![compatibility](https://github.com/ctuning/ck-guide-images/blob/master/ck-compatible.svg)](https://github.com/ctuning/ck)\n[![automation](https://github.com/ctuning/ck-guide-images/blob/master/ck-artifact-automated-and-reusable.svg)](http://cTuning.org/ae)\n[![workflow](https://github.com/ctuning/ck-guide-images/blob/master/ck-workflow.svg)](http://cKnowledge.org)\n\n[![DOI](https://zenodo.org/badge/90728442.svg)](https://zenodo.org/badge/latestdoi/90728442)\n[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)\n\n# Unification of AI for collaborative experimentation and optimization using Collective Knowledge workflow framework with common JSON API\n\n*Note that Caffe2 moved to [PyTorch](https://github.com/pytorch/pytorch) GitHub source tree, so some packages here may not work correctly.*\n\n## Introduction\n\nAfter spending most of our \"research\" time not on AI innovation but on dealing with numerous \nand ever changing AI engines, their API, and the whole software and hardware stack, \nwe decided to take an alternative approach. \n\n[![logo](http://cknowledge.org/images/ai-cloud-resize.png)](http://cKnowledge.io)\n\nWe started adding existing AI frameworks including [Caffe](https://github.com/dividiti/ck-caffe), \n[Caffe2](https://github.com/ctuning/ck-caffe2), [TensorFlow](https://github.com/ctuning/ck-tensorflow),\n[MXNet](https://github.com/ctuning/ck-mxnet), [CK-PyTorch](https://github.com/ctuning/ck-pytorch),\n[CNTK](https://github.com/ctuning/ck-cntk) \nand [MVNC](https://github.com/ctuning/ck-mvnc).\n\nto the non-intrusive open-source [Collective Knowledge workflow framework (CK)](https://github.com/ctuning/ck).\nCK allows to plug in various versions of AI frameworks together with libraries, compilers, tools, models\nand data sets as [unified and reusable components with JSON API](http://cKnowledge.io), \nautomate and customize their installation across Linux, Windows, MacOS and Android (rather than using ad-hoc scripts) \nand provide simple JSON API for common operations such as prediction and training (see [demo](http://cKnowledge.org/ai/ck-api-demo)).\n\nAt the same time, CK allows us to continuously optimize ([1](https://arxiv.org/abs/1506.06256), [2](http://doi.acm.org/10.1145/2909437.2909449))\nthe whole AI stack (SW/HW/models) across diverse platforms from mobile devices and IoT to supercomputers\nin terms of accuracy, execution time, power consumption, resource usage and other costs with the\nhelp of the community (see [public CK repo](http://cKnowledge.org/repo) \nand [reproducible and CK-powered AI/SW/HW co-design competitions at ACM/IEEE conferences](http://cKnowledge.org/request)).\n\nSee [cKnowledge.io](http://cKnowledge.io) for more details.\n\n## Maintainers\n* [dividiti](http://dividiti.com) - not actively maintained\n\n## Example of Caffe and Caffe2 unified CPU installation on Ubuntu via CK\n\nNote that you need Python 2.x!\n\n```\n$ sudo apt install coreutils build-essential make cmake wget git python python-pip\n$ sudo pip install jupyter pandas numpy scipy matplotlib scikit-image scikit-learn pyyaml protobuf future google\n$ sudo pip install --upgrade beautifulsoup4\n$ sudo pip install --upgrade html5lib\n\n$ sudo pip install ck\n\n$ ck pull repo --url=https://github.com/dividiti/ck-caffe\n$ ck pull repo:ck-caffe2\n\n$ ck install package --tags=lib,caffe,vcpu --env.CAFFE_BUILD_PYTHON=ON\n$ ck install package --tags=lib,caffe2,vcpu\n```\n\nUsing compiled Caffe (with python) as a virtual environment:\n```\n$ ck virtual env --tags=lib,caffe\n$ ipython\n```\n\n## Dependencies for Windows\n\nWe tested it with Anaconda Python 2.x (should be in path for pip). Note that only stable package currently works - 0.8.1 (there is an issue with custom protobuf in the master branch)\n\n```\n$ pip install jupyter pandas numpy scipy matplotlib scikit-image scikit-learn pyyaml protobuf future google\n$ pip install flask glog graphviz  pydot python-nvd3 pyyaml requests scikit-image setuptools tornado\n$ pip install future hypothesis six\n$ pip install --upgrade beautifulsoup4\n$ pip install --upgrade html5lib\n```\n\n\n## Example of Caffe2 unified CPU installation on Raspberry Pi 3+\n\n\n```\n$ sudo apt install coreutils build-essential make cmake python python-pip libblas-dev python-scipy \n$ sudo apt install python-numpy python-pandas python-matplotlib python-scikit-image\n$ sudo pip install scikit-image pyyaml protobuf future google\n$ sudo pip install --upgrade beautifulsoup4\n$ sudo pip install --upgrade html5lib\n\n$ sudo pip install ck\n\n$ ck pull repo:ck-caffe2\n\n$ ck install package --tags=lib,caffe2,vcpu --env.CK_HOST_CPU_NUMBER_OF_PROCESSORS=2 --env.CAFFE2_CPU_FLAGS=\"-mfpu=neon -mfloat-abi=hard\"\n```\n\n## Example of Caffe and Caffe2 unified CUDA installation on Ubuntu via CK\n\nIf you have CUDA-compatible GPGPU with drivers, CUDA and cuDNN installed,\nyou can install Caffe and Caffe2 for GPGPU via CK as follows\n(CK will automatically find your CUDA installation):\n\n```\n$ ck install package:lib-caffe-bvlc-master-cuda-universal --env.CAFFE_BUILD_PYTHON=ON\n$ ck install package:lib-caffe-bvlc-master-cudnn-universal --env.CAFFE_BUILD_PYTHON=ON\n$ ck install package:lib-caffe2-master-eigen-cuda-universal --env.CAFFE_BUILD_PYTHON=ON\n```\nYou can find detailed instructions to install Caffe (CPU, CUDA, OpenCL versions) via CK \non Ubuntu, Gentoo, Yocto, Raspberry Pi, Odroid, Windows and Android [here](https://github.com/dividiti/ck-caffe/wiki/Installation). \nCaffe2 detailed instructions about customized CK builds are coming soon!\n\n## Example of Caffe and Caffe2 unified classification on Ubuntu via CK\n\n```\n$ ck run program:caffe --cmd_key=classify\n$ ck run program:caffe2 --cmd_key=classify\n```\n\nNote, that Caffe2, besides some very useful improvements, also changed various support programs \nand API. However, our approach helped our collaborators hide these changes via CK API and thus\nprotect higher-level experimental workflows!\n\nYou can find and install additional Caffe and Caffe2 models via CK:\n```\n$ ck search package:* --tags=caffemodel\n$ ck search package:* --tags=caffemodel2\n\n$ ck install package:caffemodel-bvlc-googlenet\n$ ck install package:caffemodel-bvlc-alexnet\n\n$ ck install package:caffemodel2-deepscale-squeezenet-1.1\n$ ck install package:caffemodel2-resnet50\n```\n\n## Collaborative and unified benchmarking of DNN\n\nAdditional motivation to use CK wrappers for DNN is the possibility \nto assemble various experimental workflows, crowdsource experiments\nand engage with the community to collaboratively solve complex problems \n([notes](https://www.researchgate.net/publication/304010295_Collective_Knowledge_Towards_RD_Sustainability)). \nFor example, we added basic support to collaboratively evaluate various DNN engines\nvia unified CK API:\n\n```\n$ ck crowdbench caffe --env.BATCH_SIZE=5\n$ ck crowdbench caffe2 --env.BATCH_SIZE=5 --user=i_want_to_ack_my_contribution\n```\n\nPerformance results are continuously aggregated in the public [CK repository](http://cKnowledge.org/repo), \nhowever they can also be aggregated only on your local machine or in your workgroup - you just need to add flag \"--local\".\n\n## Unified, multi-dimensional and multi-objective autotuning\n\nIt is now possible to take advantage of our [universal multi-objective CK autotuner](https://github.com/ctuning/ck/wiki/Autotuning)\nto optimize Caffe. As a first simple example, we added batch size tuning via CK. You can invoke it as follows:\n\n```\n$ ck autotune caffe\n$ ck autotune caffe2\n```\n\nAll results will be recorded in the local CK repository and \nyou will be given command lines to plot graphs or replay experiments such as:\n```\n$ ck plot graph:{experiment UID}\n$ ck replay experiment:{experiment UID} --point={specific optimization point}\n```\n\n## Collaborative and unified optimization of DNN\n\nWe are now working to extend above autotuner and crowdsource optimization \nof the whole SW/HW/model/data set stack ([paper 1](https://scholar.google.com/citations?view_op=view_citation\u0026hl=en\u0026user=IwcnpkwAAAAJ\u0026citation_for_view=IwcnpkwAAAAJ:maZDTaKrznsC), \n[paper 2](https://arxiv.org/abs/1506.06256)).\n\nWe would like to thank the community for their interest and feedback about \nthis collaborative AI optimization approach powered by CK \nat [ARM TechCon'16](https://github.com/ctuning/ck/wiki/Demo-ARM-TechCon'16)\nand the Embedded Vision Summit'17 - so please stay tuned ;) !\n\n[![logo](http://cKnowledge.org/images/dividiti_arm_stand.jpg)](https://www.researchgate.net/publication/304010295_Collective_Knowledge_Towards_RD_Sustainability)\n\n## Unified DNN API via CK\n\nWe added similar support to install, use and evaluate [TensorFlow](https://www.tensorflow.org) via CK:\n\n```\n$ ck pull repo:ck-tensorflow\n\n$ ck install lib-tensorflow-1.1.0-cpu\n$ ck install lib-tensorflow-1.1.0-cuda\n\n$ ck run program:tensorflow --cmd_key=classify\n\n$ ck crowdbench tensorflow --env.BATCH_SIZE=5\n\n$ ck autotune tensorflow\n```\n\n## Online demo of a unified CK-AI API \n\n* [Simple demo](http://cknowledge.org/repo/web.php?template=ck-ai-basic) to classify images with\ncontinuous optimization of DNN engines underneath, sharing of mispredictions and creation of a community training set;\nand to predict compiler optimizations based on program features.\n\n## Realistic/representative training sets\n\nWe provided an option in all our AI crowd-tuning tools to let the community report \nand share mispredictions (images, correct label and wrong misprediction) \nto gradually and collaboratively build realistic data/training sets:\n* [Public repository (see \"mispredictions and unexpected behavior)](http://cknowledge.org/repo/web.php?action=index\u0026module_uoa=wfe\u0026native_action=show\u0026native_module_uoa=program.optimization)\n* [Misclassified images via CK-based AI web-service](http://cknowledge.org/repo/web.php?action=index\u0026module_uoa=wfe\u0026native_action=show\u0026native_module_uoa=program.optimization)\n\n## Next steps\n\nWe would like to improve Caffe2 installation via CK on Android similar to [CK-Caffe](https://github.com/dividiti/ck-caffe/wiki/Installation).\n\n## Long term vision\n\nCK-Caffe, CK-Caffe2, CK-Tensorflow are part of an ambitious long-term and community-driven \nproject to enable collaborative and systematic optimization \nof realistic workloads across diverse hardware \nin terms of performance, energy usage, accuracy, reliability,\nhardware price and other costs\n([ARM TechCon'16 talk and demo](https://github.com/ctuning/ck/wiki/Demo-ARM-TechCon'16), \n[DATE'16](http://tinyurl.com/zyupd5v), \n[CPC'15](http://arxiv.org/abs/1506.06256)).\n\nWe are working with the community to unify and crowdsource performance analysis \nand tuning of various DNN frameworks (or any realistic workload) \nusing Collective Knowledge Technology:\n* [Android app for DNN crowd-benchmarking and crowd-tuning](http://cKnowledge.org/android-apps.html)\n* [CK-TensorFlow](https://github.com/ctuning/ck-tensorflow)\n* [CK-Caffe](https://github.com/dividiti/ck-caffe)\n* [CK-Caffe2](https://github.com/ctuning/ck-caffe2)\n\nWe continue gradually exposing various design and optimization\nchoices including full parameterization of existing models.\n\n## Open R\u0026D challenges\n\nWe use crowd-benchmarking and crowd-tuning of such realistic workloads across diverse hardware for \n[open academic and industrial R\u0026D challenges](https://github.com/ctuning/ck/wiki/Research-and-development-challenges.mediawiki) - \njoin this community effort!\n\n## Related Publications with long term vision\n\n```\n@inproceedings{ck-date16,\n    title = {{Collective Knowledge}: towards {R\\\u0026D} sustainability},\n    author = {Fursin, Grigori and Lokhmotov, Anton and Plowman, Ed},\n    booktitle = {Proceedings of the Conference on Design, Automation and Test in Europe (DATE'16)},\n    year = {2016},\n    month = {March},\n    url = {https://www.researchgate.net/publication/304010295_Collective_Knowledge_Towards_RD_Sustainability}\n}\n\n@inproceedings{cm:29db2248aba45e59:cd11e3a188574d80,\n    url = {http://arxiv.org/abs/1506.06256},\n    title = {{Collective Mind, Part II: Towards Performance- and Cost-Aware Software Engineering as a Natural Science.}},\n    author = {Fursin, Grigori and Memon, Abdul and Guillon, Christophe and Lokhmotov, Anton},\n    booktitle = {{18th International Workshop on Compilers for Parallel Computing (CPC'15)}},\n    publisher = {ArXiv},\n    year = {2015},\n    month = January,\n    pdf = {http://arxiv.org/pdf/1506.06256v1}\n}\n\n```\n\n* [All references with BibTex related to CK concept](https://github.com/ctuning/ck/wiki/Publications)\n\n## Testimonials and awards\n\n* 2017: We received [CGO test of time award](http://dividiti.blogspot.fr/2017/02/we-received-test-of-time-award-for-our.html) for our CGO'07 paper which later motivated creation of [Collective Knowledge](https://github.com/ctuning/ck)\n* 2015: ARM and the cTuning foundation use CK to accelerate computer engineering: [HiPEAC Info'45 page 17](https://www.hipeac.net/assets/public/publications/newsletter/hipeacinfo45.pdf), [ARM TechCon'16 presentation and demo](https://github.com/ctuning/ck/wiki/Demo-ARM-TechCon'16), [public CK repo](https://github.com/ctuning/ck-wa)\n\n## Feedback\n\nGet in touch with CK-AI developers [here](https://github.com/ctuning/ck/wiki/Contacts). Also feel free to engage with our community via this mailing list:\n* http://groups.google.com/group/collective-knowledge\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fctuning%2Fck-caffe2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fctuning%2Fck-caffe2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fctuning%2Fck-caffe2/lists"}