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

Closed
opened 4 years ago by unclenorton · 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.
Poster

Added subscriber: @unclenorton

Added subscriber: @unclenorton
brecht commented 4 years ago
Owner

Added subscriber: @brecht

Added subscriber: @brecht
brecht commented 4 years ago
Owner

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.
brecht commented 4 years ago
Owner

Closed as duplicate of #53242

Closed as duplicate of #53242
brecht closed this issue 4 years ago
Collaborator

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Collaborator

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
Collaborator

ah, @brecht was quicker...

ah, @brecht was quicker...
Poster

@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.
3co commented 4 years ago

Added subscriber: @3co

Added subscriber: @3co
3co commented 4 years ago

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/Collada
Interest/Compositing
Interest/Core
Interest/Cycles
Interest/Dependency Graph
Interest/Development Management
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/Modeling
Interest/Modifiers
Interest/Motion Tracking
Interest/Nodes & Physics
Interest/Overrides
Interest/Performance
Interest/Performance
Interest/Physics
Interest/Pipeline, Assets & I/O
Interest/Platforms, Builds, Tests & Devices
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
legacy module/Animation & Rigging
legacy module/Core
legacy module/Development Management
legacy module/Eevee & Viewport
legacy module/Grease Pencil
legacy module/Modeling
legacy module/Nodes & Physics
legacy module/Pipeline, Assets & IO
legacy module/Platforms, Builds, Tests & Devices
legacy module/Python API
legacy module/Rendering & Cycles
legacy module/Sculpt, Paint & Texture
legacy module/Triaging
legacy module/User Interface
legacy module/VFX & Video
legacy project/1.0.0-beta.2
legacy project/Asset Browser (Archived)
legacy project/BF Blender: 2.8
legacy project/BF Blender: After Release
legacy project/BF Blender: Next
legacy project/BF Blender: Regressions
legacy project/BF Blender: Unconfirmed
legacy project/Blender 2.70
legacy project/Code Quest
legacy project/Datablocks and Libraries
legacy project/Eevee
legacy project/Game Animation
legacy project/Game Audio
legacy project/Game Data Conversion
legacy project/Game Engine
legacy project/Game Logic
legacy project/Game Physics
legacy project/Game Python
legacy project/Game Rendering
legacy project/Game UI
legacy project/GPU / Viewport
legacy project/GSoC
legacy project/Infrastructure: Websites
legacy project/LibOverrides - Usability and UX
legacy project/Milestone 1: Basic, Local Asset Browser
legacy project/Nodes
legacy project/OpenGL Error
legacy project/Papercut
legacy project/Pose Library Basics
legacy project/Retrospective
legacy project/Tracker Curfew
legacy project/Wintab High Frequency
Meta/Good First Issue
Meta/Papercut
migration/requires-manual-verification
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 & Devices
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 Information 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

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#60618
Loading…
There is no content yet.