# AMD vs Nvidia GPUs, Clarification about OpenCL Support



## BawdyAnarchist (Jul 18, 2021)

After digging as deep as I can as a layman, I think that there is no OpenCL support available with Nvidia, and there are no workarounds at the moment (please someone correct me if I'm wrong).

So in order to use some graphics intensive programs to their full potential, I feel compelled to purchase and AMD GPU. However, I have some questions regarding this as well, as it doesn't seem to be entirely straightforward that I can expect proper OpenCL support for new AMD GPUs either. This comment makes me believe that Mesa should generically support OpenCL for even newer AMD GPUs, but at the same time raises doubts, as it describes ROCm being a replacement OpenCL driver for AMD GPUs but not ported to FreeBSD.

Given that GPU drivers seem to be a bit convoluted, especially in relation to FreeBSD, I'm not confident that if I go out and purchase an expensive AMD GPU (due to everyone and their mother trying to GPU mine crypto nowadays); that it will actually have the support I need to enable OpenCL, and thus the functionality that I'm missing.

I realize that I could just buy an older AMD GPU from say 2018 as a means of ensuring that I have proper support, but I would prefer just to get something that should be top of the line for quite a few years.


----------



## astyle (Jul 20, 2021)

BawdyAnarchist said:


> After digging as deep as I can as a layman, I think that there is no OpenCL support available with Nvidia, and there are no workarounds at the moment (please someone correct me if I'm wrong).
> 
> So in order to use some graphics intensive programs to their full potential, I feel compelled to purchase and AMD GPU. However, I have some questions regarding this as well, as it doesn't seem to be entirely straightforward that I can expect proper OpenCL support for new AMD GPUs either. This comment makes me believe that Mesa should generically support OpenCL for even newer AMD GPUs, but at the same time raises doubts, as it describes ROCm being a replacement OpenCL driver for AMD GPUs but not ported to FreeBSD.
> 
> ...


NVidia cards support OpenCL no problem.  clpeak is a shining example of that.









						krrishnarraj/clpeak
					

A tool which profiles OpenCL devices to find their peak capacities - krrishnarraj/clpeak




					github.com
				



graphics/drm-kmod provides /boot/modules/amdgpu.ko, which is what you need to get going with an AMD GPU.
ROCm is *not* a 'driver' per se, but a whole graphics stack for GPU computing. Some parts work under FreeBSD, some don't. To get started with a 'driver' that supports at least running a GPU kernel, start here: 


			Graphics/OpenCL - FreeBSD Wiki
		

.

Be prepared to blow at least of $500 USD at this point. I'm waiting for prices to come down. FWIW, my approach is to teach myself to squeeze performance out of what I have (Asus RX 550 4GB, a Polaris card that is supposedly enabled for ROCm, but not officially supported). By 'not officially supported', ROCm devs mean that they don't spend time testing the code on that card, as in, 'We have not tested it, but it's similar enough, so we expect it to work, somehow, at least'.


----------



## sko (Jul 21, 2021)

astyle said:


> NVidia cards support OpenCL no problem. clpeak is a shining example of that.



IIRC Nvidia implements OpenCL through CUDA, which still isn't available on FreeBSD.

That's what I get when checking my systems with nvidia GPUs:

```
root@hati:~ # uname -a
FreeBSD hati 12.2-RELEASE-p3 FreeBSD 12.2-RELEASE-p3 GENERIC  amd64
root@hati:~ # nvidia-smi -L
GPU 0: GeForce GTX 960 (UUID: GPU-029a228a-7c27-2036-7747-297b406d1e97)
root@hati:~ # clpeak
clGetPlatformIDs (-1001)
no platforms found
root@hati:~ # clinfo
Number of platforms                               0
```


```
root@hal9000:~ # uname -a
FreeBSD hal9000 13.0-RELEASE-p2 FreeBSD 13.0-RELEASE-p2 GENERIC amd64
root@hal9000:~ # nvidia-smi -L
GPU 0: GeForce GT 710 (UUID: GPU-1fd00883-0126-63cd-a1db-cb49c60c0e08)
root@hal9000:~ # clpeak
clGetPlatformIDs (-1001)
no platforms found
root@hal9000:~ # clinfo
Number of platforms                               0
```

Both systems are using the nvidia-driver from packages and 'Driver = "nvidia"' is set in /usr/local/etc/X11/xorg.conf.d/nvidia.conf.

However you *should* be able to use the integrated GPU of an Intel CPU for OpenCL (and e.g. transcoding) while using the Nvidia for "everything else"/graphics output via the x11/nvidia-hybrid-graphics driver. I wanted to test this for a while now, but never found the time...


----------



## astyle (Jul 21, 2021)

sko :  do you have graphics/mesa-libs installed? If you do, what does `glxinfo` output? That should work for NVidia cards. 

FWIW, CUDA is plenty available on FreeBSD - I use ports to compile stuff related to GPU acceleration, and I have to be careful to actually avoid having deps pull in anything CUDA-related. That's because I have an AMD GPU, not NVidia.


----------



## shkhln (Jul 21, 2021)

astyle said:


> and I have to be careful to actually avoid having deps pull in anything CUDA-related


Really? What would that be?


----------



## sko (Jul 21, 2021)

```
% pkg info | grep mesa
mesa-dri-20.2.3_2              OpenGL hardware acceleration drivers for DRI2+
mesa-libs-20.2.3_1             OpenGL libraries that support GLX and EGL clients
334 sko@hal9000:~ % glxinfo | grep -i cuda
335 sko@hal9000:~ % glxinfo | grep -i opencl
336 sko@hal9000:~ % glxinfo | grep -i opengl
OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: GeForce GT 710/PCIe/SSE2
OpenGL core profile version string: 4.5.0 NVIDIA 460.84
OpenGL core profile shading language version string: 4.50 NVIDIA
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 4.5.0 NVIDIA 460.84
OpenGL shading language version string: 4.50 NVIDIA
OpenGL context flags: (none)
OpenGL profile mask: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.2 NVIDIA 460.84
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
OpenGL ES profile extensions:
```

And no, CUDA is not available on FreeBSD as it is still not implemented by the Nvidia driver yet:








						CUDA and /(nv_(un|)register|os_(un|)lock)_user_pages/
					

Please, consider implementing nv_register_user_pages/nv_unregister_user_pages/os_lock_user_pages/os_unlock_user_pages in the FreeBSD driver. Those functions are apparently being called on CUDA initialization and that’s the bit that prevents CUDA from working on FreeBSD. Well, at least as far as...




					forums.developer.nvidia.com
				




also where is this "plenty cuda stuff" that should be available?

```
% pkg search cuda
cudatext-gtk2-1.99.0_2         Cross-platform text editor, written in Lazarus
cudatext-qt5-1.99.0_2          Cross-platform text editor, written in Lazarus
```


----------



## astyle (Jul 21, 2021)

shkhln said:


> Really? What would that be?





astyle said:


> That's because I have an AMD GPU, not NVidia.


----------



## shkhln (Jul 21, 2021)

As both you and I know, I caught you talking bullshit on this very subject a few times before. Please, stop.


----------



## astyle (Jul 21, 2021)

shkhln said:


> As both you and I know, I caught you talking bullshit on this very topic a few times before. Please, stop.


I merely share my observations from trying to compile ports  related to AMD GPU acceleration.  And I'm not gonna drop $2500 on an RTX 3090 just to verify my claims.


astyle said:


> Please reply and correct me if that's not the case. Besides, Nvidia's stuff has traditionally worked very well under FreeBSD, even better than AMD


----------

