Hi @brecht As I recalled, the method you mention above using preferences doesn’t work in background, this is the output I get.
jimbosmaccypro:MacOS jamescrowther$ ./blender -b --python-console
Read prefs: /Users/jamescrowther/Library/Application Support/Blender/2.79/config/userpref.blend found bundled python: /Applications/Blender/blender.app/Contents/Resources/2.79/python
HEY! My script registered
Python 3.5.3 (default, May 29 2017, 11:05:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import bpy
<bpy_struct, UserPreferences at 0x107220e98>
However the following seems to work just fine:
>>> import _cycles
(('Intel Core i5-5257U CPU @ 2.70GHz', 'CPU', 'CPU'),)
The above was done using 2.79b in background mode. So it seems the public part of the API for looking at what devices cycles has recognised, doesn’t work as desired. This is what I referred to above when I mentioned that we’d decided to use the private api since the public one did not do what we thought it would according to the API docs when running blender in background mode.
We run servers for rendering on various hardware, a lot of which, in the case of the cloud, has no monitor attached and so we run the processes in background mode. Therefore we really need something that works in background mode. Is it intentional that the public API method you showed me above does not work in background mode?