Comfy Cloud: DownloadAndLoadDepthAnythingV2Model fails during DINOv2 initialization with NoneType.uniform_ error
- Dominant language
- Python
- Stars
- 133k
- Forks
- 15.7k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 158
Description
### Custom Node Testing
- [ ] I have tried disabling custom nodes and the issue persists (see [how to disable custom nodes](https://docs.comfy.org/troubleshooting/custom-node-issues#step-1%3A-test-with-all-custom-nodes-disabled) if you need help)
### Expected Behavior
The `DownloadAndLoadDepthAnythingV2Model` node should successfully construct the DINOv2 backbone, load the selected Depth Anything V2 checkpoint, and pass the loaded model to the `Depth Anything V2` inference node.
The workflow should then generate a valid depth map from the input image.
### Actual Behavior
The `DownloadAndLoadDepthAnythingV2Model` node fails during DINOv2 model initialization before the selected checkpoint is loaded.
The node throws the following error:
AttributeError: 'NoneType' object has no attribute 'uniform_'
The stack trace shows that the error occurs here:
ComfyUI-DepthAnythingV2/depth_anything_v2/dinov2.py
init_weights_vit_timm
→ trunc_normal_(module.weight, std=0.02)
PyTorch then attempts to call:
tensor.uniform_(...)
but the tensor passed into trunc_normal_ is None.
I tested ViT-S and ViT-L models in both FP16 and FP32, and all variants fail with the same error.
Screenshot attached.
### Steps to Reproduce
1. Open Comfy Cloud.
2. Create a minimal workflow containing the following nodes:
- Load Image
- DownloadAndLoadDepthAnythingV2Model
- Depth Anything V2
- Preview Image or Save Image
3. Connect the workflow as follows:
- Connect the model output from `DownloadAndLoadDepthAnythingV2Model` to the model input of `Depth Anything V2`.
- Connect the image output from `Load Image` to the image input of `Depth Anything V2`.
- Connect the image output from `Depth Anything V2` to `Preview Image` or `Save Image`.
4. Select a supported Depth Anything V2 model, for example:
- `depth_anything_v2_vits_fp16`
- `depth_anything_v2_vits_fp32`
- `depth_anything_v2_vitl_fp32`
5. Upload any valid image.
6. Queue the workflow.
7. The `DownloadAndLoadDepthAnythingV2Model` node fails during DINOv2 initialization with the following error:
`AttributeError: 'NoneType' object has no attribute 'uniform_'`
The same error occurs with ViT-S and ViT-L models, and with both FP16 and FP32.
This issue involves the third-party custom node package `ComfyUI-DepthAnythingV2`. It cannot be reproduced with all custom nodes disabled because disabling custom nodes removes the affected node.
### Debug Logs
```powershell
# ComfyUI Error Report
## Error Details
- Node ID: 54
- Node Type: DownloadAndLoadDepthAnythingV2Model
- Exception Type: AttributeError
- Exception Message: AttributeError: 'NoneType' object has no attribute 'uniform_'
## Stack Trace
File "/app/comfyui/custom_nodes/ComfyUI-DepthAnythingV2/nodes.py", line 114, in loadmodel
self.model = DepthAnythingV2(**model_configs[encoder])
File "/app/comfyui/custom_nodes/ComfyUI-DepthAnythingV2/depth_anything_v2/dpt.py", line 184, in __init__
self.pretrained = DINOv2(model_name=encoder)
File "/app/comfyui/custom_nodes/ComfyUI-DepthAnythingV2/depth_anything_v2/dinov2.py", line 170, in __init__
self.init_weights()
File "/app/comfyui/custom_nodes/ComfyUI-DepthAnythingV2/depth_anything_v2/dinov2.py", line 334, in init_weights_vit_timm
trunc_normal_(module.weight, std=0.02)
File "/opt/conda/lib/python3.11/site-packages/torch/nn/init.py", line 295, in trunc_normal_
return _no_grad_trunc_normal_(tensor, mean, std, a, b, generator=generator)
File "/opt/conda/lib/python3.11/site-packages/torch/nn/init.py", line 114, in _no_grad_trunc_normal_
tensor.uniform_(2 * l - 1, 2 * u - 1, generator=generator)
AttributeError: 'NoneType' object has no attribute 'uniform_'
## System Information
- Platform: Comfy Cloud
- ComfyUI Version: v0.30.2
- Python runtime path: /opt/conda/lib/python3.11/
- Embedded Python: false
```
### Other
This issue occurs in Comfy Cloud, so I do not have access to the full startup terminal log, the exact PyTorch version, or the command-line option required to launch ComfyUI with `--disable-all-custom-nodes`.
I understand that the failing node belongs to the third-party package `ComfyUI-DepthAnythingV2`, and I am also reporting the issue to the node author.
I am submitting this report here because the failure appears to be specific to the current Comfy Cloud runtime or the version of the custom node installed in Comfy Cloud.
The error occurs before the checkpoint is loaded, so changing model files, precision, or encoder size does not resolve it.
Tested configurations:
- ViT-S FP16
- ViT-S FP32
- ViT-L FP32
Alternative preprocessors such as AIO Aux can execute, but their output differs substantially and is not a suitable replacement for the existing workflow.
Could the Comfy Cloud team please check the currently installed version of `ComfyUI-DepthAnythingV2`, as well as its compatibility with the current Cloud PyTorch runtime?
Contributor guide
Research direction
Start with custom_nodes/ComfyUI-DepthAnythingV2/nodes.py and depth_anything_v2/dinov2.py, following the loadmodel call into init_weights_vit_timm. Compare the installed custom-node version with the Comfy Cloud PyTorch runtime and reproduce the listed workflow using the tested ViT-S and ViT-L variants. Done means the model node initializes, loads the checkpoint, and produces a valid depth map.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- ai, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100