# Can CUDA be installed on FreeBSD now ?



## ziomario (Jul 19, 2022)

Hello to everyone.

I've just read this thread :









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

why nvidia does not reply at all ?




					forums.developer.nvidia.com
				




where has been asked to modify the code of the freebsd driver to support CUDA. I read that it has been done. So,now can we install CUDA on FreeBSD by installing first a linux distro with the linuxulator and then the proper cuda package ? does it will work ? thanks.


----------



## shkhln (Jul 19, 2022)

ziomario said:


> I've just read this thread :


Took you a while.



ziomario said:


> where has been asked to modify the code of the freebsd driver to support CUDA. I read that it has been done. So,now can we install CUDA on FreeBSD by installing first a linux distro with the linuxulator and then the proper cuda package ? does it will work ? thanks.











						CUDA
					

% pwd /usr/home/grahamperrin/dev/gpufetch % echo $0 /bin/tcsh % ./build.sh -- The CXX compiler identification is Clang 13.0.0 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features...




					forums.freebsd.org


----------



## ziomario (Jul 19, 2022)

Interesting. I've already seen that error "no GPU detected",when I tried to passthru my nvidia gpu inside a linux vm using bhyve. We have found what was missing on bhyve. Infact the nvidia driver wanted to find some components and the developers who have collaborated with me created the necessary patches. I'm not experienced,but I suspect that the gpu could be found with the same patches (or with some of them) created to allow bhyve to accept the nvidia driver. There is even a a protection mechanism inside of it. I should ask to my favorite bhyve developer.


----------



## shkhln (Jul 19, 2022)

I strongly suggest you to consider paying attention to the comment I linked, rather than contemplating some lame whateverfetch issues.


----------



## ziomario (Jul 19, 2022)

I can do it,if you have the patience to explain in easy understandable terms what you think. Unfortunately I haven't any programming knowledge. Usually I understand things by making multiple experiments,comparing the results and excluding the unuseful variables. Do you have a vague idea about how much efforts are needed to use my approach ? So,I really need to understand what happens under the hood at some theoretical level.


----------



## ziomario (Jul 19, 2022)

Can some one tell me what to do to install CUDA correctly ?


```
mario@marietto:/home/mario# sudo apt install nvidia-cuda-toolkit

Reading package lists... Done
Building dependency tree    
Reading state information... Done
The following packages were automatically installed and are no longer required:
dkms libegl-dev libglu1-mesa-dev libqt5concurrent5 libqt5opengl5 libqt5opengl5-dev libqt5sql5
libqt5sql5-sqlite libvulkan-dev libxext-dev linux-headers-5.4.0-26
linux-headers-5.4.0-26-generic linux-headers-generic qt5-default qt5-qmake qt5-qmake-bin
qtbase5-dev qtbase5-dev-tools qtchooser x11proto-xext-dev
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
g++-8 libaccinj64-10.1 libcublas10 libcublaslt10 libcudart10.1 libcufft10 libcufftw10
libcuinj64-10.1 libcupti-dev libcupti-doc libcupti10.1 libcurand10 libcusolver10 libcusolvermg10
libcusparse10 libjs-underscore libncurses5 libnppc10 libnppial10 libnppicc10 libnppicom10
libnppidei10 libnppif10 libnppig10 libnppim10 libnppist10 libnppisu10 libnppitc10 libnpps10
libnvblas10 libnvgraph10 libnvidia-compute-435 libnvidia-ml-dev libnvjpeg10 libnvrtc10.1
libnvtoolsext1 libnvvm3 libstdc++-8-dev libthrust-dev libtinfo5 libvdpau-dev node-html5shiv
nsight-compute nsight-systems nvidia-cuda-dev nvidia-cuda-doc nvidia-cuda-gdb nvidia-opencl-dev
nvidia-profiler nvidia-visual-profiler ocl-icd-opencl-dev opencl-c-headers
Suggested packages:
g++-8-multilib gcc-8-doc libstdc++-8-doc libvdpau-doc nodejs nvidia-driver
| nvidia-tesla-440-driver | nvidia-tesla-418-driver libpoclu-dev
Recommended packages:
libnvcuvid1
The following NEW packages will be installed:
g++-8 libaccinj64-10.1 libcublas10 libcublaslt10 libcudart10.1 libcufft10 libcufftw10
libcuinj64-10.1 libcupti-dev libcupti-doc libcupti10.1 libcurand10 libcusolver10 libcusolvermg10
libcusparse10 libjs-underscore libncurses5 libnppc10 libnppial10 libnppicc10 libnppicom10
libnppidei10 libnppif10 libnppig10 libnppim10 libnppist10 libnppisu10 libnppitc10 libnpps10
libnvblas10 libnvgraph10 libnvidia-compute-435 libnvidia-ml-dev libnvjpeg10 libnvrtc10.1
libnvtoolsext1 libnvvm3 libstdc++-8-dev libthrust-dev libtinfo5 libvdpau-dev node-html5shiv
nsight-compute nsight-systems nvidia-cuda-dev nvidia-cuda-doc nvidia-cuda-gdb
nvidia-cuda-toolkit nvidia-opencl-dev nvidia-profiler nvidia-visual-profiler ocl-icd-opencl-dev
opencl-c-headers
0 upgraded, 53 newly installed, 0 to remove and 0 not upgraded.
Need to get 1399 MB of archives.
After this operation, 3750 MB of additional disk space will be used.
Do you want to continue? [Y/n] y


mario@marietto:/home/mario# nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Sun_Jul_28_19:07:16_PDT_2019
Cuda compilation tools, release 10.1, V10.1.243

mario@marietto:/home/mario# nvidia-smi
Could not find command-not-found database. Run 'sudo apt update' to populate it.
nvidia-smi: command not found

mario@marietto:/home/mario# apt install nvidia-settings

Reading package lists... Done
Building dependency tree    
Reading state information... Done

The following additional packages will be installed:
python3-xkit screen-resolution-extra
The following NEW packages will be installed:
nvidia-settings python3-xkit screen-resolution-extra



mario@marietto:/home/mario# nvidia-smi              
Could not find command-not-found database. Run 'sudo apt update' to populate it.
nvidia-smi: command not found

mario@marietto:/home/mario# nvidia-settings
nvidia-settings: error while loading shared libraries: libXNVCtrl.so.0: cannot open shared object file: No such file or directory

mario:/home/mario# apt install nvidia-driver-440

Reading package lists... Done
Building dependency tree        
Reading state information... Done

The following additional packages will be installed:
  libnvidia-cfg1-440 libnvidia-common-440 libnvidia-compute-440 libnvidia-decode-440
  libnvidia-encode-440 libnvidia-extra-440 libnvidia-fbc1-440 libnvidia-gl-440 libnvidia-ifr1-440
  nvidia-compute-utils-440 nvidia-dkms-440 nvidia-kernel-common-440 nvidia-kernel-source-440
  nvidia-prime nvidia-utils-440 xserver-xorg-video-nvidia-440

Get:17 http://archive.ubuntu.com/ubuntu focal/main amd64 nvidia-prime all 0.8.14 [9164 B]          
Fetched 101 MB in 31s (3204 kB/s)                                                                  
dpkg: libnvidia-compute-435:amd64: dependency problems, but removing anyway as you requested:
 libcuinj64-10.1:amd64 depends on libcuda1 (>= 418.39) | libnvidia-tesla-cuda1 (>= 418.39) | libcuda
.so.1 (>= 418.39) | libcuda-10.1-1; however:
  Package libcuda1 is not installed.
  Package libnvidia-compute-435:amd64 which provides libcuda1 is to be removed.
  Package libnvidia-tesla-cuda1 is not installed.
  Package libcuda.so.1 is not installed.
  Package libcuda-10.1-1 is not installed.
  Package libnvidia-compute-435:amd64 which provides libcuda-10.1-1 is to be removed.
 libcuinj64-10.1:amd64 depends on libcuda1 (>= 418.39) | libnvidia-tesla-cuda1 (>= 418.39) | libcuda
.so.1 (>= 418.39) | libcuda-10.1-1; however:
  Package libcuda1 is not installed.
  Package libnvidia-compute-435:amd64 which provides libcuda1 is to be removed.
  Package libnvidia-tesla-cuda1 is not installed.
  Package libcuda.so.1 is not installed.
  Package libcuda-10.1-1 is not installed.
  Package libnvidia-compute-435:amd64 which provides libcuda-10.1-1 is to be removed.
 libnvidia-ml-dev depends on libnvidia-ml1 (>= 418.39) | libnvidia-tesla-440-ml1 (>= 418.39) | libnv
idia-tesla-418-ml1 (>= 418.39) | libnvidia-ml.so.1 (>= 418.39); however:
  Package libnvidia-ml1 is not installed.
  Package libnvidia-compute-435:amd64 which provides libnvidia-ml1 is to be removed.
  Package libnvidia-tesla-440-ml1 is not installed.
  Package libnvidia-tesla-418-ml1 is not installed.
  Package libnvidia-ml.so.1 is not installed.

Setting up libnvidia-cfg1-440:amd64 (440.82+really.440.64-0ubuntu6) ...
Setting up nvidia-kernel-source-440 (440.82+really.440.64-0ubuntu6) ...
Setting up nvidia-prime (0.8.14) ...
Setting up libnvidia-extra-440:amd64 (440.82+really.440.64-0ubuntu6) ...
Setting up libnvidia-common-440 (440.82+really.440.64-0ubuntu6) ...
Setting up libnvidia-fbc1-440:amd64 (440.82+really.440.64-0ubuntu6) ...
Setting up libnvidia-compute-440:amd64 (440.82+really.440.64-0ubuntu6) ...
Setting up nvidia-kernel-common-440 (440.82+really.440.64-0ubuntu6) ...
Setting up xserver-xorg-video-nvidia-440 (440.82+really.440.64-0ubuntu6) ...
Setting up libnvidia-decode-440:amd64 (440.82+really.440.64-0ubuntu6) ...
Setting up nvidia-utils-440 (440.82+really.440.64-0ubuntu6) ...
Setting up libnvidia-gl-440:amd64 (440.82+really.440.64-0ubuntu6) ...
Setting up nvidia-compute-utils-440 (440.82+really.440.64-0ubuntu6) ...
Warning: The home dir /nonexistent you specified can't be accessed: No such file or directory
Adding system user `nvidia-persistenced' (UID 116) ...
Adding new group `nvidia-persistenced' (GID 125) ...
Adding new user `nvidia-persistenced' (UID 116) with group `nvidia-persistenced' ...
Not creating home directory `/nonexistent'.
Setting up nvidia-dkms-440 (440.82+really.440.64-0ubuntu6) ...
INFO:Enable nvidia
DEBUG:/usr/share/ubuntu-drivers-common/quirks does not exist
/var/lib/dpkg/info/nvidia-dkms-440.postinst: 140: /usr/lib/dkms/common.postinst: not found
dpkg: error processing package nvidia-dkms-440 (--configure):
 installed nvidia-dkms-440 package post-installation script subprocess returned error exit status 12
7
Setting up libnvidia-encode-440:amd64 (440.82+really.440.64-0ubuntu6) ...
dpkg: dependency problems prevent configuration of nvidia-driver-440:
 nvidia-driver-440 depends on nvidia-dkms-440 (= 440.82+really.440.64-0ubuntu6) | nvidia-dkms-440 (=
 440.82+really.440.64-0ubuntu4); however:
  Package nvidia-dkms-440 is not configured yet.
  Version of nvidia-dkms-440 on system is 440.82+really.440.64-0ubuntu6.

dpkg: error processing package nvidia-driver-440 (--configure):
 dependency problems - leaving unconfigured
Setting up libnvidia-ifr1-440:amd64 (440.82+really.440.64-0ubuntu6) ...
Processing triggers for man-db (2.9.1-1) ...
No apport report written because the error message indicates its a followup error from a previous fa
ilure.
      Processing triggers for libc-bin (2.31-0ubuntu9) ...
Errors were encountered while processing:
 nvidia-dkms-440
 nvidia-driver-440
E: Sub-process /usr/bin/dpkg returned an error code (1)
```


----------



## shkhln (Jul 20, 2022)

ziomario said:


> explain in easy understandable terms


I was under impression I'm already doing that. There are multiple pieces involved: a few kernel modules (nvidia.ko and nvidia-uvm.ko), core (libcuda.so) and additional (libcufft.so and so on) shared libs and, of course, the compiler (nvcc). The aforementioned change specifically addresses the bit of code required to use libcuda.so, but not necessarily any other components. Whether that is enough for you depends on the particular application you want to use. Say, Darktable (an OpenCL application) and OBS Studio should be usable already (with my userspace hack, that is), on the other hand Blender requires nvcc, so it wouldn't be.


----------



## ziomario (Jul 20, 2022)

Thanks. Now I understand a little bit more. I'm interested in running for example Blender and Maya. So,for me the problem is how to run nvcc.  yesterday I have installed nvcc :



```
mario@marietto:/home/mario# nvcc --version

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Sun_Jul_28_19:07:16_PDT_2019
Cuda compilation tools, release 10.1, V10.1.243
```

so,can you explain in which context nvcc should run ? because as u can see within the linuxulator it works. And if works with it,is it really hard to make it work even natively ? what are the piece of code missing ? Im really interested also to try your userspace hack).


----------



## shkhln (Jul 20, 2022)

So far:

 nvcc should be available at /usr/local/cuda/bin/nvcc.
 Blender should be started with `env CYCLES_CUDA_EXTRA_CFLAGS="-ccbin /path/to/cc-wrapper.sh" nv-sglrun blender`
 cc-wrapper.sh looks like:

```
#!/bin/sh
exec env /compat/linux/bin/env PATH="/compat/linux/bin:$PATH" /compat/linux/opt/rh/devtoolset-9/root/usr/bin/gcc --sysroot /compat/linux "$@"
```

 That version of Linux gcc was installed from the devtoolset-9-gcc-9.3.1_1 CentOS package, which isn't actually available as a port. I'm not going to submit it.


----------



## ziomario (Jul 20, 2022)

If I have understood correctly,before to use the wrapper,I should apply your userspace hack ? Where is located and how can I install it ?


----------



## shkhln (Jul 20, 2022)

`pkg install linux-nvidia-libs libc6-shim`, `nv-sglrun nvidia-smi`. Note the change in reported CUDA version.


----------



## ziomario (Jul 20, 2022)

```
mario@marietto:/home/marietto/Desktop/Files/CUDA/libc6-shim/bin # ./nv-sglrun nvidia-smi

shim init
Wed Jul 20 20:05:51 2022       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 510.60.02    Driver Version: 510.60.02    CUDA Version: 11.6     |
|-------------------------------+----------------------+----------------------+
| 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:02:00.0 Off |                  N/A |
| 46%   63C    P0    77W / 250W |      0MiB / 11264MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+
```


----------



## jbo (Jul 20, 2022)

ziomario

Please stop deleting the contents of your posts and replacing it with "a".

If your content is not worth keeping alive don't post it to begin.
If you accidentially posted something worth deleting (such as "sensitive" information) ask staff to delete the post.


----------



## ziomario (Jul 20, 2022)

jbodenmann said:


> ziomario
> 
> Please stop deleting the contents of your posts and replacing it with "a".
> 
> ...



The content that I have posted was good at the beginning,but then it stopped to be valid. I can't remove it by myself,so I have temporarely changed it with a letter. Now I'm going to report it,but I presume that you know that this procedure can't be immediate,since I can't remove the post by myself. I know what to do. Stop to tell me stop. If you want the content to be removed faster,change the method. Allow me to remove it by my self and I will be faster.


----------



## jbo (Jul 20, 2022)

ziomario said:


> Allow me to remove it by my self and I will be faster.


No, just don't post stuff that is "invalid" within the blink of an eye.

It happens to everyone once in a while. There is in general nothing wrong to post something and following up later that the previous information no longer applies, was incorrect or anything along those lines.
The "issue" is that you seem to just post whatever whenever.

This forum is not a race. You don't get extra points for posting more or faster. In fact, if anything, quite the contrary.


----------



## shkhln (Jul 20, 2022)

Post removal was working just fine not so long ago, which means it either was broken on the forum upgrade or was massively abused and thus disabled. SirDice, any idea?


----------



## ziomario (Jul 20, 2022)

jbodenmann said:


> No, just don't post stuff that is "invalid" within the blink of an eye.
> 
> It happens to everyone once in a while. There is in general nothing wrong to post something and following up later that the previous information no longer applies, was incorrect or anything along those lines.
> The "issue" is that you seem to just post whatever whenever.
> ...



I disagree with you. Only two posts were not valid. I meant that it does not depend by me the speed with which the post is removed. I don't want to make a challenge with anyone. Make a phone call to the moderator and tell him to be faster. And I can't know from the beginning which contents will be invalid after some time.


----------



## SirDice (Jul 20, 2022)

shkhln said:


> or was massively abused and thus disabled.


Aye, this was the reason. So deleting has been limited. You should still be able to delete the occasional post, we've all posted something and immediately regretted it. Mass deletions however aren't possible any more.



ziomario said:


> I disagree with you.


I strongly suggest listening to jbodenmann 



ziomario said:


> And I can't know from the beginning which contents will be invalid after some time.


Sure, but then it's more proper to do a follow-up post, which explains what was wrong. You don't go around posting willy-nilly, then removing said posts because you think they were "wrong".


----------



## ziomario (Jul 20, 2022)

SirDice said:


> Aye, this was the reason. So deleting has been limited. You should still be able to delete the occasional post, we've all posted something and immediately regretted it. Mass deletions however aren't possible any more.



if someone wants to remove two posts in a row,it is considered a mass deletion ?


----------



## eternal_noob (Jul 20, 2022)

For questions about the forum itself we have a dedicated sub-forum









						Feedback (about the Forums)
					

Share your ideas, questions or suggestions regarding The FreeBSD Forums with us here.




					forums.freebsd.org
				




Stop spamming your own threads


----------



## ziomario (Jul 20, 2022)

Anyway,coming back to the thread,I tried to install the devtoolset inside the centos distro,with this command :


```
bash-4.2# rpm -i devtoolset-9-gcc-9.3.1-2.2.el7.x86_64.rpm
bash: rpm: command not found
```

but I see that I can't do it. Can you explain a little bit how can I install rpm ? thanks.


----------



## eternal_noob (Jul 20, 2022)

Maybe convert it using alien









						How to Convert .rpm package to .deb using alien Package Converter? - GeeksforGeeks
					

A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.




					www.geeksforgeeks.org


----------



## ziomario (Jul 20, 2022)

eternal_noob said:


> Maybe convert it using alien
> 
> 
> 
> ...




```
bash-4.2# apt-get install
bash: apt-get: command not found

bash-4.2# ping google.it
bash: ping: command not found
```

inside the centos distribution installed by shkhln a lot of components are missing. Converting the rpm package to deb for achieving which purpoise ?


----------



## eternal_noob (Jul 20, 2022)

To install the package. And don't convert it to *.deb but to *.tgz. You then could simply decompress it.


----------



## ziomario (Jul 20, 2022)

Ok. A little of creativity. I've used an ubuntu 20.04 distro,instead of the centos and I have changed the wrapper script like this :


```
#!/bin/sh
exec env /compat/ubuntu/usr/bin/env PATH="/compat/ubuntu/bin:$PATH" /compat/ubuntu/usr/bin/gcc --sysroot /compat/ubuntu "$@"
```

and then I've ran it :


```
# ./cuda-blender-wrapper

gcc: fatal error: no input files
compilation terminated.
```

maybe it worked. But now,what should I do ? keep in consideration that what I want to do is that blender recognizes the CUDA libraries and then it can uses them to render my projects.


----------



## shkhln (Jul 20, 2022)

ziomario said:


> inside the centos distribution installed by shkhln a lot of components are missing.


I'm not doing anything unusual. If I don't have something I simply make a port for it on the spot using some existing linux-c7-* port as a template. That doesn't mean I want to submit those ports to the collection or maintain them.


----------



## ziomario (Jul 20, 2022)

ok. you can do whatever you want. But what I should I do now ? I've reached the end of your tutorial and I would like to know what to do to allow Blender to recognizes the CUDA libraries. I would like to render my projects using CUDA on FreeBSD. This would be very nice.


----------



## ziomario (Jul 20, 2022)

Maybe I have understood. The nvcc compiler is for you. But for me as final user,it is not useful,right ? According with the picture below,it just works like this. It seems that it recognizes CUDA without doing anything else. (In my case it does not work because I'm using the intel gpu as primary,I suppose). So,very very thanks. To be able to do this has been my first desire when I've jumped from Linux to FreeBSD. You are cool.

PS : maybe I will try to see if I can render even with the trial of Arnold / Maya 2022. So cool,man to use Maya on FreeBSD.


----------



## shkhln (Jul 20, 2022)

You aren't even starting Blender with the `nv-sglrun` script as you were _explicitly_ told. What gives?


----------



## shkhln (Jul 20, 2022)

Also try

```
% sh
$ env LD_LIBMAP="`nv-sglrun printenv LD_LIBMAP | grep -v libGL`" blender
```


----------



## eternal_noob (Jul 20, 2022)

ziomario said:


> So cool,man to use Maya on FreeBSD.


In every 2nd thread of yours you tell us that you are poor and don't have money. But you can afford several thousands of Euros a year to run Maya?


----------



## ziomario (Jul 20, 2022)

eternal_noob said:


> In every 2nd thread of yours you tell us that you are poor and don't have money. But you can afford several thousands of Euros a year to run Maya?



Do you really think that I can and I want to spend 2000 euros to buy the maya license ? Even if I was rich. I'm talking about the trial,that should be the student license. If should allow to use Maya for free for 1 year.


----------



## eternal_noob (Jul 20, 2022)

Just wanted to make sure you're not telling fairy tales.


----------



## ziomario (Jul 20, 2022)

shkhln said:


> You aren't even starting Blender with the `nv-sglrun` script as you were _explicitly_ told. What gives?




```
# ./nv-sglrun /compat/ubuntu/usr/bin/blender

/compat/ubuntu/usr/bin/blender: error while loading shared libraries: libtbb.so.2: cannot open shared object file: No such file or directory
```


----------



## ziomario (Jul 20, 2022)

shkhln said:


> Also try
> 
> ```
> % sh
> ...




```
sh

env LD_LIBMAP="`nv-sglrun printenv LD_LIBMAP | grep -v libGL`" blender
shim init

XDG_RUNTIME_DIR (/var/run/user/1001) is not owned by us (uid 0), but by uid 1001! (This could e.g. happen if you try to connect to a non-root PulseAudio as a root user, over the native protocol. Don't do that.)
```

and Blender started. I forgot to write sh


----------



## eternal_noob (Jul 20, 2022)

Yeah, how about installing those missing libraries?


----------



## ziomario (Jul 20, 2022)

```
# nv-sglrun blender

shim init
XDG_RUNTIME_DIR (/var/run/user/1001) is not owned by us (uid 0), but by uid 1001! (This could e.g. happen if you try to connect to a non-root PulseAudio as a root user, over the native protocol. Don'tdo that.)

shim_openat is not implemented
0x815d3be24 <openat+0x44> at /usr/local/lib/libc6-shim/libc6.so
0x816c72cea <_nv011glcore+0x2922a> at /compat/linux/usr/lib64/libnvidia-glcore.so.510.60.02
0x816c62213 <_nv011glcore+0x18753> at /compat/linux/usr/lib64/libnvidia-glcore.so.510.60.02
0x816c716f8 <_nv011glcore+0x27c38> at /compat/linux/usr/lib64/libnvidia-glcore.so.510.60.02
0x811c7ddce <vk_icdNegotiateLoaderICDInterfaceVersion+0x60e> at /root/.cache/nv-sglrun/78c27f68033b2
8c791e31ce5c83474e38a55302492834452fdbf39e3f210fb63_libGLX_nvidia.so.510.60.02.patched
0x811c7ee78 <vk_icdNegotiateLoaderICDInterfaceVersion+0x16b8> at /root/.cache/nv-sglrun/78c27f68033b
28c791e31ce5c83474e38a55302492834452fdbf39e3f210fb63_libGLX_nvidia.so.510.60.02.patched
0x811c6150c <glXCreateGLXPbufferSGIX+0x7eac> at /root/.cache/nv-sglrun/78c27f68033b28c791e31ce5c8347
4e38a55302492834452fdbf39e3f210fb63_libGLX_nvidia.so.510.60.02.patched
0x816c4a036 <_nv011glcore+0x576> at /compat/linux/usr/lib64/libnvidia-glcore.so.510.60.02
0x816c4bdb9 <_nv011glcore+0x22f9> at /compat/linux/usr/lib64/libnvidia-glcore.so.510.60.02
0x816c90047 <_nv012glcore+0x3397> at /compat/linux/usr/lib64/libnvidia-glcore.so.510.60.02
0x816c4d9c5 <_nv011glcore+0x3f05> at /compat/linux/usr/lib64/libnvidia-glcore.so.510.60.02
0x811c25423 <???> at /root/.cache/nv-sglrun/78c27f68033b28c791e31ce5c83474e38a55302492834452fdbf39e3f210fb63_libGLX_nvidia.so.510.60.02.patched
0x811c6095f <glXCreateGLXPbufferSGIX+0x72ff> at /root/.cache/nv-sglrun/78c27f68033b28c791e31ce5c83474e38a55302492834452fdbf39e3f210fb63_libGLX_nvidia.so.510.60.02.patched
0x3a298c4 <_ZN16GHOST_ContextGLX24initializeDrawingContextEv+0x3c4> at /usr/local/bin/blender-bin
0x3a2845c <_ZN15GHOST_WindowX1117newDrawingContextE25GHOST_TDrawingContextType+0x9c> at /usr/local/bin/blender-bin
0x3a24272 <_ZN12GHOST_Window21setDrawingContextTypeE25GHOST_TDrawingContextType+0x42> at /usr/local/bin/blender-bin
0x3a26086<_ZN15GHOST_WindowX11C1EP15GHOST_SystemX11P9_XDisplayPKciijj18GHOST_TWindowStatePS_25GHOST_TDrawingContextTypebbbbb+0x8d6> at /usr/local/bin/blender-bin
0x3a1c16a<_ZN15GHOST_SystemX1112createWindowEPKciijj18GHOST_TWindowState25GHOST_TDrawingContextType16GHOST_GLSettingsbbPK13GHOST_IWindow+0x9a> at /usr/local/bin/blender-bin
0x3a1a126 <GHOST_CreateWindow+0x46> at /usr/local/bin/blender-bin
0x28e9feb <wm_window_ghostwindows_ensure+0x23b> at /usr/local/bin/blender-bin
0x28e9e2d <wm_window_ghostwindows_ensure+0x7d> at /usr/local/bin/blender-bin
0x28a34d3 <WM_check+0xb3> at /usr/local/bin/blender-bin
0x28b5fde <wm_homefile_read_ex+0x81e> at /usr/local/bin/blender-bin
0x28d06f7 <WM_init+0x157> at /usr/local/bin/blender-bin

Assertion failed: (0), function shim_openat, file build/wrappers64.c, line 28381.
Abort trap (core dumped)
```


----------



## shkhln (Jul 20, 2022)

ziomario said:


> ```
> # ./nv-sglrun /compat/ubuntu/usr/bin/blender
> 
> /compat/ubuntu/usr/bin/blender: error while loading shared libraries: libtbb.so.2: cannot open shared object file: No such file or directory
> ```


We aren't talking about the Linux Blender package.



ziomario said:


> ```
> sh
> 
> env LD_LIBMAP="`nv-sglrun printenv LD_LIBMAP | grep -v libGL`" blender
> ...


That's probably good enough, although I don't see the reason to run that application as root. Now you should see the GPU in the settings. What about the compiler?



ziomario said:


> ```
> Assertion failed: (0), function shim_openat, file build/wrappers64.c, line 28381.
> ```


Meh. Not relevant to this use case.


----------



## ziomario (Jul 20, 2022)

```
[marietto@marietto ~/Desktop/Files/CUDA/libc6-shim/bin]$ ./nv-sglrun /usr/local/bin/blender

shim init
shim_openat is not implemented
0x815d3c384 <openat+0x44> at /home/marietto/Desktop/Files/CUDA/libc6-shim/lib64/libc6.so
0x816c72cea <_nv011glcore+0x2922a> at /compat/linux/usr/lib64/libnvidia-glcore.so.510.60.02
0x816c62213 <_nv011glcore+0x18753> at /compat/linux/usr/lib64/libnvidia-glcore.so.510.60.02
0x816c716f8 <_nv011glcore+0x27c38> at /compat/linux/usr/lib64/libnvidia-glcore.so.510.60.02
0x811c7ddce <vk_icdNegotiateLoaderICDInterfaceVersion+0x60e> at /compat/linux/usr/lib64/libGLX_nvidi
a.so.510.60.02
0x811c7ee78 <vk_icdNegotiateLoaderICDInterfaceVersion+0x16b8> at /compat/linux/usr/lib64/libGLX_nvid
ia.so.510.60.02
0x811c6150c <glXCreateGLXPbufferSGIX+0x7eac> at /compat/linux/usr/lib64/libGLX_nvidia.so.510.60.02
0x816c4a036 <_nv011glcore+0x576> at /compat/linux/usr/lib64/libnvidia-glcore.so.510.60.02
0x816c4bdb9 <_nv011glcore+0x22f9> at /compat/linux/usr/lib64/libnvidia-glcore.so.510.60.02
0x816c90047 <_nv012glcore+0x3397> at /compat/linux/usr/lib64/libnvidia-glcore.so.510.60.02
0x816c4d9c5 <_nv011glcore+0x3f05> at /compat/linux/usr/lib64/libnvidia-glcore.so.510.60.02
0x811c25423 <???> at /compat/linux/usr/lib64/libGLX_nvidia.so.510.60.02
0x811c6095f <glXCreateGLXPbufferSGIX+0x72ff> at /compat/linux/usr/lib64/libGLX_nvidia.so.510.60.02
0x3a298c4 <_ZN16GHOST_ContextGLX24initializeDrawingContextEv+0x3c4> at /usr/local/bin/blender-bin
0x3a2845c <_ZN15GHOST_WindowX1117newDrawingContextE25GHOST_TDrawingContextType+0x9c> at /usr/local/b
in/blender-bin
0x3a24272 <_ZN12GHOST_Window21setDrawingContextTypeE25GHOST_TDrawingContextType+0x42> at /usr/local/
bin/blender-bin
0x3a26086 <_ZN15GHOST_WindowX11C1EP15GHOST_SystemX11P9_XDisplayPKciijj18GHOST_TWindowStatePS_25GHOST
_TDrawingContextTypebbbbb+0x8d6> at /usr/local/bin/blender-bin
0x3a1c16a <_ZN15GHOST_SystemX1112createWindowEPKciijj18GHOST_TWindowState25GHOST_TDrawingContextType
16GHOST_GLSettingsbbPK13GHOST_IWindow+0x9a> at /usr/local/bin/blender-bin
0x3a1a126 <GHOST_CreateWindow+0x46> at /usr/local/bin/blender-bin
0x28e9feb <wm_window_ghostwindows_ensure+0x23b> at /usr/local/bin/blender-bin
0x28e9e2d <wm_window_ghostwindows_ensure+0x7d> at /usr/local/bin/blender-bin
0x28a34d3 <WM_check+0xb3> at /usr/local/bin/blender-bin
0x28b5fde <wm_homefile_read_ex+0x81e> at /usr/local/bin/blender-bin
0x28d06f7 <WM_init+0x157> at /usr/local/bin/blender-bin
Assertion failed: (0), function shim_openat, file build/wrappers64.c, line 28381.
Abort trap
```


```
[marietto@marietto ~/Desktop/Files/CUDA/libc6-shim/bin]$ sh
marietto@marietto:~/Desktop/Files/CUDA/libc6-shim/bin $ env LD_LIBMAP="`nv-sglrun printenv LD_LIBMAP | grep -v libGL`" blender
shim init
```


----------



## shkhln (Jul 21, 2022)

Does anything else work? clpeak?


----------



## monwarez (Jul 21, 2022)

I remember that for some time with the nvidia-driver on a laptop I could not use libc6-shim without implementing openat,
you can try to use this patch https://github.com/monwarez/libc6-shim/commit/7e3dffc13d33e03cd18904c6e711595b5ade72e0
Note that this implementation of openat is not correct if the path is relative, it only work with absolute path (I use the FreeBSD behavior of openat with an absolute path which is to return open).


----------



## ziomario (Jul 21, 2022)

```
# ./nv-sglrun clpeak

shim init

Platform: NVIDIA CUDA
Device: NVIDIA GeForce RTX 2080 Ti
Driver version  : 510.60.02 (FreeBSD)
Compute units   : 68
Clock frequency : 1545 MHz

Global memory bandwidth (GBPS)
float   : 505.37
float2  : 533.31
float4  : 549.07
float8  : 551.19
float16 : 490.40

Single-precision compute (GFLOPS)
float   : 16545.49
float2  : 16510.95
float4  : 16474.07
float8  : 16404.12
float16 : 16286.54

No half precision support! Skipped

Double-precision compute (GFLOPS)
double   : 517.78
double2  : 517.22
double4  : 515.99
double8  : 513.54
double16 : 508.64

Integer compute (GIOPS)
int   : 14938.30
int2  : 14721.25
int4  : 14851.60
int8  : 14891.99
int16 : 14646.05

Integer compute Fast 24bit (GIOPS)
int   : 14399.28
int2  : 14631.37
int4  : 14689.85
int8  : 14741.36
int16 : 14586.65

Transfer bandwidth (GBPS)
enqueueWriteBuffer              : 6.14
enqueueReadBuffer               : 6.51
enqueueWriteBuffer non-blocking : 6.03
enqueueReadBuffer non-blocking  : 6.41
enqueueMapBuffer(for read)      : 6.24
memcpy from mapped ptr        : 11.54
enqueueUnmap(after write)       : 6.50
memcpy to mapped ptr          : 11.46

Kernel launch latency : 5.64 us

Device: NVIDIA GeForce GTX 1060 3GB
Driver version  : 510.60.02 (FreeBSD)
Compute units   : 9
Clock frequency : 1708 MHz

Global memory bandwidth (GBPS)
float   : 149.99
float2  : 156.75
float4  : 159.40
float8  : 159.04
float16 : 103.58

Single-precision compute (GFLOPS)
float   : 4043.46
float2  : 4169.39
float4  : 4156.42
float8  : 4129.98
float16 : 4111.27

No half precision support! Skipped

Double-precision compute (GFLOPS)
double   : 133.86
double2  : 133.51
double4  : 133.19
double8  : 132.91
double16 : 131.64

Integer compute (GIOPS)
int   : 1355.11
int2  : 1348.88
int4  : 1350.11
int8  : 1256.30
int16 : 1231.96

Integer compute Fast 24bit (GIOPS)
int   : 1350.68
int2  : 1341.06
int4  : 1345.51
int8  : 1340.86
int16 : 1323.04

Transfer bandwidth (GBPS)
enqueueWriteBuffer              : 1.52
enqueueReadBuffer               : 1.64
enqueueWriteBuffer non-blocking : 1.50
enqueueReadBuffer non-blocking  : 1.63
enqueueMapBuffer(for read)      : 1.63
memcpy from mapped ptr        : 11.91
enqueueUnmap(after write)       : 1.53
memcpy to mapped ptr          : 12.02

Kernel launch latency : 6.94 us
```


----------



## ziomario (Jul 21, 2022)

I've applied the @monwarez patches and I gave a make : I didn't see errors. I hope that I made the right choice, shkhln...

If I remember correctly,blender will not recognize the Nvidia gpu until it becomes the main gpu and now my main gpu is the intel. There is a trick to do this but I don't remember.


----------



## shkhln (Jul 21, 2022)

Let's try `env __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia LD_LIBMAP="`nv-sglrun printenv LD_LIBMAP | grep -v libGL`" blender` then.


----------



## ziomario (Jul 21, 2022)

No compatible GPUs found for Cycles. Requires NVIDIA GPU with compute capacibility 3.0.
I would like to exclude that this is not a specific behavior of Blender. Do you know another CG tool that could use the nvida gpu ? Maybe OBS,but there should be written somewhere,in the OBS parameters that it is using the nvidia gpu.


----------



## ziomario (Jul 21, 2022)

Bingo !

```
[marietto@marietto ~/Desktop/Files/CUDA/libc6-shim/bin]$ env __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia LD_LIBMAP="`nv-sglrun printenv LD_LIBMAP | grep -v libGL`" obs

shim init

Attempted path: share/obs/obs-studio/locale/en-US.ini
Attempted path: /usr/local/share/obs/obs-studio/locale/en-US.ini
Attempted path: share/obs/obs-studio/locale.ini
Attempted path: /usr/local/share/obs/obs-studio/locale.ini
Attempted path: share/obs/obs-studio/themes/Dark.qss
Attempted path: /usr/local/share/obs/obs-studio/themes/Dark.qss
info: CPU Name: Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz
info: CPU Speed: 3600.00MHz
info: Physical Cores: 8, Logical Cores: 16
info: Physical Memory: 31615MB Total, 26159MB Free
info: Kernel Version: FreeBSD 13.1-RELEASE
info: Window System: X11.0, Vendor: The X.Org Foundation, Version: 1.20.14
info: Qt Version: 5.15.5 (runtime), 5.15.5 (compiled)
info: Portable mode: false
Attempted path: share/obs/obs-studio/themes/Dark/no_sources.svg
Attempted path: /usr/local/share/obs/obs-studio/themes/Dark/no_sources.svg
QMetaObject::connectSlotsByName: No matching signal for on_tbar_position_valueChanged(int)
QMetaObject::connectSlotsByName: No matching signal for on_actionShowTransitionProperties_triggered()
QMetaObject::connectSlotsByName: No matching signal for on_actionHideTransitionProperties_triggered()
info: OBS 27.2.4 (freebsd)
info: ---------------------------------
info: ---------------------------------
info: audio settings reset:
        samples per sec: 48000
        speakers:        2
info: ---------------------------------
info: Initializing OpenGL...
info: Loading up OpenGL on adapter NVIDIA Corporation NVIDIA GeForce RTX 2080 Ti/PCIe/SSE2
info: OpenGL loaded successfully, version 3.3.0 NVIDIA 510.60.02, shading language 3.30 NVIDIA via Cg compiler
info: ---------------------------------
```

So,the mystery is still unresolved. Why OBS detects the RTX-2080 Ti and blender does not.


----------



## shkhln (Jul 21, 2022)

Now you either have to set up the compiler or you can go the lazy asshole way and copy the precompiled Cycles CUDA kernels from 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. (I didn't realize they were part of the distribution. Sorry about that.)


----------



## shkhln (Jul 21, 2022)

ziomario said:


> No compatible GPUs found for Cycles. Requires NVIDIA GPU with compute capacibility 3.0.


Oh, sorry. Didn't immediately read that one. Still not working? Like really?


----------



## jbo (Jul 21, 2022)

This post might very well be unnecessary but just in case: I get the feeling that OP is running blender inside of Linux - either via a VM with patched GPU passthrough, via a Linux jail or just Linux compatibility layer.
At the same time, I feel like the efforts presented by shkhln are geared towards running Blender directly on FreeBSD.

Are you guys talking the same scenarios here?


----------



## ziomario (Jul 21, 2022)

jbodenmann said:


> This post might very well be unnecessary but just in case: I get the feeling that OP is running blender inside of Linux - either via a VM with patched GPU passthrough, via a Linux jail or just Linux compatibility layer.
> At the same time, I feel like the efforts presented by shkhln are geared towards running Blender directly on FreeBSD.
> 
> Are you guys talking the same scenarios here?



Nope. I'm out of any jail and I don't use the Linuxlator. I've installed blender and obs from the freebsd ports.


```
[marietto@marietto ~/Desktop/Files/CUDA/libc6-shim/bin]$ uname -a
FreeBSD marietto 13.1-RELEASE FreeBSD 13.1-RELEASE n250232-e981f9a8e335 GENERIC amd64

[marietto@marietto ~/Desktop/Files/CUDA/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
```


----------



## shkhln (Jul 21, 2022)

jbodenmann said:


> This post might very well be unnecessary but just in case: I get the feeling that OP is running blender inside of Linux - either via a VM with patched GPU passthrough, via a Linux jail or just Linux compatibility layer.


You can see the switch from Linux to FreeBSD Blender between posts #34 and #35.



jbodenmann said:


> At the same time, I feel like the efforts presented by shkhln are geared towards running Blender directly on FreeBSD.


Indeed.


----------



## ziomario (Jul 21, 2022)

This could be the solution : https://blender.stackexchange.com/questions/156503/rendering-on-command-line-with-gpu

let's see what happens...


----------



## monwarez (Jul 21, 2022)

ziomario said:


> No compatible GPUs found for Cycles. Requires NVIDIA GPU with compute capacibility 3.0.
> I would like to exclude that this is not a specific behavior of Blender. Do you know another CG tool that could use the nvida gpu ? Maybe OBS,but there should be written somewhere,in the OBS parameters that it is using the nvidia gpu.


If you have ffmpeg with nvenc enabled, you can have obs that use the nvidia gpu for encoding

```
...
info: NVENC support
info: FFMPEG VAAPI supported
...
```


----------



## ziomario (Jul 21, 2022)

shkhln said:


> You can see the switch from Linux to FreeBSD Blender between posts #34 and #35.
> 
> 
> Indeed.



I'm sure will come the day when users will start reading //more carefully ? // a little of old messages


----------



## ziomario (Jul 21, 2022)

monwarez said:


> If you have ffmpeg with nvenc enabled, you can have obs that use the nvidia gpu for encoding
> 
> ```
> ...
> ...



How can I enable ffmpeg + nvenc ? because I can't choose the NVIDIA NVENC H.264 as encoder. I don't have that entry. I have ony : 1) FFMPEG VAAPI 2) X264


----------



## ziomario (Jul 21, 2022)

```
[marietto@marietto ~/Desktop/Files/CUDA/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 -P blender-render
```

the script that doesnt produce errors (but the GPU is still not available) is :

```
import bpy

def enable_gpus(device_type, use_cpus=False):
    preferences = bpy.context.preferences
    cycles_preferences = preferences.addons["cycles"].preferences
    cycles_preferences.refresh_devices()
    devices = cycles_preferences.devices

    if not devices:
        raise RuntimeError("Unsupported device type")

    activated_gpus = []
    for device in devices:
        if device.type == "CPU":
            device.use = use_cpus
        else:
            device.use = True
            activated_gpus.append(device.name)
            print('activated gpu', device.name)

    cycles_preferences.compute_device_type = device_type
    bpy.context.scene.cycles.device = "GPU"

    return activated_gpus


enable_gpus("CUDA")
```


----------



## monwarez (Jul 21, 2022)

ziomario said:


> How can I enable ffmpeg + nvenc ? because I can't choose the NVIDIA NVENC H.264 as encoder. I don't have that entry. I have ony : 1) FFMPEG VAAPI 2) X264


You will have to build ffmpeg with nvenc support, for that what I did was to use the following repository as a reference: https://github.com/shkhln/revird-aidivn
I just pick the directory devel/nv-codec-headers, and multimedia/ffmpeg
And then I manually updated ffmpeg so that it is up to date with what we have in the port tree (I used a merge tool for that).


----------



## ziomario (Jul 21, 2022)

monwarez said:


> You will have to build ffmpeg with nvenc support, for that what I did was to use the following repository as a reference: https://github.com/shkhln/revird-aidivn
> I just pick the directory devel/nv-codec-headers, and multimedia/ffmpeg
> And then I manually updated ffmpeg so that it is up to date with what we have in the port tree (I used a merge tool for that).



I have no idea about how to "manually update ffmpeg" without more carefully informations. In the maintime I've cloned the code.


----------



## ziomario (Jul 21, 2022)

We done it. That's cool. Everyone is a monster here. I like this place. How many satisfactions you give to me from 1 year. This place became like my secondary home. Very thanks to every freebsd hackers and lovers. Maybe one day we will meet in the real life if there will be some FreeBSD event in Europe. Who knows.


----------



## ziomario (Jul 21, 2022)

So,if to enable CUDA I can only install a 3d tool from the ports and I cannot install / run it within the linuxlator,I can't try to install maya and I can't try to render any project in maya using arnold and my GPU,because the installation of maya should be made inside the linuxulator chroot. But if you can allow me to invoke the blender (or any other 3d tool) executable from within the linuxulator,in this case I can enjoy myself installing a lot of funny 3d tools,including the unreal engine.


----------



## freezr (Jul 22, 2022)

I read this thread three times and I didn't understand a bit.
To use Blender I dual boot into Linux, it would be cool using Blender + Cuda into FreeBSD.

If you recap step by step what you did to achieve your goal maybe other people can benefit from your experience.

My only concern is all these hoops might make Blender quite unstable to use in a real production...


----------



## ziomario (Jul 22, 2022)

How much experience do you have with FreeBSD ? I think that you should take some confidence with this os,before to try complicated configurations.


----------



## freezr (Jul 22, 2022)

I won't follow your configuration because I don't get the point of many things you do, but this thread is messed up, if you recap and reorganize your stuff maybe some other person can benefit from your experience as you do from other places, think about it before to reply non-sense...


----------



## ziomario (Jul 22, 2022)

Try this :


```
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
```


----------



## eva82414 (Jul 29, 2022)

I wish it was easier to install it


----------



## ziomario (Jul 29, 2022)

I can help you. Tell me what you want to do and which kind of error you get.


----------



## drhowarddrfine (Jul 29, 2022)

eva82414 It looks to me like there's only five commands to get it done.


----------



## ziomario (Jul 29, 2022)

drhowarddrfine said:


> eva82414 It looks to me like there's only five commands to get it done.



Caution. Yours looks like a mental bias. The false belief that if something is easy for you, it is also easy for other users.


----------



## ziomario (Aug 2, 2022)

eternal_noob said:


> For questions about the forum itself we have a dedicated sub-forum
> 
> 
> 
> ...



stop spamming who you think is spamming


----------



## ziomario (Aug 2, 2022)

Seriously,man : we have a different idea about what's the meaning of "spam". I suspect that you make some confusion between some expressed opinions,more or less consistent with the topic and the repeated and unwanted messages for commercial purposes. In my opinion,this is spam. And the messages,even if not strictly related to the topic,they lack of the commercial purpose,so they aren't spam,but some kind of "temporary digressions".


----------



## eternal_noob (Aug 2, 2022)

I just said that questions about the forum itself belong to the appropriate sub-forum.


----------



## ziomario (Aug 2, 2022)

It is also physiological to talk about other aspects not strictly related to technicality, because we are not robots. Who spams wants to make money or he wants to cause annoyance to someone else. For these reasons the meaning assigned to the term spam is negative. Whoever talks about other things does so because his mind contains many more elements and interests than simple purely technical reasoning and these elements sooner or later,they will come out,no matter where you are. If they are deemed psychologically important, they will emerge.


----------



## eternal_noob (Aug 2, 2022)

ziomario said:


> For these reasons the meaning assigned to the term spam is negative.


Lovely Spam! Wonderful Spam!
Lovely Spam! Wonderful Spam
Spa-a-a-a-a-a-a-am
Spa-a-a-a-a-a-a-am
Spa-a-a-a-a-a-a-am
Spa-a-a-a-a-a-a-am
Lovely Spam! (Lovely Spam!)
Lovely Spam! (Lovely Spam!)
Lovely Spam!
Spam, Spam, Spam, Spam!


----------



## ziomario (Aug 2, 2022)

Digression ended. I'm trying to launch maya (one year educational license for linux) using the same tecnique explained by shkhln because I would like that it recognises the CUDA libraries,but I'm doing something bad. Infact :

```
# export PATH="$PATH:/compat/ubuntu/usr/Autodesk/maya/bin"

mario@marietto:/home/marietto/Desktop/Files/CUDA/libc6-shim/bin # echo $PATH
/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin:/compat/ubuntu/usr/Autodesk/maya/bin

mario@marietto:/home/marietto/Desktop/Files/CUDA/libc6-shim/bin # ./nv-sglrun maya

/home/marietto/Desktop/Files/CUDA/libc6-shim/bin/with-glibc-shim:34:in `exec': No such file or directory - maya (Errno::ENOENT)
from /home/marietto/Desktop/Files/CUDA/libc6-shim/bin/with-glibc-shim:34:in `<main>'

buy why it says "No such file or directory" if I have saved the folder where is located the maya executable inside the current FreeBSD PATH ?

Infact the maya executable is located here : /compat/ubuntu/usr/local/bin/maya

when I invoke maya within the linux chroot as root this is what happens :

root@marietto:/usr/local/bin# ./maya
Qt: Session management error: Authentication Rejected, reason : None of the authentication protocols specified are supported and host-based authentication failed

as normal user :

root@marietto:/usr/local/bin# su - marietto

$ maya

qt.qpa.xcb: could not connect to display
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: linuxfb, minimal, offscreen, vnc, xcb.

/usr/local/bin/maya: line 220: 73951 Aborted                 /usr/Autodesk/maya/bin/maya.bin
```

no way,but I think that all of those errors depend about my ignorance. I feel to be close to the solution,but I still need some help from you.


----------



## shkhln (Aug 2, 2022)

nv-sglrun is strictly for FreeBSD executables, Linux apps need a different trick: https://gist.github.com/shkhln/40ef290463e78fb2b0000c60f4ad797e. I'm not personally interested in those Ubuntu chroots, so I won't comment on the corresponding issues.


----------



## ziomario (Aug 2, 2022)

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.


```
# 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)
```


----------



## hsnyder (Aug 20, 2022)

ziomario said:


> Try this :
> 
> 
> ```
> ...


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.


----------



## jbo (Aug 20, 2022)

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.


----------



## ziomario (Aug 20, 2022)

shkhln : is it necessary to build/patch libc6-shim ?


----------



## hsnyder (Aug 20, 2022)

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 (Aug 20, 2022)

ziomario said:


> 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.



hsnyder said:


> If anybody gets `nvcc` working, _please_ let me know











						Can CUDA be installed on FreeBSD now ?
					

Hello to everyone.  I've just read this thread :  https://forums.developer.nvidia.com/t/cuda-and-nv-un-register-os-un-lock-user-pages/174678/13  where has been asked to modify the code of the freebsd driver to support CUDA. I read that it has been done. So,now can we install CUDA on FreeBSD by...




					forums.freebsd.org


----------

