No devices listed in bpy.context.preferences.addons['cycles'].preferences.devices when running in background mode #60618

Closed
opened 2019-01-18 12:51:49 +01:00 by Dmytro Kharchenko · 10 comments

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
Broken:
2.80 beta, 2757469824, blender2.8, 2019-01-18, downloaded from https://builder.blender.org/download/blender-2.80-2757469824bb-linux-glibc224-x86_64.tar.bz2
Worked:
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:
blender_list_devices.py

The logic is adapted from https://developer.blender.org/T54099 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:
Screenshot 2019-01-18 at 5.15.45 PM.png

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 blender_list_devices.py --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.

**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** Broken: 2.80 beta, 2757469824bb, blender2.8, 2019-01-18, downloaded from https://builder.blender.org/download/blender-2.80-2757469824bb-linux-glibc224-x86_64.tar.bz2 Worked: 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: [blender_list_devices.py](https://archive.blender.org/developer/F6327106/blender_list_devices.py) The logic is adapted from https://developer.blender.org/T54099 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: ![Screenshot 2019-01-18 at 5.15.45 PM.png](https://archive.blender.org/developer/F6327081/Screenshot_2019-01-18_at_5.15.45_PM.png) 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 blender_list_devices.py --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.

Added subscriber: @unclenorton

Added subscriber: @unclenorton

Added subscriber: @brecht

Added subscriber: @brecht

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

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

Closed as duplicate of #53242

Closed as duplicate of #53242
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

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 #57282 as well

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 #57282 as well
Member

ah, @brecht was quicker...

ah, @brecht was quicker...

@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.

@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.

Added subscriber: @3co

Added subscriber: @3co

Greetings, I'm new to the Blender development community. It's been pretty crazy catching up to 2.8 with all of the broken guidance from online forums, and this is no exception. I may be wrong, but it seems 2.8 introduced the need to call

bpy.context.preferences.addons['cycles'].preferences.get_devices()

...prior to actually having GPU etc. recognized by the machine. Was this done "automatically" before? In any case, why is this not done automatically?

Greetings, I'm new to the Blender development community. It's been pretty crazy catching up to 2.8 with all of the broken guidance from online forums, and this is no exception. I may be wrong, but it seems 2.8 introduced the need to call ``` bpy.context.preferences.addons['cycles'].preferences.get_devices() ``` ...prior to actually having GPU etc. recognized by the machine. Was this done "automatically" before? In any case, why is this not done automatically?
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#60618
No description provided.