Crash when choosing cycles device with python #81520

Closed
opened 2 years ago 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.
Poster

Added subscriber: @Cedar-Myers

Added subscriber: @Cedar-Myers
rjg commented 2 years ago
Collaborator

Added subscriber: @rjg

Added subscriber: @rjg
rjg commented 2 years ago
Collaborator

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

Changed status from 'Needs Triage' to: 'Needs User Info'
rjg commented 2 years ago
Collaborator

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?
Poster

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)
rjg commented 2 years ago
Collaborator

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

Changed status from 'Needs User Info' to: 'Needs Triage'
rjg commented 2 years ago
Collaborator

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

Added subscriber: @Raimund58

Added subscriber: @Raimund58
Owner

This issue was referenced by 0ff7d21c27

This issue was referenced by 0ff7d21c27957b4f4a9f02c59b458cdd6beeb06b
Owner

This issue was referenced by 1001adb500

This issue was referenced by 1001adb500196537050cc60e8d80318a2f1a56c3
Owner

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

Changed status from 'Needs Triage' to: 'Resolved'
ideasman42 closed this issue 2 years ago
ideasman42 self-assigned this 2 years ago
Poster

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.
rjg commented 2 years ago
Collaborator

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

@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
good first issue
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/2.81
legacy project/2.82
legacy project/2.83
legacy project/2.90
legacy project/2.91
legacy project/2.92
legacy project/3.0
legacy project/3.1
legacy project/3.2
legacy project/3.3
legacy project/Alembic
legacy project/Animation & Rigging
legacy project/Asset Browser
legacy project/Asset Browser (Archived)
legacy project/Asset Browser Project Overview
legacy project/Audio
legacy project/Automated Testing
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/Blender Asset Bundle
legacy project/Code Quest
legacy project/Collada
legacy project/Compositing
legacy project/Core
legacy project/Cycles
legacy project/Datablocks and Libraries
legacy project/Dependency Graph
legacy project/Development Management
legacy project/Eevee
legacy project/EEVEE & Viewport
legacy project/Freestyle
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/Geometry Nodes
legacy project/Good First Issue
legacy project/GPU / Viewport
legacy project/Grease Pencil
legacy project/GSoC
legacy project/Images & Movies
legacy project/Import/Export
legacy project/Infrastructure: Websites
legacy project/LibOverrides - Usability and UX
legacy project/Line Art
legacy project/Masking
legacy project/Milestone 1: Basic, Local Asset Browser
legacy project/Modeling
legacy project/Modifiers
legacy project/Motion Tracking
legacy project/Nodes
legacy project/Nodes & Physics
legacy project/OpenGL Error
legacy project/Overrides
legacy project/Papercut
legacy project/Performance
legacy project/Physics
legacy project/Pipeline, Assets & I/O
legacy project/Platform: FreeBSD
legacy project/Platform: Linux
legacy project/Platform: macOS
legacy project/Platforms, Builds, Tests & Devices
legacy project/Platform: Windows
legacy project/Pose Library Basics
legacy project/Python API
legacy project/Render & Cycles
legacy project/Render Pipeline
legacy project/Retrospective
legacy project/Sculpt, Paint & Texture
legacy project/Text Editor
legacy project/Tracker Curfew
legacy project/Translations
legacy project/Triaging
legacy project/Undo
legacy project/USD
legacy project/User Interface
legacy project/UV Editing
legacy project/VFX & Video
legacy project/Video Sequencer
legacy project/Virtual Reality
legacy project/Wintab High Frequency
migration/requires-manual-verification
Module › Animation & Rigging
Module › Core
Module › Development Management
Module › Eevee & Viewport
Module › EEVEE & Viewport
Module › Grease Pencil
Module › Modeling
Module › Nodes & Physics
Module › Pipeline, Assets & IO
Module › Platforms, Builds Tests & Devices
Module › Platforms, Builds, Tests & Devices
Module › Python API
Module › Rendering & Cycles
Module › Sculpt, Paint & Texture
Module › Triaging
Module › User Interface
Module › VFX & Video
papercut
performance
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
5 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

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