{"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":41,"created_at":"2015-06-16T23:25:11Z","updated_at":"2015-07-03T15:35:33Z","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\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\r\n## Missing features\r\n* CMAKE support. Still needs some tuning to produce the same results as the Makefile.\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## 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\nI0619 13:45:36.655455  4777 caffe.cpp:288] Average Forward pass: 429.952 ms.\r\nI0619 13:45:36.655464  4777 caffe.cpp:290] Average Backward pass: 339.361 ms.\r\nI0619 13:45:36.655472  4777 caffe.cpp:292] Average 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\nI0619 13:43:30.017576  4720 caffe.cpp:288] Average Forward pass: 240.883 ms.\r\nI0619 13:43:30.017606  4720 caffe.cpp:290] Average Backward pass: 173.725 ms.\r\nI0619 13:43:30.017637  4720 caffe.cpp:292] Average Forward-Backward: 414.7 ms.\r\n```\r\n\r\nGTX 980 on CUDA with CUDNN:\r\n```\r\nI0619 13:42:05.963385  4666 caffe.cpp:288] Average Forward pass: 11.9474 ms.\r\nI0619 13:42:05.963392  4666 caffe.cpp:290] Average Backward pass: 14.2246 ms.\r\nI0619 13:42:05.963397  4666 caffe.cpp:292] Average Forward-Backward: 26.2111 ms.\r\n```\r\n\r\nGTX 980 on CUDA:\r\n```\r\nI0621 01:58:48.354440 17137 caffe.cpp:288] Average Forward pass: 20.0203 ms.\r\nI0621 01:58:48.354446 17137 caffe.cpp:290] Average Backward pass: 15.886 ms.\r\nI0621 01:58:48.354462 17137 caffe.cpp:292] Average Forward-Backward: 35.9809 ms.\r\n```\r\n\r\nGTX 980 on OpenCL:\r\n```\r\nI0619 13:42:39.797739  4690 caffe.cpp:288] Average Forward pass: 62.7322 ms.\r\nI0619 13:42:39.797744  4690 caffe.cpp:290] Average Backward pass: 55.9396 ms.\r\nI0619 13:42:39.797749  4690 caffe.cpp:292] Average Forward-Backward: 118.68 ms.\r\n```\r\n\r\nW9100 on OpenCL:\r\n```\r\nI0619 13:41:02.161386  4622 caffe.cpp:288] Average Forward pass: 48.3477 ms.\r\nI0619 13:41:02.161391  4622 caffe.cpp:290] Average Backward pass: 132.813 ms.\r\nI0619 13:41:02.161396  4622 caffe.cpp:292] Average Forward-Backward: 181.2 ms.\r\n```"},"comment":{"url":"https://api.github.com/repos/BVLC/caffe/issues/comments/118376334","html_url":"https://github.com/BVLC/caffe/pull/2610#issuecomment-118376334","issue_url":"https://api.github.com/repos/BVLC/caffe/issues/2610","id":118376334,"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-07-03T15:35:33Z","updated_at":"2015-07-03T15:35:33Z","body":"Ok.. make a lint pass."}}