75

I am a newbie to GPU programming. I have a laptop with NVIDIA GeForce GT 640 card. I am faced with 2 dilemmas, suggestions are most welcome.

  1. If I go for CUDA -- Ubuntu or Windows Clearly CUDA is more suitable to windows while it can be a severe issue to install on Ubuntu. I have seen some blogposts which claim to have installed CUDA 5 on Ubuntu 11.10 and Ubuntu 12.04. However, I have not been able to get them to work. Also, standard CUDA textbooks prefer to work in the windows domain and are more or less silent in concern with Unix/Ubuntu installation and working.

  2. CUDA or OpenCL -- Now this is probably more trickier than my first question ! I have mostly come across GPGPU projects using CUDA/Nvidia but OpenCL is probably is the next best option in open source and installing in Ubuntu probably will not be an issue, though some suggestions here will be most useful. Am I sacrificing any functionality if I go for OpenCL and NOT CUDA ?

Any help or suggestions ?

ChrisF
  • 134,786
  • 31
  • 255
  • 325
Arkapravo
  • 4,084
  • 9
  • 37
  • 46
  • 2
    Regarding your first question, I have the feeling that Windows is currently better supported for CUDA rather than Linux. I have extensively used CUDA under Linux in the past, but the installation has been always a bit tricky. Concerning your second question, I think you could find much material by simple google search, for example [CUDA vs OpenCL: Which should I use?](http://wiki.tiker.net/CudaVsOpenCL) and [Difference between CUDA and OpenCL 2010](http://streamcomputing.eu/blog/2010-04-22/difference-between-cuda-and-opencl/). – Vitality Aug 02 '13 at 10:28
  • JackOLantern Thank you for your answer, can you tell me which Linux distro etc did you use for CUDA ? Also, if you had to take a pick, which one will you go for ? CUDA or OpenCL ? – Arkapravo Aug 02 '13 at 10:35
  • 2
    You may find CUDA 5.5 Production Release easy to install in Linux (see https://developer.nvidia.com/content/cudacasts-episode-5-install-cuda-55-linux-package-manager). In addition it is possible debug CUDA code with a single-GPU in CUDA 5.5 under Linux, with compute capability 3.5 or higher. Not your case, however that is a good new for linux users :) I'm not aware about windows debug requirements. – pQB Aug 02 '13 at 10:39
  • @pQB Very good news! :-) – Vitality Aug 02 '13 at 11:27
  • 1
    @Arkapravo I was using Ubuntu. Concerning CUDA vs OpenCL, it is difficult to answer. It is a matter of opinions. Basically, I started using CUDA since its beginning and never found a strong motivation to move towards OpenCL. Perhaps, simplifying, OpenCL will give you more portability, while CUDA more performance. But take this statement with a grain of salt. – Vitality Aug 02 '13 at 11:30
  • @JackOLantern So, for a newbie like me, it may be a better idea to start with CUDA in Windows-7 and then probably move to CUDA 5.5 hoping that Linux installation becomes relatively easier with the debian package ! :-) – Arkapravo Aug 02 '13 at 11:35
  • 1
    I have voted to close this - it is completely subjective and off-topic. [SO] isn't a place for dispensing advice and open ended discussions, it intended for concrete programming questions and their answers. – talonmies Aug 02 '13 at 12:47
  • 2
    @talonmies I am new to the topic, I have done suficient research (as shown by the links I have supplied) but I look for some genuine advice from people who have been doing it. I defend my question, it certainly has a clear answer and neither is it off topic. – Arkapravo Aug 02 '13 at 15:07
  • @pQB Thank you ! that link was a great help ! :-) – Arkapravo Aug 25 '13 at 16:28
  • @ChrisF This question has been answered and I am done with it - I have also requested various moderators to close it, rather delete it - and now, the funny thing - I get marked down for this ! ? – Arkapravo May 18 '15 at 14:45

2 Answers2

95
  1. If you use OpenCL, you can easily use it both on Windows and Linux because having display drivers is enough to run OpenCL programs and for programming you would simply need to install the SDK. CUDA has more requirements on specific GCC versions etc. But it is not much more difficult to install on Linux also.

  2. In Linux CUDA has strange requirements such as using GCC 4.6 or 4.7. If you use a different version of GCC, you won't be able to compile your program anymore. If you use OpenCL, you can use any compiler because you would just need to link with the common OpenCL library. So OpenCL is easier to setup, use and compile for. Once you compile an OpenCL program it can be run on any hardware (as long as it is coded to do so) even if it was compiled using another brand's OpenCL SDK.

You can write OpenCL programs which will function on Nvidia, AMD, and Intel hardware, on GPUs, CPUs, and Accelerators. Even more, Altera is working on supporting OpenCL on FPGAs! If you use CUDA, you will have to use Nvidia GPUs only and re-write your code again in OpenCL or other language for other platforms. A serious limitation of using CUDA and cause of serious waste of time in the long run.

I see that somebody posted some old references between CUDA and OpenCL, but they are old! When those documents were out, only AMD properly supported OpenCL. Since 2013, OpenCL is supported by ARM, Altera, Intel etc. and became an industry standard.

The only downside is that since OpenCL is so flexible, you are faced with more options and ways to code memory allocations, transfers etc. in your program. Therefore it may feel more complicated perhaps.

Arkapravo
  • 4,084
  • 9
  • 37
  • 46
Evren Yurtesen
  • 2,267
  • 1
  • 22
  • 40
  • 1
    As long as you don't plan to use Nvidia-proprietary things like tensor / ray-tracing cores, OpenCL is just as fast as CUDA when properly optimized. Plus you get a ton of hardware flexibility on Nvidia/AMD/Intel GPUs, AMD/Intel/ARM CPUs, FPGAs etc. and excellent compatibility across Windows, Linux and MacOS. – ProjectPhysX Jul 05 '20 at 11:10
10

I think it is not very difficult to set up cuda environment on ubuntu, you can give it a try.

As a computing architecture student, I think you need to learn both of OpenCL and CUDA. And you should learn cuda first because CUDA exposes more hardware and runtime info, hardware awareness is very important when you want to optimize your GPU codes.

Xiaolong Xie
  • 121
  • 3