{"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":222,"created_at":"2015-06-16T23:25:11Z","updated_at":"2015-08-24T11:37:26Z","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 (available on Ubuntu 14.04)\r\n* clBLAS dynamic/shared library (OPTIONAL, not required for OpenCL execution)\r\n* C++11\r\n* gcc/g++ 4.8.2 to 4.9.2, on OS X, clang might also work. When not using CUDA, the compiler only has to support C++11 and no further constraints apply.\r\n* CUDA 7.0 (not 6.5 due to C++11 compability and has to be used 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\n| Device | Backend | Forward (ms) | Backward (ms) | Forward-Backward (ms) |\r\n|----------|-----------|--------------------|--------------------|---------------------------------|\r\n| i7-4790K | CPU | 429.952 |  339.361 |  769.36 |\r\n| i7-4790K | OpenCL | 240.883 | 173.725 | 414.7 |\r\n| GTX 980 | CUDA+CUDNN | 11.9474 | 14.2246 | 26.2111 |\r\n| GTX 980 | CUDA | 20.0203 | 15.886 | 35.9809 |\r\n| GTX 980 | OpenCL | 62.7322 | 55.9396 | 118.68 |\r\n| W9100 | OpenCL | 48.3477 | 132.813 | 181.2 |\r\n| HD4000 (i7-3632QM) | OpenCL | 1742.5 | 1546.26 | 3288.84 |\r\n| i7-4750HQ | OpenCL | 270.365 | 264.544 | 534.94 |\r\n| Iris Pro (i7-4750HQ) | OpenCL | 334.524 | 744.907 |  1079.5 |\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\r\n## Support\r\nIf you need help with compiling, installation or device support, and you think it is not a bug of the Caffe branch, ask here:\r\nhttps://groups.google.com/forum/#!forum/greentea-users\r\nAgain, 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"},"comment":{"url":"https://api.github.com/repos/BVLC/caffe/issues/comments/134162578","html_url":"https://github.com/BVLC/caffe/pull/2610#issuecomment-134162578","issue_url":"https://api.github.com/repos/BVLC/caffe/issues/2610","id":134162578,"user":{"login":"bhack","id":1710528,"avatar_url":"https://avatars.githubusercontent.com/u/1710528?v=3","gravatar_id":"","url":"https://api.github.com/users/bhack","html_url":"https://github.com/bhack","followers_url":"https://api.github.com/users/bhack/followers","following_url":"https://api.github.com/users/bhack/following{/other_user}","gists_url":"https://api.github.com/users/bhack/gists{/gist_id}","starred_url":"https://api.github.com/users/bhack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bhack/subscriptions","organizations_url":"https://api.github.com/users/bhack/orgs","repos_url":"https://api.github.com/users/bhack/repos","events_url":"https://api.github.com/users/bhack/events{/privacy}","received_events_url":"https://api.github.com/users/bhack/received_events","type":"User","site_admin":false},"created_at":"2015-08-24T11:37:26Z","updated_at":"2015-08-24T11:37:26Z","body":"@naibaf7 See also https://github.com/Theano/Theano/issues/2072"}}