Cycles Motion Blur + python bpy.context leads to error and VRAM overload #49797

Closed
opened 2016-10-19 19:48:04 +02:00 by lucas veber · 7 comments

Win10, 16Go RAM, gtx 980 6GB

Blender 2.78

SUMMARY:
Very specific nagging bug.
When rendering with cycles motion blur (GPU) enabled and running an addon containing 'bpy.context.active_object' inside a persistent function, blender generates an error and over loads the VRAM, leading to CUDA error: out of memory while rendering.

STEPS:

  • Set the renderer to Cycles, using the default scene

  • Install and enable the attached addon : addon_vram_overload.py

  • Switch to GPU compute and enable Motion Blur

  • Start rendering 100 frames

  • Monitor the VRAM usage with GPU-Z for example, or wait until Out of Memory error message appear.

  • You can check the console: AtributeError 'Context' object has no attribute 'active_object'

  • Now replace this line in the addon:
    ob = bpy.context.active_object
    by this one:
    print("")

  • Render the animation again
    The VRAM is no more overloaded.

COMMENT:
So yes, the workaround in python would be easy, it's all about avoiding the error:

 try:
     ob = bpy.context.active_object  
except:
     ob = None

The problem is it happens on several scripts already used by a lot of users. Is there a way to resolve this memory consumption when this error occurs?

Thanks for your great works!

Win10, 16Go RAM, gtx 980 6GB Blender 2.78 SUMMARY: Very specific nagging bug. When rendering with cycles motion blur (GPU) enabled and running an addon containing 'bpy.context.active_object' inside a persistent function, blender generates an error and over loads the VRAM, leading to CUDA error: out of memory while rendering. STEPS: - Set the renderer to Cycles, using the default scene - Install and enable the attached addon : [addon_vram_overload.py](https://archive.blender.org/developer/F381514/addon_vram_overload.py) - Switch to GPU compute and enable Motion Blur - Start rendering 100 frames - Monitor the VRAM usage with GPU-Z for example, or wait until Out of Memory error message appear. - You can check the console: AtributeError 'Context' object has no attribute 'active_object' - Now replace this line in the addon: ob = bpy.context.active_object by this one: print("") - Render the animation again The VRAM is no more overloaded. COMMENT: So yes, the workaround in python would be easy, it's all about avoiding the error: ``` try: ob = bpy.context.active_object except: ob = None ``` The problem is it happens on several scripts already used by a lot of users. Is there a way to resolve this memory consumption when this error occurs? Thanks for your great works!
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @LucasVeber

Added subscriber: @LucasVeber

Added subscriber: @YAFU

Added subscriber: @YAFU

This issue was referenced by blender/blender@32c2cba4ef

This issue was referenced by blender/blender@32c2cba4ef1c940dab559cdc47b886c60cc9f2e1

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

Thanks Lucas for the clear report and thank Sergey for the fix.
This problem had given me more of a headache with some addons, and some people out there having this problem but without them knowing exactly why.
Thanks!

Thanks Lucas for the clear report and thank Sergey for the fix. This problem had given me more of a headache with some addons, and some people out there having this problem but without them knowing exactly why. Thanks!
Author

Thanks for quick fix Sergey!

Thanks for quick fix Sergey!
Sign in to join this conversation.
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-addons#49797
No description provided.