3 ms·
I'm just getting started with machine learning and deep learning, so I'm certainly no expert. I wonder if building frameworks on top of OpenCL would be a viable
by generic_T 9y ago
I'm just getting started with machine learning and deep learning, so I'm certainly no expert. I wonder if building frameworks on top of OpenCL would be a viable alternative?
- paulmd 9y agoSure. And like I said, for relatively trivial stuff you can almost do a find-and-replace of CUDA keywords with OpenCL keywords and get something that will run with relatively minimal tweaking. The problem is the middleware - i.e. when you go to write a program, you want to write your financial simulation or whatever, not a RNG library. Once that stuff gets written, OpenCL will be perfectly viable. It's just sort of a slog now, vs a huge amount of stuff available for CUDA, both from NVIDIA and from others. Another, more general problem is that OpenCL is not really a GPGPU language, it's a general framework for dispatching tasks to heterogeneous processors. You can hypothetically use OpenCL to dispatch tasks to a FPGA or a DSP or anything else. This means there's a relatively silly amount of boilerplate compared to CUDA, which is stylistically annoying but not really complex. But in general it's also up to the vendor to implement their own SDK, compiler, etc, and there's no guarantee that what runs on one OpenCL platform will run on another. What is commonly referred to as "OpenCL" is actually the AMD APP SDK and the NVIDIA OpenCL SDK, which both implement their own version of parallel C++ dispatched according to the OpenCL function interface/semantics. So in other words, OpenCL suffers from a bit of Architecture Astronaut syndrome. AMD solved the problem of making a framework that can dispatch tasks to any coprocessor that implements their interface, NVIDIA solved the problem of making a GPGPU language. As such, AMD sometimes struggles to fulfill the cross-platform promise of their language and suffers in conciseness. For learning CUDA, I really like the Thrust language. You can write GPGPU programs that are literally 10 lines or less. It looks like regular C++ STL but you can execute it on the GPU. You can easily call __device__ functions using functors iterating across your dataset, or get raw_pointers into a device_vector and then pass them into a normal kernel launch, so there's a lot of flexibility there to tune stuff as you want to make it more complex. http://docs.nvidia.com/cuda/thrust/index.html http://docs.nvidia.com/cuda/thrust/index.html For a non-trivial program, here's my master's thesis, which I did in Thrust. Not really machine learning but at least you can see what you're getting into. https://github.com/pholvs/PandemicThrust https://github.com/pholvs/PandemicThrust For AMD, there is supposedly an equivalent called "Bolt Framework" but I have not used it personally. As is customary for AMD's libraries, after release it was abandoned and it has not been updated in several years, best of luck. https://hsa-libraries.github.io/Bolt/html/ https://hsa-libraries.github.io/Bolt/html/ https://github.com/HSA-Libraries/Bolt https://github.com/HSA-Libraries/Bolt