File SUSE-NVIDIA-GPU-rendering.txt of Package blender

NVIDIA GPU rendering on openSUSE

Prerequisites

A CUDA-enabled GPU

If you are designated for this task, determine your exact GPU model with:

$ sudo hwinfo --gfxcard

Look up the model of your card (the part in square brackets of the Model: line
at https://developer.nvidia.com/cuda-gpus.

If the "Compute Capability" level for your GPU is 3.0 at least, you're set.

Install the x11-video-nvidiaG0x driver. 

Please follow https://en.opensuse.org/SDB:NVIDIA_drivers and come back, when
you're ready.

Next, you need to install the cuda libraries from NVIDIA. This is documented
here: https://docs.nvidia.com/cuda/cuda-installation-guide-linux/

Short version (at the time of this writing):

$ sudo zypper addrepo http://developer.download.nvidia.com/compute/cuda/repos/opensuse15/x86_64/cuda-opensuse15.repo
$ sudo zypper refresh
$ sudo zypper install cuda-toolkit-10-2

Be careful, other cuda packages may want to deinstall the NVIDIA driver, which 
would be better avoided at this point.

Please add any user, that want to use NVIDIA GPU rendering, to the video group:

$ sudo usermod -a -G video <userid>

Now set up CUDA environment, e.g. in ~/.bashrc or in /etc/profile.local:

export PATH=/usr/local/cuda-10.2/bin:/usr/local/cuda-10.2/NsightCompute-2019.1${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64:${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

Relogin or reboot to activate these changes.

Optional: verify the installation

As a prepared user (see above), run:

Check, if the correct driver if installed:

$ cat /proc/driver/nvidia/version

Check, if the nvidia compiler is installed correctly:

$ nvcc -V

Install the sample source code in <dir>

$ cuda-install-samples-10.2.sh <dir>

At the time of this writing, gcc9 or later is not supported from CUDA 10.2.
For Tumbleweed, you may want to create compatibility symlinks:

$ ln -s /usr/bin/gcc-7 ~/bin/gcc
$ ln -s /usr/bin/g++-7 ~/bin/g++

Compile the sample code:

$ cd <dir>/NVIDIA_CUDA-10.2_Samples
$ make -k

We run make with the keep going option, because it is expected to fail to
compile a few modules, e.g.:

In file included from cudaNvSci.cpp:12:0:
cudaNvSci.h:14:10: fatal error: nvscibuf.h: No such file or directory
 #include <nvscibuf.h>

Don't bother.

Check the device from CUDA POV:

$ ./bin/x86_64/linux/release/deviceQuery
./bin/x86_64/linux/release/deviceQuery Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: "GeForce GTX 650"

[...]

You're set. Run blender, check Edit -> Preferences -> System -> CUDA
Enable devices to your liking.

Troubleshooting

Check, that user is member of the video group:

$ id

Check driver:

$ cat /proc/driver/nvidia/version
NVRM version: NVIDIA UNIX x86_64 Kernel Module  440.59  Thu Jan 30 01:00:41 UTC 2020
GCC version:  gcc version 9.2.1 20200128 [revision 83f65674e78d97d27537361de1a9d74067ff228d] (SUSE Linux) 

$ nvidia-smi
Sun Feb 23 16:54:48 2020       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 440.59       Driver Version: 440.59       CUDA Version: 10.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 650     Off  | 00000000:01:00.0 N/A |                  N/A |
| 16%   29C    P8    N/A /  N/A |    207MiB /  1991MiB |     N/A      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0                    Not Supported                                       |
+-----------------------------------------------------------------------------+

Check devices and permissions:

$ ls -la /dev/nvidia*
crw-rw----+ 1 root video 195,   0 21. Feb 13:51 /dev/nvidia0
crw-rw----+ 1 root video 195, 255 21. Feb 13:51 /dev/nvidiactl
crw-rw----+ 1 root video 195, 254 21. Feb 13:51 /dev/nvidia-modeset
crw-rw----+ 1 root video 240,   0 21. Feb 13:51 /dev/nvidia-uvm

$ chacl -l /dev/nvidia*
/dev/nvidia0 [u::rw-,u:<userid>:rw-,g::rw-,m::rw-,o::---]
/dev/nvidiactl [u::rw-,u:<userid>:rw-,g::rw-,m::rw-,o::---]
/dev/nvidia-modeset [u::rw-,u:<userid>:rw-,g::rw-,m::rw-,o::---]
/dev/nvidia-uvm [u::rw-,u:<userid>:rw-,g::rw-,m::rw-,o::---]

Problem: gcc 12 unsupported

If blender shows an error during initial compilation of the cuda kernel similar to:
#error -- unsupported GNU version! gcc versions later than 11 are not supported! 
The nvcc flag '-allow-unsupported-compiler' can be used to override this version check; 
however, using an unsupported host compiler may cause compilation failure or incorrect 
run time execution. Use at your own risk.

Solution: 
$ zypper in gcc11{,-c++}
$ cd /usr/local/cuda/bin/
$ ln -s ../../../bin/gcc-11 gcc
$ ln -s ../../../bin/g++-11 g++

At this point, the CUDA kernel should build properly, and CUDA devices should be 
available.

Remember: Blender needs a CUDA "Compute Capability" of 3.0 at least.

As a final resort, create a bug report at https://bugzilla.opensuse.org.

Enjoy!
openSUSE Build Service is sponsored by