Crash when choosing cycles device with python #81520

Closed
opened 2020-10-07 20:35:17 +02:00 by Cedar Myers · 14 comments

System Information
Operating system: Ubuntu 20.04.1 LTS
Graphics card: GTX 1070 + GTX 1070 + GTX 1050 Ti, NVIDIA 440.100

Blender Version
Broken: 2.90.1, Commit date: 2020-09-23 06:43, Hash 3e85bb34d0
Worked: 2.83.7

Short description of error
Blender crashes when using python to choose CUDA GPU for cycles. I don't know if this happens in systems with only 1 GPU.

Exact steps for others to reproduce the error
Run Blender from command line with python expression to select GPU:

blender --factory-startup --python-expr "import bpy; cuda_devices, opencl_devices = bpy.context.preferences.addons['cycles'].preferences.get_devices(); cuda_devices[0].use = True"

More information:
Using get_devices_for_type() instead of get_devices() does not crash.

blender --factory-startup --python-expr "import bpy; cuda_devices = bpy.context.preferences.addons['cycles'].preferences.get_devices_for_type('CUDA'); cuda_devices[0].use = True"

The specific sequence of device types used by get_devices() matters, CUDA, then OPTIX, then OPENCL. Changing the sequence to CUDA last does not crash. Something about OPTIX and OPENCL mutates the CUDA devices. See the dump of cuda_devices before and after getting OPENCL devices:

blender --factory-startup --python-expr "import bpy; \
cuda_devices = bpy.context.preferences.addons['cycles'].preferences.get_devices_for_type('CUDA'); \
optix_devices = bpy.context.preferences.addons['cycles'].preferences.get_devices_for_type('OPTIX'); \
print('CUDA devices before getting OPENCL devices', cuda_devices); \
opencl_devices = bpy.context.preferences.addons['cycles'].preferences.get_devices_for_type('OPENCL'); \
print('CUDA devices after getting OPENCL devices', cuda_devices); \
print('OPTIX devices', optix_devices); \
print('OPENCL devices', opencl_devices); \
cuda_devices[0].use = True"

CUDA devices before getting OPENCL devices [<bpy_struct, CyclesDeviceSettings("GeForce GTX 1070")>, <bpy_struct, CyclesDeviceSettings("GeForce GTX 1070")>, <bpy_struct, CyclesDeviceSettings("GeForce GTX 1050 Ti")>, <bpy_struct, CyclesDeviceSettings("AMD Ryzen 9 3900X 12-Core Processor")>]
CUDA devices after getting OPENCL devices [<bpy_struct, CyclesDeviceSettings("")>, <bpy_struct, CyclesDeviceSettings("")>, <bpy_struct, CyclesDeviceSettings("")>, <bpy_struct, CyclesDeviceSettings("")>]
OPTIX devices [<bpy_struct, CyclesDeviceSettings("GeForce GTX 1070")>, <bpy_struct, CyclesDeviceSettings("GeForce GTX 1070")>, <bpy_struct, CyclesDeviceSettings("GeForce GTX 1050 Ti")>]
OPENCL devices [<bpy_struct, CyclesDeviceSettings("AMD Ryzen 9 3900X 12-Core Processor")>]

Also, this seems to have something to do with OPTIX. Removing OPTIX from the sequence above also does not crash.

**System Information** Operating system: Ubuntu 20.04.1 LTS Graphics card: GTX 1070 + GTX 1070 + GTX 1050 Ti, NVIDIA 440.100 **Blender Version** Broken: 2.90.1, Commit date: 2020-09-23 06:43, Hash 3e85bb34d0d7 Worked: 2.83.7 **Short description of error** Blender crashes when using python to choose CUDA GPU for cycles. I don't know if this happens in systems with only 1 GPU. **Exact steps for others to reproduce the error** Run Blender from command line with python expression to select GPU: ``` blender --factory-startup --python-expr "import bpy; cuda_devices, opencl_devices = bpy.context.preferences.addons['cycles'].preferences.get_devices(); cuda_devices[0].use = True" ``` **More information:** Using get_devices_for_type() instead of get_devices() does not crash. ``` blender --factory-startup --python-expr "import bpy; cuda_devices = bpy.context.preferences.addons['cycles'].preferences.get_devices_for_type('CUDA'); cuda_devices[0].use = True" ``` The specific sequence of device types used by get_devices() matters, CUDA, then OPTIX, then OPENCL. Changing the sequence to CUDA last does not crash. Something about OPTIX and OPENCL mutates the CUDA devices. See the dump of cuda_devices before and after getting OPENCL devices: ``` blender --factory-startup --python-expr "import bpy; \ cuda_devices = bpy.context.preferences.addons['cycles'].preferences.get_devices_for_type('CUDA'); \ optix_devices = bpy.context.preferences.addons['cycles'].preferences.get_devices_for_type('OPTIX'); \ print('CUDA devices before getting OPENCL devices', cuda_devices); \ opencl_devices = bpy.context.preferences.addons['cycles'].preferences.get_devices_for_type('OPENCL'); \ print('CUDA devices after getting OPENCL devices', cuda_devices); \ print('OPTIX devices', optix_devices); \ print('OPENCL devices', opencl_devices); \ cuda_devices[0].use = True" CUDA devices before getting OPENCL devices [<bpy_struct, CyclesDeviceSettings("GeForce GTX 1070")>, <bpy_struct, CyclesDeviceSettings("GeForce GTX 1070")>, <bpy_struct, CyclesDeviceSettings("GeForce GTX 1050 Ti")>, <bpy_struct, CyclesDeviceSettings("AMD Ryzen 9 3900X 12-Core Processor")>] CUDA devices after getting OPENCL devices [<bpy_struct, CyclesDeviceSettings("")>, <bpy_struct, CyclesDeviceSettings("")>, <bpy_struct, CyclesDeviceSettings("")>, <bpy_struct, CyclesDeviceSettings("")>] OPTIX devices [<bpy_struct, CyclesDeviceSettings("GeForce GTX 1070")>, <bpy_struct, CyclesDeviceSettings("GeForce GTX 1070")>, <bpy_struct, CyclesDeviceSettings("GeForce GTX 1050 Ti")>] OPENCL devices [<bpy_struct, CyclesDeviceSettings("AMD Ryzen 9 3900X 12-Core Processor")>] ``` Also, this seems to have something to do with OPTIX. Removing OPTIX from the sequence above also does not crash.
Author

Added subscriber: @Cedar-Myers

Added subscriber: @Cedar-Myers

Added subscriber: @rjg

Added subscriber: @rjg

Changed status from 'Needs Triage' to: 'Needs User Info'

Changed status from 'Needs Triage' to: 'Needs User Info'

I can't reproduce this on my one GPU system. Could you run Blender from the terminal with ./blender --debug --debug-python --debug-gpu > ~/blender_debug_output.txt 2>&1 and upload the output as well as the crash log / stack trace?

I can't reproduce this on my one GPU system. Could you run Blender from the terminal with `./blender --debug --debug-python --debug-gpu > ~/blender_debug_output.txt 2>&1` and upload the output as well as the crash log / stack trace?
Author

These are pretty short. Do I need a certain build for debugging?

blender.crash.txt

blender_debug_output.txt

These are pretty short. Do I need a certain build for debugging? [blender.crash.txt](https://archive.blender.org/developer/F8965899/blender.crash.txt) [blender_debug_output.txt](https://archive.blender.org/developer/F8965900/blender_debug_output.txt)

Changed status from 'Needs User Info' to: 'Needs Triage'

Changed status from 'Needs User Info' to: 'Needs Triage'

@Cedar-Myers No, the log files are exactly how they are supposed to be.

@Cedar-Myers No, the log files are exactly how they are supposed to be.
Contributor

Added subscriber: @Raimund58

Added subscriber: @Raimund58

This issue was referenced by 0ff7d21c27

This issue was referenced by 0ff7d21c27957b4f4a9f02c59b458cdd6beeb06b

This issue was referenced by 1001adb500

This issue was referenced by 1001adb500196537050cc60e8d80318a2f1a56c3

Changed status from 'Needs Triage' to: 'Resolved'

Changed status from 'Needs Triage' to: 'Resolved'
Campbell Barton self-assigned this 2020-10-15 07:54:06 +02:00
Author

I have tested the 2.91.0-3bc808ebcbf6 nightly build and I can confirm that this fixes get_devices() but get_devices_for_type() still suffers the same problem when called in sequence (CUDA, then OPTIX, then OPENCL). Should this be filed as a new issue, or should this issue be re-opened?

Also, I'm uncertain if this is relevant for LTS backport since 2.83 does not crash, but I'll leave that to you guys to determine.

I have tested the 2.91.0-3bc808ebcbf6 nightly build and I can confirm that this fixes get_devices() but get_devices_for_type() still suffers the same problem when called in sequence (CUDA, then OPTIX, then OPENCL). Should this be filed as a new issue, or should this issue be re-opened? Also, I'm uncertain if this is relevant for LTS backport since 2.83 does not crash, but I'll leave that to you guys to determine.

@Cedar-Myers Since this ticket as already been closed with an associated commit, it's probably a good idea to open another ticket. Just to make sure it's not forgotten.

@Cedar-Myers Since this ticket as already been closed with an associated commit, it's probably a good idea to open another ticket. Just to make sure it's not forgotten.

@Cedar-Myers other issues should be reported separately, get_devices_for_type is returning data that's re-allocated, so we'll need to copy the return values to prevent problems like this from happening entirely.

@Cedar-Myers other issues should be reported separately, `get_devices_for_type` is returning data that's re-allocated, so we'll need to copy the return values to prevent problems like this from happening entirely.
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
FBX
Interest
Freestyle
Interest
Geometry Nodes
Interest
glTF
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 & 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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
Asset System
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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
5 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#81520
No description provided.