Ubuntu – CUDA kernel compilation failed

16.10blendercudanvidia

I have geforce 1070, ubuntu-studio 16.10 and installed CUDA 8 (from here: https://developer.nvidia.com/cuda-toolkit). I also install g++ 5 and make symlink

ln -s /usr/bin/gcc-5 /usr/local/cuda/bin/gcc

but when i try to render model in blender, i got a stack of messages after "Compile CUDA kernel". All log (run from console)

crystal@ustudio:~$ blender
connect failed: No such file or directory
Read new prefs: /home/crystal/.config/blender/2.77/config/userpref.blend
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for 4294967295, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for 4294967295, skipping unlock
AL lib: (WW) ALCjackBackendFactory_init: jack_client_open() failed, 0x11
AL lib: (WW) alc_initconfig: Failed to initialize backend "jack"
read blend: /home/crystal/Downloads/BMW27.blend
skipping driver '-90*brake', automatic scripts are disabled
skipping driver '100*power', automatic scripts are disabled
skipping driver '90*brake', automatic scripts are disabled
skipping driver '-100*power', automatic scripts are disabled
skipping driver '100*power', automatic scripts are disabled
skipping driver '-90*brake', automatic scripts are disabled
skipping driver '90*brake', automatic scripts are disabled
skipping driver '-100*power', automatic scripts are disabled
skipping driver '-90*brake', automatic scripts are disabled
skipping driver '100*power', automatic scripts are disabled
skipping driver '-100*power', automatic scripts are disabled
skipping driver '90*brake', automatic scripts are disabled
skipping driver '100*power', automatic scripts are disabled
skipping driver '-100*power', automatic scripts are disabled
skipping driver '90*brake', automatic scripts are disabled
skipping driver '-90*brake', automatic scripts are disabled
skipping driver '100*power', automatic scripts are disabled
skipping driver '-90*brake', automatic scripts are disabled
skipping driver '-100*power', automatic scripts are disabled
skipping driver '90*brake', automatic scripts are disabled
skipping driver '100*power', automatic scripts are disabled
skipping driver '90*brake', automatic scripts are disabled
skipping driver '-100*power', automatic scripts are disabled
skipping driver '-90*brake', automatic scripts are disabled
CUDA version 8.0 detected, build may succeed but only CUDA 7.5 is officially supported.
Compiling CUDA kernel ...
"/usr/local/cuda/bin/nvcc" -arch=sm_61 -m64 --cubin "/usr/share/blender/scripts/addons/cycles/kernel/kernels/cuda/kernel.cu" -o "/home/crystal/.config/blender/2.77/cache/cycles_kernel_sm61_19BAB894867FFAFF2ADC00F401D5E4EB.cubin" --ptxas-options="-v" --use_fast_math -I"/usr/share/blender/scripts/addons/cycles/kernel" -DNVCC -D__KERNEL_CUDA_VERSION__=80
/usr/share/blender/scripts/addons/cycles/kernel/kernels/cuda/kernel.cu:94:2: error: #error "Unknown or unsupported CUDA architecture, can't determine launch bounds"
 #error "Unknown or unsupported CUDA architecture, can't determine launch bounds"
  ^
/usr/share/blender/scripts/addons/cycles/kernel/kernels/cuda/kernel.cu:112:87: error: division by zero in #if
 #if CUDA_MULTIPRESSOR_MAX_REGISTERS/(CUDA_THREADS_BLOCK_WIDTH*CUDA_THREADS_BLOCK_WIDTH*CUDA_KERNEL_MAX_REGISTERS) > CUDA_MULTIPROCESSOR_MAX_BLOCKS
                                                                                       ^
CUDA kernel compilation failed, see console for details.

Refer to the Cycles GPU rendering documentation for possible solutions:
http://www.blender.org/manual/render/cycles/gpu_rendering.html

skipping driver '100*power', automatic scripts are disabled
skipping driver '90*brake', automatic scripts are disabled
skipping driver '-100*power', automatic scripts are disabled
skipping driver '-90*brake', automatic scripts are disabled
Error: CUDA kernel compilation failed, see console for details.

blender –version
Blender 2.77 (sub 0)

How to fix it? Thanks in advance.

Best Answer

This worked for me on Blender 2.76b (Ubuntu 16.04)

  1. Open kernel.cu

sudo gedit /usr/share/blender/scripts/addons/cycles/kernel/kernels/cuda/kernel.cu

  1. Find the line that looks something like this:

/* 5.0 and 5.2 */

#elif __CUDA_ARCH__ == 500 || __CUDA_ARCH__ == 520

It may be slightly different, but should start with #elif __CUDA_ARCH___ ==

  1. Change that line to: #elif __CUDA_ARCH__ >= 500

This will allow Blender to compile for newer CUDA architectures. It may not work as expected, and you'll probably get warnings the first time you run it (as it compiles), but you won't get the compile error any more. Also, this is working for me on Ubuntu 16.04 with Blender 2.76b and CUDA 8.0