Page MenuHome

No devices listed in bpy.context.preferences.addons['cycles'].preferences.devices when running in background mode
Closed, DuplicatePublic


System Information
Hardware: ROG Zephyrus laptop
Operating system: Ubuntu 18.04
Graphics card: GeForce GTX 1070
Nvidia drivers version: 390.77
CUDA version: 9.1.85

Blender Version
2.80 beta, 2757469824bb, blender2.8, 2019-01-18, downloaded from
2.79b release

Short description of error
When running Blender 2.8 from command line in background mode, it is not possible to activate any GPU devices for rendering because
bpy.context.preferences.addons['cycles'].preferences.devices is empty. The rendering will still proceed with CPU.

To debug this, I've come up with a short script:

The logic is adapted from and this same script has been tested to work in following environments:

  • Same machine, Blender 2.79b (lists CPU and GPU)
  • macOS Mojave, Blender 2.8 (lists CPU only)

Additionally, on the same machine, it is possible to see the devices in GUI preferences window:

It may also be worth noting that the debug output produces this:

I0118 19:35:32.273550  2197 device_opencl.cpp:60] CLEW initialization succeeded.
I0118 19:35:32.282517  2197 opencl_util.cpp:779] Enumerating devices for platform NVIDIA CUDA.
I0118 19:35:32.282583  2197 opencl_util.cpp:845] Ignoring device GeForce GTX 1070, not officially supported yet.
I0118 19:35:32.282691  2197 device_cuda.cpp:2390] CUEW initialization succeeded
I0118 19:35:32.282703  2197 device_cuda.cpp:2392] Found precompiled kernels
I0118 19:35:32.284847  2197 device_cuda.cpp:2513] Added device "GeForce GTX 1070" with id "CUDA_GeForce GTX 1070_0000:01:00".
Using device: CUDA

Which apparently means that the device is found.

Exact steps for others to reproduce the error

  1. Use the default startup.
  2. Download the script to test the listing of devices.
  3. Run path_to_blender2.8/blender -b --python --debug-cycles --debug-gpu --verbose

Expected result:
At least 1 device name (CPU) is output, 2 or more if GPUs present.

Problem experienced:
No device names output, the array is empty.



Event Timeline

You need to call prefs.addons['cycles'].preferences.get_devices() to refresh the list.

Havent checked code, but it is still unclear to me which (stored) preferences are actually used here.
If I do a fresh start [nuke my userprefs], then enable all devices in Preferences and save Preferences, then I get these reported by bpy.context.preferences.addons['cycles'].preferences.devices:

Intel Core i7-6700 CPU @ 3.40GHz
GeForce GTX 1080
Quadro RTX 6000
GeForce GTX 970M (Display)

the 1080 and RTX are definitely wrong.

But what works reliably is to query them using cuda_devices, opencl_devices = bpy.context.preferences.addons['cycles'].preferences.get_devices()
So .get_devices() makes it do the right thing...
Have a look at T57282 as well

@Brecht Van Lommel (brecht) get_devices() worked for me, thanks. On a side note, I've noticed that after I used get_devices() once, the devices started to appear in the list. What's a bit strange is that I previously did run Blender 2.79b in the background in a Docker container (via nvidia-docker) where Blender was installed from scratch and never ran with UI, and I did not run into this problem—the GPU was definitely working.