Blender crashes and closes when I move the model view in Cycles (Only with GPU) #128733

Open
opened 2024-10-08 03:22:55 +02:00 by Reinhard-Marvin-Carrillo-Talavera · 15 comments

System Information

System: Windows 11

GPU: NVIDIA GeForce MX450

CPU: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz

Memory: 16GB

Blender Version
Broken: 4.2
""Worked"": 3.6 ("So far, it hasn't happened that much, but it does happen in sudden moments as well.")

Short description of error

I've been having a problem with Blender for a while now, specifically in Cycles view when using the GPU. This doesn't happen with the CPU, but it's slower. When I use Cycles with the GPU (even with Denoise off and just 40 samples), it often happens that when I move the model view, Blender crashes and closes automatically, even when I move it just a little. However, I should point out that this is inconsistent: it can happen or not, even with the same model that previously crashed. When it doesn't happen, I can move the model view in Cycles without any issues. This also doesn't happen with all models, but I don't know why this is happening, and it's becoming really frustrating. I would appreciate any help. This is an issue that doesn't show any error message, so I don't know why it's happening. It also occurred even when I had a clean installation of Blender without any add-ons, which I usually download from the official Blender website.

I'm leaving an example GIF, I want to know what’s happening and how to fix it.

**System Information** System: Windows 11 GPU: NVIDIA GeForce MX450 CPU: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz Memory: 16GB **Blender Version** Broken: 4.2 ""Worked"": 3.6 ("So far, it hasn't happened that much, but it does happen in sudden moments as well.") **Short description of error** I've been having a problem with Blender for a while now, specifically in Cycles view when using the GPU. This doesn't happen with the CPU, but it's slower. When I use Cycles with the GPU (even with Denoise off and just 40 samples), it often happens that when I move the model view, Blender crashes and closes automatically, even when I move it just a little. However, I should point out that this is inconsistent: it can happen or not, even with the same model that previously crashed. When it doesn't happen, I can move the model view in Cycles without any issues. This also doesn't happen with all models, but I don't know why this is happening, and it's becoming really frustrating. I would appreciate any help. This is an issue that doesn't show any error message, so I don't know why it's happening. It also occurred even when I had a clean installation of Blender without any add-ons, which I usually download from the official Blender website. I'm leaving an example GIF, I want to know what’s happening and how to fix it.
Member

Hi @Reinhard-Marvin-Carrillo-Talavera , could you give us the crash log? Also try starting blender with GPU debug/workarounds commands and upload logs it produces. Thanks!

Hi @Reinhard-Marvin-Carrillo-Talavera , could you give us the [crash log](https://docs.blender.org/manual/en/latest/troubleshooting/crash.html#windows)? Also try starting blender with GPU debug/workarounds commands and upload logs it produces. Thanks!
YimingWu added
Status
Needs Information from User
and removed
Status
Needs Triage
labels 2024-10-08 04:04:43 +02:00

@ChengduLittleA

Archies por GPU debug

@ChengduLittleA >Archies por GPU debug

@ChengduLittleA

Archives for GPU workarounds

"I've taken a while because this crash is very inconsistent, so I don't think it's my graphics card. Sometimes it doesn't crash and lets me move things around and see everything normally right away, but obviously it would be better if it didn't happen at all."

@ChengduLittleA >Archives for GPU workarounds "I've taken a while because this crash is very inconsistent, so I don't think it's my graphics card. Sometimes it doesn't crash and lets me move things around and see everything normally right away, but obviously it would be better if it didn't happen at all."
Member

Apparently always crashed in ccl::ObjectManager::device_update_prim_offsets. It looks like blender does run on correct video card MX450.

BTW your file has dependency cycle, try removing those drivers and see if anything changes.

Dependency cycle detected:
  OBGhost Mesh/VISIBILITY() depends on
  OBGhost Mesh/DRIVER(modifiers["Cock"].show_render) via 'Driver -> Driven Property'
  OBGhost Mesh/VISIBILITY() via 'RNA Target -> Driver'
Dependency cycle detected:
  OBJawbone_Poncho_Rig/DRIVER(hide_render) depends on
  OBJawbone_Poncho_Rig/OBJECT_FROM_LAYER_EXIT() via 'RNA Target -> Driver'
  OBJawbone_Poncho_Rig/OBJECT_FROM_LAYER_ENTRY() via 'Object from Layer'
  OBJawbone_Poncho_Rig/DRIVER(hide_render) via 'Driver -> Driven Property'
Dependency cycle detected:
  OBGhost/DRIVER(hide_render) depends on
  OBGhost/OBJECT_FROM_LAYER_EXIT() via 'RNA Target -> Driver'
  OBGhost/OBJECT_BASE_FLAGS() via 'Base flags flush Exit'
  OBGhost/OBJECT_FROM_LAYER_ENTRY() via 'Base flags flush Entry'
  OBGhost/DRIVER(hide_render) via 'Driver -> Driven Property'
Dependency cycle detected:
  OBGhost Glasses/OBJECT_FROM_LAYER_ENTRY() depends on
  OBGhost Glasses/DRIVER(hide_render) via 'Driver -> Driven Property'
  OBGhost Glasses/OBJECT_FROM_LAYER_EXIT() via 'RNA Target -> Driver'
  OBGhost Glasses/OBJECT_FROM_LAYER_ENTRY() via 'Object from Layer'
Detected 4 dependency cycles
Apparently always crashed in `ccl::ObjectManager::device_update_prim_offsets`. It looks like blender does run on correct video card MX450. BTW your file has dependency cycle, try removing those drivers and see if anything changes. ``` Dependency cycle detected: OBGhost Mesh/VISIBILITY() depends on OBGhost Mesh/DRIVER(modifiers["Cock"].show_render) via 'Driver -> Driven Property' OBGhost Mesh/VISIBILITY() via 'RNA Target -> Driver' Dependency cycle detected: OBJawbone_Poncho_Rig/DRIVER(hide_render) depends on OBJawbone_Poncho_Rig/OBJECT_FROM_LAYER_EXIT() via 'RNA Target -> Driver' OBJawbone_Poncho_Rig/OBJECT_FROM_LAYER_ENTRY() via 'Object from Layer' OBJawbone_Poncho_Rig/DRIVER(hide_render) via 'Driver -> Driven Property' Dependency cycle detected: OBGhost/DRIVER(hide_render) depends on OBGhost/OBJECT_FROM_LAYER_EXIT() via 'RNA Target -> Driver' OBGhost/OBJECT_BASE_FLAGS() via 'Base flags flush Exit' OBGhost/OBJECT_FROM_LAYER_ENTRY() via 'Base flags flush Entry' OBGhost/DRIVER(hide_render) via 'Driver -> Driven Property' Dependency cycle detected: OBGhost Glasses/OBJECT_FROM_LAYER_ENTRY() depends on OBGhost Glasses/DRIVER(hide_render) via 'Driver -> Driven Property' OBGhost Glasses/OBJECT_FROM_LAYER_EXIT() via 'RNA Target -> Driver' OBGhost Glasses/OBJECT_FROM_LAYER_ENTRY() via 'Object from Layer' Detected 4 dependency cycles ```

@ChengduLittleA

Alright, I'll give it a try tomorrow, but... If you're interested, I can also share the GPU debug files of a 3D model that crashed, which doesn't have the drivers that were generating the dependencies. If you'd like, I can also send the GPU workarounds for the same model.

@ChengduLittleA Alright, I'll give it a try tomorrow, but... If you're interested, I can also share the GPU debug files of a 3D model that crashed, which doesn't have the drivers that were generating the dependencies. If you'd like, I can also send the GPU workarounds for the same model.

@ChengduLittleA
I tried it, and it happened again even after removing basically all the related drivers. Here are the GPU debug files from this crash. Also, just to remind you of the debug file I sent with the model that doesn't have any drivers installed.

@ChengduLittleA I tried it, and it happened again even after removing basically all the related drivers. Here are the GPU debug files from this crash. Also, just to remind you of the debug file I sent with the model that doesn't have any drivers installed.
Member

There's still some:

Dependency cycle detected:
  OBGhost/DRIVER(hide_render) depends on
  OBGhost/OBJECT_FROM_LAYER_EXIT() via 'RNA Target -> Driver'
  OBGhost/OBJECT_BASE_FLAGS() via 'Base flags flush Exit'
  OBGhost/OBJECT_FROM_LAYER_ENTRY() via 'Base flags flush Entry'
  OBGhost/DRIVER(hide_render) via 'Driver -> Driven Property'
Dependency cycle detected:
  OBGhost Glasses/OBJECT_FROM_LAYER_ENTRY() depends on
  OBGhost Glasses/DRIVER(hide_render) via 'Driver -> Driven Property'
  OBGhost Glasses/OBJECT_FROM_LAYER_EXIT() via 'RNA Target -> Driver'
  OBGhost Glasses/OBJECT_FROM_LAYER_ENTRY() via 'Object from Layer'
Detected 2 dependency cycles

You may be using some plugins to handle the rig? Could you try factory reset then render the same model?

There's still some: ``` Dependency cycle detected: OBGhost/DRIVER(hide_render) depends on OBGhost/OBJECT_FROM_LAYER_EXIT() via 'RNA Target -> Driver' OBGhost/OBJECT_BASE_FLAGS() via 'Base flags flush Exit' OBGhost/OBJECT_FROM_LAYER_ENTRY() via 'Base flags flush Entry' OBGhost/DRIVER(hide_render) via 'Driver -> Driven Property' Dependency cycle detected: OBGhost Glasses/OBJECT_FROM_LAYER_ENTRY() depends on OBGhost Glasses/DRIVER(hide_render) via 'Driver -> Driven Property' OBGhost Glasses/OBJECT_FROM_LAYER_EXIT() via 'RNA Target -> Driver' OBGhost Glasses/OBJECT_FROM_LAYER_ENTRY() via 'Object from Layer' Detected 2 dependency cycles ``` You may be using some plugins to handle the rig? Could you try factory reset then render the same model?

@ChengduLittleA Well, I reset Blender to its factory mode and completely deleted all its configurations from the folder... And... The crash happened again. I'm sending you the files of a model without any of that, without the drivers or anything, where it happened again even in the blender_factory_startup.cmd as well as in the formatted Blender I used. Thank you, and sorry for the inconvenience, but it's a persistent problem. Could it have something to do with my graphics card?

@ChengduLittleA Well, I reset Blender to its factory mode and completely deleted all its configurations from the folder... And... The crash happened again. I'm sending you the files of a model without any of that, without the drivers or anything, where it happened again even in the blender_factory_startup.cmd as well as in the formatted Blender I used. Thank you, and sorry for the inconvenience, but it's a persistent problem. Could it have something to do with my graphics card?
Member

Looks like it still crashes in device_update_prim_offsets. Might be that you somehow have invalid geometries. Could you clean the file up and upload a minimal example that can reproduce this issue?

If your file contain age restrictions then you could try do this yourself:

Select one mesh object at a time, and run this in the python console:

bpy.context.object.data.validate()

It should validate your mesh data and may help with the situation. But best is that if you could have a minimal file that reproduces the problem. Thanks!

Looks like it still crashes in `device_update_prim_offsets`. Might be that you somehow have invalid geometries. Could you clean the file up and upload a minimal example that can reproduce this issue? If your file contain age restrictions then you could try do this yourself: Select one mesh object at a time, and run this in the python console: ``` bpy.context.object.data.validate() ``` It should validate your mesh data and may help with the situation. But best is that if you could have a minimal file that reproduces the problem. Thanks!

@ChengduLittleA Well, here I leave you two things:

A) First, I did what you told me with the Python console on each one, and it happened again, but as always, it's inconsistent: I can be moving the camera all the time, and when loading in Cycles, it may not crash and close, or it might. In any case, since it doesn't always happen, I don't think it's a problem with my GPU because if it were, it would always do it, and it has been shown that it can handle it. Here I leave you the crash files.

B) I also leave you the Blender file of this model for you to see. It's censored and fixed, don't worry. Thanks and sorry for the trouble, but I wish this crash would never happen at all.

Caution

The file contains nudity

@ChengduLittleA Well, here I leave you two things: A) First, I did what you told me with the Python console on each one, and it happened again, but as always, it's inconsistent: I can be moving the camera all the time, and when loading in Cycles, it may not crash and close, or it might. In any case, since it doesn't always happen, I don't think it's a problem with my GPU because if it were, it would always do it, and it has been shown that it can handle it. Here I leave you the crash files. B) I also leave you the Blender file of this model for you to see. It's censored and fixed, don't worry. Thanks and sorry for the trouble, but I wish this crash would never happen at all. >[!Caution] >The file contains nudity
Member

Thanks! Here I'm not able to reproduce the crash on Linux and Windows with a 4070. Your driver 565.9 appears to be latest, maybe you could try installing an earlier driver version from NVIDIA?

Thanks! Here I'm not able to reproduce the crash on Linux and Windows with a 4070. Your driver 565.9 appears to be latest, maybe you could try installing an earlier driver version from NVIDIA?
Contributor

I was able to reproduce the crash after a few tries (had to rename the texture folder to get them to load). To get the crash, I opened another instance of blender and had it rendering a scene (this demo file) to fill up VRAM (if you have a larger amount of VRAM a heavier scene might be required). Then opening the file from this issue, I got the crash when moving/zooming the viewport in rendered view.

Operating system: Windows-10-10.0.19045-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 3060 Laptop GPU/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 561.09 (6 GB of VRAM)
version: 4.3.0 Beta, branch: blender-v4.3-release, commit date: 2024-10-03 15:45, hash: 6b7889474005
version: 4.4.0 Alpha, branch: main, commit date: 2024-10-10 20:49, hash: 07f298c1e570

I also tried to figure out what's happening (I haven't looked at the cycles code much before, so take this with a grain of salt).
When a device_vector is copied to the rendering device by calling device_vector<>::copy_to_device and the available VRAM is low, GPUDevice::generic_alloc instead allocates a buffer (device_vector<>::shared_pointer) in the host's RAM and maps it to the GPU. It then copies the contents of device_vector<>::host_pointer to the mapped buffer, frees the original buffer, and sets it to the new mapped buffer. When the scene is updated and device_vector<>::copy_to_device is called again, the CUDA implementation of Device::mem_copy_to calls CUDADevice::global_free which then calls GPUDevice::generic_free which then frees the mapped buffer, setting device_vector<>::host_pointer to nullptr and thereby destroying the data in the device_vector.

void CUDADevice::mem_copy_to(device_memory &mem)
{
if (mem.type == MEM_GLOBAL) {
global_free(mem);
global_alloc(mem);
}

if (mem.host_pointer == mem.shared_pointer) {
mem.host_pointer = 0;
}
free_host(mem.shared_pointer);
mem.shared_pointer = 0;

When device_vector<>::alloc is called after and the requested size hasn't changed, it just returns device_vector<>::host_pointer, which is now nullptr, causing an access violation.

You can make the crash always happen in rendered view when using the GPU if you force Cycles to always use mapped allocations by making the following change in GPUDevice::generic_alloc:

   /* Allocate in device memory. */
-  if (!move_texture_to_host && (size + headroom) < free) {
+  if (!move_texture_to_host && (size + headroom) < free && mem.type == MEM_DEVICE_ONLY) {
I was able to reproduce the crash after a few tries (had to rename the texture folder to get them to load). To get the crash, I opened another instance of blender and had it rendering a scene ([this demo file](https://cloud.blender.org/p/gallery/5dd6d7044441651fa3decb56)) to fill up VRAM (if you have a larger amount of VRAM a heavier scene might be required). Then opening the file from this issue, I got the crash when moving/zooming the viewport in rendered view. Operating system: Windows-10-10.0.19045-SP0 64 Bits Graphics card: NVIDIA GeForce RTX 3060 Laptop GPU/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 561.09 (6 GB of VRAM) version: 4.3.0 Beta, branch: blender-v4.3-release, commit date: 2024-10-03 15:45, hash: `6b7889474005` version: 4.4.0 Alpha, branch: main, commit date: 2024-10-10 20:49, hash: `07f298c1e570` I also tried to figure out what's happening (I haven't looked at the cycles code much before, so take this with a grain of salt). When a `device_vector` is copied to the rendering device by calling `device_vector<>::copy_to_device` and the available VRAM is low, `GPUDevice::generic_alloc` instead allocates a buffer (`device_vector<>::shared_pointer`) in the host's RAM and maps it to the GPU. It then copies the contents of `device_vector<>::host_pointer` to the mapped buffer, frees the original buffer, and sets it to the new mapped buffer. When the scene is updated and `device_vector<>::copy_to_device` is called again, the CUDA implementation of `Device::mem_copy_to` calls `CUDADevice::global_free` which then calls `GPUDevice::generic_free` which then frees the mapped buffer, setting `device_vector<>::host_pointer` to `nullptr` and thereby destroying the data in the `device_vector`. https://projects.blender.org/blender/blender/src/commit/6ff33b7e9290c7fb29f0c04d42cae2e8ea526881/intern/cycles/device/cuda/device_impl.cpp#L583-L588 https://projects.blender.org/blender/blender/src/commit/6ff33b7e9290c7fb29f0c04d42cae2e8ea526881/intern/cycles/device/device.cpp#L767-L771 When `device_vector<>::alloc` is called after and the requested size hasn't changed, it just returns `device_vector<>::host_pointer`, which is now `nullptr`, causing an access violation. You can make the crash always happen in rendered view when using the GPU if you force Cycles to always use mapped allocations by making the following change in `GPUDevice::generic_alloc`: ```cpp /* Allocate in device memory. */ - if (!move_texture_to_host && (size + headroom) < free) { + if (!move_texture_to_host && (size + headroom) < free && mem.type == MEM_DEVICE_ONLY) { ```
Member

I see. Thanks for the investigation @jorn !

I guess the main problem is the handing of mapped data isn't taking this kind of situation into account, which can be triggered by insufficient video memory.

Will mark this to confirmed then.

I believe we could have device_vector<>::alloc to always check host_pointer to prevent such crash. Let me try making a PR, but people more familiar with cycles/GPU in general may be able to come up with better ideas.

I see. Thanks for the investigation @jorn ! I guess the main problem is the handing of mapped data isn't taking this kind of situation into account, which can be triggered by insufficient video memory. Will mark this to confirmed then. I believe we could have `device_vector<>::alloc` to always check `host_pointer` to prevent such crash. Let me try making a PR, but people more familiar with cycles/GPU in general may be able to come up with better ideas.
YimingWu added
Module
Render & Cycles
Status
Confirmed
and removed
Status
Needs Information from User
labels 2024-10-13 09:25:51 +02:00

Hi @ChengduLittleA , thank you very much for confirming and investigating the issue. I'm relieved to know that it was a software-related bug and not a problem with my laptop or GPU. I appreciate the effort you and the team are putting into solving it.

Would it be possible to get updates on the status of the fix? I’d like to follow up and test the solution once it’s merged to confirm everything works smoothly on my end.

Thanks again for your hard work!!

Hi @ChengduLittleA , thank you very much for confirming and investigating the issue. I'm relieved to know that it was a software-related bug and not a problem with my laptop or GPU. I appreciate the effort you and the team are putting into solving it. Would it be possible to get updates on the status of the fix? I’d like to follow up and test the solution once it’s merged to confirm everything works smoothly on my end. Thanks again for your hard work!!
Member

Hi @Reinhard-Marvin-Carrillo-Talavera , we are investigating. You will get notified in this thread when the PR has merged so you don't need to do anything rn :)

Hi @Reinhard-Marvin-Carrillo-Talavera , we are investigating. You will get notified in this thread when the PR has merged so you don't need to do anything rn :)
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
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
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
Core
Module
Development Management
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
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
3 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#128733
No description provided.