{"action":"created","issue":{"url":"https://api.github.com/repos/BVLC/caffe/issues/2610","labels_url":"https://api.github.com/repos/BVLC/caffe/issues/2610/labels{/name}","comments_url":"https://api.github.com/repos/BVLC/caffe/issues/2610/comments","events_url":"https://api.github.com/repos/BVLC/caffe/issues/2610/events","html_url":"https://github.com/BVLC/caffe/pull/2610","id":88865719,"number":2610,"title":"Caffe OpenCL support","user":{"login":"naibaf7","id":5577650,"avatar_url":"https://avatars.githubusercontent.com/u/5577650?v=3","gravatar_id":"","url":"https://api.github.com/users/naibaf7","html_url":"https://github.com/naibaf7","followers_url":"https://api.github.com/users/naibaf7/followers","following_url":"https://api.github.com/users/naibaf7/following{/other_user}","gists_url":"https://api.github.com/users/naibaf7/gists{/gist_id}","starred_url":"https://api.github.com/users/naibaf7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/naibaf7/subscriptions","organizations_url":"https://api.github.com/users/naibaf7/orgs","repos_url":"https://api.github.com/users/naibaf7/repos","events_url":"https://api.github.com/users/naibaf7/events{/privacy}","received_events_url":"https://api.github.com/users/naibaf7/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":144,"created_at":"2015-06-16T23:25:11Z","updated_at":"2015-08-17T10:31:03Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/BVLC/caffe/pulls/2610","html_url":"https://github.com/BVLC/caffe/pull/2610","diff_url":"https://github.com/BVLC/caffe/pull/2610.diff","patch_url":"https://github.com/BVLC/caffe/pull/2610.patch"},"body":"# Full OpenCL support for Caffe\r\nThe idea is to end up with a complete polymorphic device abstraction until the end of the year. At the moment, it offers a side-by-side implementation of OpenCL and CUDA.\r\nThe second objective is enhanced layers for fast pixelwise image classification with Caffe.\r\n\r\n## New optional requirements for Caffe\r\n* ViennaCL header-only library, version 1.5 or newer\r\n* clBLAS dynamic/shared library (OPTIONAL, not required for OpenCL execution)\r\n* C++11, although this could be resolved. However, replacing Boost with C++11 would be possible.\r\n* gcc/g++ 4.8.2 to 4.9.2\r\n* CUDA 7.0 (compatible with gcc/g++ up to 4.9.2, >=5 not working)\r\n\r\n## Key features\r\n* Full OpenCL and CUDA support for all layers\r\n* Strided-kernel enhancements for pixelwise classification\r\n* Ability to build as CPU only or with OpenCL and CUDA support. Each backend can be enabled and disabled independently\r\n* Hybrid OpenCL/CBLAS implementation as a basis for a faster CPU backend. The hybrid solution also reduces memory redundancy in the Syncedmem class for CPU OpenCL devices. The future of this will also enhance support for AMD APUs with both CPU and GPU cores.\r\n* Support for 2 OpenCL BLAS libraries: ViennaCL-BLAS and CLBLAS\r\n* Seamless selection of CUDA and OpenCL devices. Supports multi-vendor ICDs. Can be run and compiled for AMD, Intel and nVidia OpenCL at once, from OpenCL 1.1 and up.\r\n* All original Caffe tests in the test rig pass without failure on all OpenCL implementations.\r\n* Aimed at getting peak performance on all device types\r\n* Enabling/disabling OpenCL and CUDA as easy as setting a flag in the Makefile.config, much like the CPU_ONLY flag\r\n* Adding a minimal amount of code overhead by leaving a lot of the OpenCL complexity to ViennaCL.\r\n* CMAKE support. Now fully functional for all compile combinations.\r\n\r\n## Missing features\r\n* Proper OpenCL RNG. Currently, CPU RNG and memory copy is used to provide the OpenCL implementation with random numbers. Replacement with optional https://github.com/clMathLibraries/clRNG is planned.\r\n\r\n## Special features\r\n* 1,2,...,6 dimensional (kernel strided) convolution\r\n* 1,2,...,6 dimensional (kernel strided) max-pooling\r\n* MALIS criterion loss function\r\n* Support for SK, U and USK network type architectures for fast image segmentation\r\n\r\n## Tested & known working hardware\r\nDevices that run out of the box and pass all tests\r\n- Intel i7 4790K & i7 3632QM, Intel & AMD OpenCL\r\n- AMD W9100, AMD OpenCL 1.2 and 2.0\r\n- nVidia GTX980, CUDA 7.0 and OpenCL 1.1 and 1.2\r\n- nVidia GT650M, CUDA 7.0 and OpenCL 1.1 and 1.2 (with OPTIMUS/BUMBLEBEE)\r\n- Intel i7-4750HQ and Iris Pro, Apple OpenCL 1.2\r\n\r\n## Hardware with issues\r\n- Intel onboard GPUs (Beignet), no double support. Tests do not pass but networks with float work.\r\n\r\n## Benchmarks:\r\n```\r\n./build/tools/caffe time -model models/bvlc_alexnet/deploy.prototxt -gpu=0\r\n```\r\n\r\ni7-4790K on CPU (CPU part of the Chip, not on board graphics):\r\n```\r\nAverage Forward pass: 429.952 ms.\r\nAverage Backward pass: 339.361 ms.\r\nAverage Forward-Backward: 769.36 ms.\r\n```\r\n\r\ni7-4790K on OpenCL-Hybrid (CPU part of the Chip, not on board graphics):\r\n```\r\nAverage Forward pass: 240.883 ms.\r\nAverage Backward pass: 173.725 ms.\r\nAverage Forward-Backward: 414.7 ms.\r\n```\r\n\r\nGTX 980 on CUDA with CUDNN:\r\n```\r\nAverage Forward pass: 11.9474 ms.\r\nAverage Backward pass: 14.2246 ms.\r\nAverage Forward-Backward: 26.2111 ms.\r\n```\r\n\r\nGTX 980 on CUDA:\r\n```\r\nAverage Forward pass: 20.0203 ms.\r\nAverage Backward pass: 15.886 ms.\r\nAverage Forward-Backward: 35.9809 ms.\r\n```\r\n\r\nGTX 980 on OpenCL:\r\n```\r\nAverage Forward pass: 62.7322 ms.\r\nAverage Backward pass: 55.9396 ms.\r\nAverage Forward-Backward: 118.68 ms.\r\n```\r\n\r\nW9100 on OpenCL:\r\n```\r\nAverage Forward pass: 48.3477 ms.\r\nAverage Backward pass: 132.813 ms.\r\nAverage Forward-Backward: 181.2 ms.\r\n```\r\n\r\ni7-3632QM integrated GPU (Ivy Bridge HD4000, beignet, OpenCL):\r\n```\r\nAverage Forward pass: 1742.5 ms.\r\nAverage Backward pass: 1546.26 ms.\r\nAverage Forward-Backward: 3288.84 ms.\r\n```\r\n\r\ni7-4750HQ (Apple OpenCL):\r\n```\r\nAverage Forward pass: 270.365 ms.\r\nAverage Backward pass: 264.544 ms.\r\nAverage Forward-Backward: 534.94 ms.\r\n```\r\n\r\nIris Pro (i7-4750HQ, Apple OpenCL):\r\n```\r\nAverage Forward pass: 334.524 ms.\r\nAverage Backward pass: 744.907 ms.\r\nAverage Forward-Backward: 1079.5 ms.\r\n```\r\n\r\n## Acknowledgments\r\nDevelopment of this branch is partially supported by:\r\n- AMD\r\n- HHMI Janelia\r\n- UZH, INI\r\n- ETH\r\n\r\n## Issues\r\nIf you notice issues with compilation, running tests or problems with network models, file an issue here:\r\nhttps://github.com/naibaf7/caffe\r\nand please specify:\r\n- Operating system\r\n- Compute device\r\n- Backend (Greentea, CUDA, CPU) and BLAS (Viennacl-BLAS, clBLAS, OpenBLAS, ATLAS, MKL, cuBLAS)\r\n- CUDA version, GCC version, OpenCL driver level\r\n"},"comment":{"url":"https://api.github.com/repos/BVLC/caffe/issues/comments/131771370","html_url":"https://github.com/BVLC/caffe/pull/2610#issuecomment-131771370","issue_url":"https://api.github.com/repos/BVLC/caffe/issues/2610","id":131771370,"user":{"login":"naibaf7","id":5577650,"avatar_url":"https://avatars.githubusercontent.com/u/5577650?v=3","gravatar_id":"","url":"https://api.github.com/users/naibaf7","html_url":"https://github.com/naibaf7","followers_url":"https://api.github.com/users/naibaf7/followers","following_url":"https://api.github.com/users/naibaf7/following{/other_user}","gists_url":"https://api.github.com/users/naibaf7/gists{/gist_id}","starred_url":"https://api.github.com/users/naibaf7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/naibaf7/subscriptions","organizations_url":"https://api.github.com/users/naibaf7/orgs","repos_url":"https://api.github.com/users/naibaf7/repos","events_url":"https://api.github.com/users/naibaf7/events{/privacy}","received_events_url":"https://api.github.com/users/naibaf7/received_events","type":"User","site_admin":false},"created_at":"2015-08-17T10:31:03Z","updated_at":"2015-08-17T10:31:03Z","body":"@hughperkins \r\nYes, absolutely. Let's see how the user base grows."}}