CUDA内核编译失败

CUDA内核编译失败

我有 geforce 1070、ubuntu-studio 16.10 并安装了 CUDA 8(来自这里:https://developer.nvidia.com/cuda-toolkit)。我还安装了 g++ 5 并创建了符号链接

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

但当我尝试在 Blender 中渲染模型时,在“编译 CUDA 内核”后我收到一堆消息。所有日志(从控制台运行)

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 --版本
Blender 2.77 (sub 0)

如何修复?提前致谢。

答案1

这对我适用于 Blender 2.76b (Ubuntu 16.04)

  1. 打开 kernel.cu

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

  1. 找到类似这样的行:

/* 5.0 and 5.2 */

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

可能略有不同,但应该从#elif __CUDA_ARCH___ ==

  1. 将该行更改为: #elif __CUDA_ARCH__ >= 500

这将允许 Blender 为较新的 CUDA 架构进行编译。它可能无法按预期工作,并且您可能会在第一次运行它时收到警告(因为它在编译),但您不会再收到编译错误。此外,这对我而言在装有 Blender 2.76b 和 CUDA 8.0 的 Ubuntu 16.04 上有效

答案2

安装G++ 5解决了该问题。请使用以下命令:

sudo apt install g++-5

答案3

我正在使用带有 Ubuntu 17.04 和 CUDA 8.0 的 Blender 2.78:

  • 安装 g++ 5 不起作用
  • 更改 kernel.cu 不起作用(Blender 2.78 已经有了更改)

但这有效:

  1. 使用“sudo blender”以 sudo 模式运行 Blender。使用 GPU 渲染加载内核,渲染即可正常工作
  2. 然后正常运行 Blender(无需 sudo),GPU 渲染即可正常工作

答案4

根据截至 2020 年 4 月 7 日的 blender 网页,blender 与 gcc 4.7 或更高版本不兼容(https://docs.blender.org/manual/en/latest/render/cycles/gpu_rendering.html

使用 *bunutu 20.04,修改 blender.desktop 启动器为:

CYCLES_CUDA_EXTRA_CFLAGS="-ccbin clang-8" blender

上述命令将启动与 20.04 兼容的 blender 编译器设置。第一次 GPU 渲染需要几分钟来编译 CUDA 渲染器,但之后的渲染将立即运行。NVidia 1080 CUDA 渲染比我以前的 4771 CPU 快 6 倍。

相关内容