When baking to two images, CUDA crashes on the second image. #94217

Closed
opened 2021-12-18 06:25:11 +01:00 by Memm · 26 comments

System Information
Operating system: Windows-10
Graphics card: NVIDIA GeForce GTX 960

Blender Version
Broken: version: 3.0.0
Worked: 2.93.5

Short description of error
If an object has multiple materials, only the first will bake normal maps, and the second material will have a hole in the bake image.

Exact steps for others to reproduce the error
Setup a high res object and a low res object, give the low res object two materials, assign some vertices to material 1 and some to material 2, bake a normal map to the low res object, only material 1 will bake a normal map image, material 2 will have a hole.

Attached .blend file showing the bug, open it in 3.0.0 and press bake, second image "bake2" will have a hole. Open it in 2.93.5, press bake, "bake2" will bake as expected.

baking bug.blend

**System Information** Operating system: Windows-10 Graphics card: NVIDIA GeForce GTX 960 **Blender Version** Broken: version: 3.0.0 Worked: 2.93.5 **Short description of error** If an object has multiple materials, only the first will bake normal maps, and the second material will have a hole in the bake image. **Exact steps for others to reproduce the error** Setup a high res object and a low res object, give the low res object two materials, assign some vertices to material 1 and some to material 2, bake a normal map to the low res object, only material 1 will bake a normal map image, material 2 will have a hole. Attached .blend file showing the bug, open it in 3.0.0 and press bake, second image "bake2" will have a hole. Open it in 2.93.5, press bake, "bake2" will bake as expected. [baking bug.blend](https://archive.blender.org/developer/F12760051/baking_bug.blend)
Author

Added subscriber: @Memm

Added subscriber: @Memm

Added subscriber: @Baardaap

Added subscriber: @Baardaap
Martijn Versteegh self-assigned this 2021-12-19 23:26:26 +01:00

As I've been working on this code for 3.1 I'll have a look if it's something I understand.

As I've been working on this code for 3.1 I'll have a look if it's something I understand.

If anybody knows what's going on, feel free to claim this one.

If anybody *knows* what's going on, feel free to claim this one.

Very strange. If I use the official release I see this bug. If I compile 3.0.0 myself it works as it should!

Very strange. If I use the official release I see this bug. If I compile 3.0.0 myself it works as it should!

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

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

I think the actual bug here is Cycles crashing for the second image. Maybe something with deinitializing and reinitializing CUDA?

For me it works correctly if I set Cycles to CPU only.

@Memm could you confirm if it works correctly if you set cycles to cpu rendering?

I think the actual bug here is Cycles crashing for the second image. Maybe something with deinitializing and reinitializing CUDA? For me it works correctly if I set Cycles to CPU only. @Memm could you confirm if it works correctly if you set cycles to cpu rendering?
Author

@Baardaap I can confirm it works with CPU rendering, you're probably right about CUDA failing to reinitialize. I'm just guessing here but maybe it's a memory leak, that seems to happen quite often with CUDA.

@Baardaap I can confirm it works with CPU rendering, you're probably right about CUDA failing to reinitialize. I'm just guessing here but maybe it's a memory leak, that seems to happen quite often with CUDA.
Martijn Versteegh changed title from Multiple materials cause holes in normal map baking to When baking to two images, CUDA crashes on the second image. 2021-12-20 17:17:00 +01:00
Martijn Versteegh removed their assignment 2021-12-20 17:17:00 +01:00

Added subscriber: @brecht

Added subscriber: @brecht

@brecht CUDA reliably crashes on the second image on multiple machines over here. As have no experience whatsoever with CUDA I 'unclaim' this task.

@brecht CUDA reliably crashes on the second image on multiple machines over here. As have no experience whatsoever with CUDA I 'unclaim' this task.
Author

So I just tried baking a roughness map and Blender froze up, then opened the same file in 2.93.5 and it baked just fine, not only that but baking in 2.93.5 uses much less memory and goes about 100x faster. Could it be that baking as a whole is broken with CUDA under 3.0.0? Basically all my baking has to be done in 2.93.5 right now, which seems like a major bug for 3.0.0.

So I just tried baking a roughness map and Blender froze up, then opened the same file in 2.93.5 and it baked just fine, not only that but baking in 2.93.5 uses much less memory and goes about 100x faster. Could it be that baking as a whole is broken with CUDA under 3.0.0? Basically all my baking has to be done in 2.93.5 right now, which seems like a major bug for 3.0.0.

are you sure 3.0.0 wasn't set to CPU only?

Also, maybe it's useful to open a new bugreport for that? Since it's probably not the same problem, though maybe related.
Maybe mention the new bugreport over here.

are you sure 3.0.0 wasn't set to CPU only? Also, maybe it's useful to open a new bugreport for that? Since it's probably not the same problem, though maybe related. Maybe mention the new bugreport over here.
Author

This comment was removed by @Memm

*This comment was removed by @Memm*
Author

@Baardaap It might need a new bug report, but I get the feeling this is all related. If I set rendering to CPU like you suggested then the roughness map bakes and Blender doesn't crash. It also bakes just fine in 2.93.5 with CUDA. Too many coincidences in my opinion.

@Baardaap It might need a new bug report, but I get the feeling this is all related. If I set rendering to CPU like you suggested then the roughness map bakes and Blender doesn't crash. It also bakes just fine in 2.93.5 with CUDA. Too many coincidences in my opinion.

Added subscriber: @Sergey

Added subscriber: @Sergey

Maybe it's related, sure. But being very slow (but CUDA not crashing) or CUDA crashing is still a different bug I think.

Anyway, I think the main person who can shed some light on this is @brecht , or maybe @sergey. Brecht is on holiday I think. Considering 3.0 is just out and Christmass is nearly here, I wouldn't be surprised is @Sergey is on holiday as well.

Turning off the noise threshold fixing it was incorrect?

Maybe it's related, sure. But being very slow (but CUDA not crashing) or CUDA crashing is still a different bug I think. Anyway, I think the main person who can shed some light on this is @brecht , or maybe @sergey. Brecht is on holiday I think. Considering 3.0 is just out and Christmass is nearly here, I wouldn't be surprised is @Sergey is on holiday as well. Turning off the noise threshold fixing it was incorrect?
Author

@Baardaap Turning off noise threshold gets it to bake the second image in the example .blend file, but I don't want to say it fixes it because we still don't know the cause. It's probably best to just wait for someone that knows the baking code to look at it.

@Baardaap Turning off noise threshold gets it to bake the second image in the example .blend file, but I don't want to say it fixes it because we still don't know the cause. It's probably best to just wait for someone that knows the baking code to look at it.

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

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

So far can confirm the issue.
Not sure yet what causes it, maybe somehow non-initialized state of the auxiliary buffer used by adaptive sampling, or maybe some missing synchronization of a queue somewhere.

So far can confirm the issue. Not sure yet what causes it, maybe somehow non-initialized state of the auxiliary buffer used by adaptive sampling, or maybe some missing synchronization of a queue somewhere.
Author

I have put in another ticket, I think this is related.

https://developer.blender.org/T94854

I have put in another ticket, I think this is related. https://developer.blender.org/T94854

Added subscriber: @MaleneThyssen

Added subscriber: @MaleneThyssen

I suspect this is related. Baking textures (Combined) from a multi material object only the first material in the list bakes right. The next materials bakes a mix of the previous materials + their own. This happens in Blender 3.0 with GPU and Denoise/Noise Threshold on. If I turn off Denoise and Noise Threshold the textures will bake right, albeit a lot slower and more noisy of course (If i switch to Diffuse though - the issue is back with these settings too). Whether I use OptiX or OpenImageDenoise seems to make no difference. Switching the materials in the list it will still be the top material that works and the ones lover in the list will be messed up. If I bake in CPU I have no issue.

System info:

Blender version: 3.0.0, branch: master, commit date: 2021-12-02 18:35, hash: f1cca30557, type: release
build date: 2021-12-03, 00:44:02
platform: 'Windows-10-10.0.19043-SP0'
NVIDIA GeForce GTX 1070/PCIe/SSE2'
4.5.0 NVIDIA 472.84'

A few screenshots of the setup:
5f23e2823f42fd1b5e37079479d44062.png
c4d7d31b4c68c2d1cbd196454d032a6d.png
09ae6f122bbfaa10e7de0aaef7006d44.png
f685cdfd31ab4271614577d72f5317df.png

I suspect this is related. Baking textures (Combined) from a multi material object only the first material in the list bakes right. The next materials bakes a mix of the previous materials + their own. This happens in Blender 3.0 with GPU and Denoise/Noise Threshold on. If I turn off Denoise and Noise Threshold the textures will bake right, albeit a lot slower and more noisy of course (If i switch to Diffuse though - the issue is back with these settings too). Whether I use OptiX or OpenImageDenoise seems to make no difference. Switching the materials in the list it will still be the top material that works and the ones lover in the list will be messed up. If I bake in CPU I have no issue. System info: --------------- Blender version: 3.0.0, branch: master, commit date: 2021-12-02 18:35, hash: f1cca3055776, type: release build date: 2021-12-03, 00:44:02 platform: 'Windows-10-10.0.19043-SP0' NVIDIA GeForce GTX 1070/PCIe/SSE2' 4.5.0 NVIDIA 472.84' A few screenshots of the setup: ![5f23e2823f42fd1b5e37079479d44062.png](https://archive.blender.org/developer/F12805547/5f23e2823f42fd1b5e37079479d44062.png) ![c4d7d31b4c68c2d1cbd196454d032a6d.png](https://archive.blender.org/developer/F12805550/c4d7d31b4c68c2d1cbd196454d032a6d.png) ![09ae6f122bbfaa10e7de0aaef7006d44.png](https://archive.blender.org/developer/F12805552/09ae6f122bbfaa10e7de0aaef7006d44.png) ![f685cdfd31ab4271614577d72f5317df.png](https://archive.blender.org/developer/F12805554/f685cdfd31ab4271614577d72f5317df.png)

Added subscriber: @EMSI

Added subscriber: @EMSI

Can confirm it, i was about to make a bug report for the similar Issue. I've been baking Alpha Info with Emission to an Image Textures; in mid-process of texture baking, Blender suddenly close itself without any warning what so ever. I'm using a simple props:

Configuration:
Render & Viewport sample : 1
Bake: Combined, without Light info (Direct/Indirect Lighting) with 1px margin.

System Info:
Microsoft Windows 10
Version 20H3 (OS Build 19042.985)

About Blender:
Latest Official Release Blender Version 3.0.0
Date: 2021-12-02 18:35
Hash: f1cca30557
Branch: Master

Note that the Crashes happens randomly and on standard frequent, and sometimes happen on Diffuse baking but more likely to happen with Combined Bake.
Screenshot (170).png

Can confirm it, i was about to make a bug report for the similar Issue. I've been baking Alpha Info with Emission to an Image Textures; in mid-process of texture baking, Blender suddenly close itself without any warning what so ever. I'm using a simple props: **Configuration**: Render & Viewport sample : 1 Bake: Combined, without Light info (Direct/Indirect Lighting) with 1px margin. **System Info**: Microsoft Windows 10 Version 20H3 (OS Build 19042.985) **About Blender**: Latest Official Release Blender Version 3.0.0 Date: 2021-12-02 18:35 Hash: f1cca3055776 Branch: Master Note that the Crashes happens randomly and on standard frequent, and sometimes happen on Diffuse baking but more likely to happen with Combined Bake. ![Screenshot (170).png](https://archive.blender.org/developer/F12806020/Screenshot__170_.png)

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Brecht Van Lommel self-assigned this 2022-01-24 19:48:52 +01:00

Also fixed by 04c3b08.

Also fixed by 04c3b08.
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
6 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#94217
No description provided.