Can CUDA be installed on FreeBSD now ?

ok. I leave this question open for those users who are interested to apply your trick,so that potentially some other CG tools can run under FreeBSD using the CUDA libraries, like Maya or Unreal Engine 5.

Code:
# cc uvm_ioctl_override.c

ld: error: undefined symbol: main
>>> referenced by crt1_c.c:75 (/usr/src/lib/csu/amd64/crt1_c.c:75)
>>>               /usr/lib/crt1.o:(_start)
cc: error: linker command failed with exit code 1 (use -v to see invocation)
 
Try this :

Code:
pkg install linux-nvidia-libs libc6-shim blender


copy the precompiled Cycles CUDA kernels located on the folder "/blender-3.2.1-linux-x64/3.2/scripts/addons/cycles/lib/"


of this zipped file : https://download.blender.org/release/Blender3.2/blender-3.2.1-linux-x64.tar.xz


into this folder :


/usr/local/share/blender/3.2/scripts/addons/cycles/lib


patch libc6-shim to implement openat : https://github.com/monwarez/libc6-shim/commit/7e3dffc13d33e03cd18904c6e711595b5ade72e0


git clone https://github.com/shkhln/libc6-shim.git


cd libc6-shim/bin/


env __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia LD_LIBMAP="`nv-sglrun printenv LD_LIBMAP | grep -v libGL`" blender
Just for the sake of summary: I tried following the instructions in this thread and I did get it to work (or at least, my GPU shows up in blender).

Actually, I don't think you even need to build/patch libc6-shim, I'm pretty sure you can just run the `pkg install` bits from the quoted post, plus extract the precompiled cuda kernels from the blender tarball, and then use

env __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia LD_LIBMAP="`nv-sglrun printenv LD_LIBMAP | grep -v libGL`" blender

Thank you to everyone who has contributed to getting this working and documenting the process, especially shkhln and ziomario.
 
hsnyder If possible, it would be great if you could add additional information to your post regarding your setup such as which FreeBSD version you're running, which hardware and so on.
These things tend to change over time so someone coming along in a few years might have a better chance of figuring stuff out if these details are provided.
 
I'm running FreeBSD 14.0-CURRENT from about three weeks ago. Motherboard: Supermicro H11DSi, CPUs: 2x AMD Epyc 7302, GPU: 1080 Ti.

Re: patching, I was following the outlined steps above and I had already patched and built libc6-shim by the time I realized that even if you're in the libc6-shim/bin folder, simply invoking nv-sglrun instead of ./nv-sglrun will use the system installed version (from pkg) and not the one in the current directory (at least this is the case for sh and bash). Just as a sanity check, I just now deleted my patched libc6-shim and (to be extra sure) re-installed libc6-shim from pkg and it works fine. So it's definitely not required. According to freshports.org, the version of libc6-shim is the same between 13 and 14.

So the steps, then:

1. pkg install linux-nvidia-libs libc6-shim blender

2. copy the precompiled Cycles CUDA kernels located on the folder
/blender-3.2.1-linux-x64/3.2/scripts/addons/cycles/lib/
of this zipped file:
https://download.blender.org/release/Blender3.2/blender-3.2.1-linux-x64.tar.xz
into
/usr/local/share/blender/3.2/scripts/addons/cycles/lib

3. execute blender via env __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia LD_LIBMAP="`nv-sglrun printenv LD_LIBMAP | grep -v libGL`" blender


If anybody gets nvcc working, please let me know :)
 
shkhln : is it necessary to build/patch libc6-shim ?
The package is up-to-date and, if you use Nvidia as your primary GPU, it should be good enough as it is. The patch from monwarez concerns hybrid dual-GPU setup (aka Optimus). nv-sglrun could also benefit from a few adjustments for Optimus, but since I'm not working on the shim at the moment, all of this can wait.

Also, currently we can't do more than a few renders in a row before running into a libc6-shim bug, requiring a Blender restart. This will be eventually™ fixed.

If anybody gets nvcc working, please let me know :)
 
Hello to everyone.

I've installed the nvidia driver 525.78.01 + CUDA 12 within the ubuntu linuxulator and as you can see below,both are recognized :

Code:
mario@marietto:/compat/ubuntu # sudo chroot /compat/ubuntu bash
mario@marietto:/# sudo nvidia-smi

Thu Feb 16 01:17:27 2023  
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 525.78.01    Driver Version: 525.78.01    CUDA Version: 12.0     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ...  Off  | 00000000:01:00.0 Off |                  N/A |
| 53%   37C    P0    28W / 120W |      0MiB /  3072MiB |      2%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                         
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+

now,I would also like that cycles recognizes my GPU,but it doesn't. Can someone explain to me why ? what's wrong ?

Code:
mario@marietto:/# sudo blender

Read prefs: /root/.config/blender/2.82/config/userpref.blend
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_card_driver returned error: No such fi
le or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_concat returned error: No such file or
 directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_refer returned error: No such file or
directory
ALSA lib conf.c:5220:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM default
AL lib: (EE) ALCplaybackAlsa_open: Could not open playback device 'default': No such file or directo
ry
libGL error: failed to create dri screen
libGL error: failed to load driver: nouveau
/var/run/user/1001/gvfs/ non-existent directory
Warning: property 'release_confirm' not found in keymap item 'OperatorProperties'
CUDA cuInit: Unknown error
Saved session recovery to '/tmp/quit.blend'

Screenshot_2023-02-16_01-23-35.jpg
 
Back
Top