一、问题现象(附报错日志上下文):
https://github.com/comfyanonymous/ComfyUI/ 的master分支已适配昇腾npu,但torch_npu2.1.0.post3和post6报AttributeError: 'torch_npu._C._NPUDeviceProperties' object has no attribute 'major'
二、软件版本:
-- CANN 版本 (CANN 8.0.rc3):
--Pytorch版本:2.1.0
--Python 版本 :3.10.15
-- 驱动版本 :23.0.0
--操作系统版本 :EulerOS release 2.0 (SP8)

三、测试步骤:
1.在镜像环境torch_npu已装好,再pip install -r requirements.txt
2.python main.py
3.在工作流执行

四、日志信息:
# ComfyUI Error Report
## Error Details
- **Node ID:** 4
- **Node Type:** CheckpointLoaderSimple
- **Exception Type:** AttributeError
- **Exception Message:** 'torch_npu._C._NPUDeviceProperties' object has no attribute 'major'
## Stack Trace
```
File "/home/ma-user/work/ComfyUI-master/execution.py", line 327, in execute
output_data, output_ui, has_subgraph = get_output_data(obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
File "/home/ma-user/work/ComfyUI-master/execution.py", line 202, in get_output_data
return_values = _map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
File "/home/ma-user/work/ComfyUI-master/execution.py", line 174, in _map_node_over_list
process_inputs(input_dict, i)
File "/home/ma-user/work/ComfyUI-master/execution.py", line 163, in process_inputs
results.append(getattr(obj, func)(**inputs))
File "/home/ma-user/work/ComfyUI-master/nodes.py", line 568, in load_checkpoint
out = comfy.sd.load_checkpoint_guess_config(ckpt_path, output_vae=True, output_clip=True, embedding_directory=folder_paths.get_folder_paths("embeddings"))
File "/home/ma-user/work/ComfyUI-master/comfy/sd.py", line 828, in load_checkpoint_guess_config
out = load_state_dict_guess_config(sd, output_vae, output_clip, output_clipvision, embedding_directory, output_model, model_options, te_model_options=te_model_options)
File "/home/ma-user/work/ComfyUI-master/comfy/sd.py", line 874, in load_state_dict_guess_config
vae = VAE(sd=vae_sd)
File "/home/ma-user/work/ComfyUI-master/comfy/sd.py", line 401, in __init__
dtype = model_management.vae_dtype(self.device, self.working_dtypes)
File "/home/ma-user/work/ComfyUI-master/comfy/model_management.py", line 788, in vae_dtype
if d == torch.bfloat16 and (not is_amd()) and should_use_bf16(device):
File "/home/ma-user/work/ComfyUI-master/comfy/model_management.py", line 1084, in should_use_bf16
if props.major >= 8:
```
## System Information
- **ComfyUI Version:** unknown
- **Arguments:** main.py
- **OS:** posix
- **Python Version:** 3.10.15 (main, Oct 3 2024, 07:21:53) [GCC 11.2.0]
- **Embedded Python:** false
- **PyTorch Version:** 2.1.0
## Devices
- **Name:** npu
- **Type:** npu
- **VRAM Total:** 34359738368
- **VRAM Free:** 34333212672
- **Torch VRAM Total:** 0
- **Torch VRAM Free:** 0
## Logs
```
2025-01-09T10:53:57.039494 - /home/ma-user/anaconda3/envs/py310_torch2.1/lib/python3.10/site-packages/torch_npu/utils/path_manager.py:79: UserWarning: Warning: The /usr/local/Ascend/ascend-toolkit/latest owner does not match the current user.
warnings.warn(f"Warning: The {path} owner does not match the current user.")
2025-01-09T10:53:57.042872 - /home/ma-user/anaconda3/envs/py310_torch2.1/lib/python3.10/site-packages/torch_npu/utils/path_manager.py:79: UserWarning: Warning: The /usr/local/Ascend/ascend-toolkit/8.0.RC3/aarch64-linux/ascend_toolkit_install.info owner does not match the current user.
warnings.warn(f"Warning: The {path} owner does not match the current user.")
2025-01-09T10:53:57.138646 - /home/ma-user/anaconda3/envs/py310_torch2.1/lib/python3.10/site-packages/torch_npu/contrib/transfer_to_npu.py:211: ImportWarning:
*************************************************************************************************************
The torch.Tensor.cuda and torch.nn.Module.cuda are replaced with torch.Tensor.npu and torch.nn.Module.npu now..
The torch.cuda.DoubleTensor is replaced with torch.npu.FloatTensor cause the double type is not supported now..
The backend in torch.distributed.init_process_group set to hccl now..
The torch.cuda.* and torch.cuda.amp.* are replaced with torch.npu.* and torch.npu.amp.* now..
The device parameters have been replaced with npu in the function below:
torch.logspace, torch.randint, torch.hann_window, torch.rand, torch.full_like, torch.ones_like, torch.rand_like, torch.randperm, torch.arange, torch.frombuffer, torch.normal, torch._empty_per_channel_affine_quantized, torch.empty_strided, torch.empty_like, torch.scalar_tensor, torch.tril_indices, torch.bartlett_window, torch.ones, torch.sparse_coo_tensor, torch.randn, torch.kaiser_window, torch.tensor, torch.triu_indices, torch.as_tensor, torch.zeros, torch.randint_like, torch.full, torch.eye, torch._sparse_csr_tensor_unsafe, torch.empty, torch._sparse_coo_tensor_unsafe, torch.blackman_window, torch.zeros_like, torch.range, torch.sparse_csr_tensor, torch.randn_like, torch.from_file, torch._cudnn_init_dropout_state, torch._empty_affine_quantized, torch.linspace, torch.hamming_window, torch.empty_quantized, torch._pin_memory, torch.autocast, torch.load, torch.Generator, torch.Tensor.new_empty, torch.Tensor.new_empty_strided, torch.Tensor.new_full, torch.Tensor.new_ones, torch.Tensor.new_tensor, torch.Tensor.new_zeros, torch.Tensor.to, torch.nn.Module.to, torch.nn.Module.to_empty
*************************************************************************************************************
warnings.warn(msg, ImportWarning)
2025-01-09T10:54:05.076133 - Total VRAM 32768 MB, total RAM 773221 MB
2025-01-09T10:54:05.076314 - pytorch version: 2.1.0
2025-01-09T10:54:05.077776 - Set vram state to: NORMAL_VRAM
2025-01-09T10:54:05.077965 - Device: npu
2025-01-09T10:54:05.674590 - Using pytorch attention
2025-01-09T10:54:06.573863 - [Prompt Server] web root: /home/ma-user/work/ComfyUI-master/web
2025-01-09T10:54:07.138422 -
Import times for custom nodes:
2025-01-09T10:54:07.138566 - 0.0 seconds: /home/ma-user/work/ComfyUI-master/custom_nodes/websocket_image_save.py
2025-01-09T10:54:07.138790 -
2025-01-09T10:54:07.140933 - /home/ma-user/anaconda3/envs/py310_torch2.1/lib/python3.10/site-packages/aiohttp/web_urldispatcher.py:202: DeprecationWarning: Bare functions are deprecated, use async ones
warnings.warn(
2025-01-09T10:54:07.150412 - Starting server
2025-01-09T10:54:07.150863 - To see the GUI go to: http://127.0.0.1:8188
2025-01-09T10:54:28.693831 - got prompt
2025-01-09T10:54:50.275779 - model weight dtype torch.float16, manual cast: None
2025-01-09T10:54:50.285478 - model_type EPS
2025-01-09T10:55:09.256357 - Using pytorch attention in VAE
2025-01-09T10:55:09.260752 - Using pytorch attention in VAE
2025-01-09T10:55:09.429034 - -------------------------------2025-01-09T10:55:09.429110 -
2025-01-09T10:55:09.429224 - _NPUDeviceProperties(name='Ascend910B', total_memory=32768MB)2025-01-09T10:55:09.429238 -
2025-01-09T10:55:09.429784 - !!! Exception during processing !!! 'torch_npu._C._NPUDeviceProperties' object has no attribute 'major'
2025-01-09T10:55:09.432785 - Traceback (most recent call last):
File "/home/ma-user/work/ComfyUI-master/execution.py", line 327, in execute
output_data, output_ui, has_subgraph = get_output_data(obj, input_data_all, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
File "/home/ma-user/work/ComfyUI-master/execution.py", line 202, in get_output_data
return_values = _map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True, execution_block_cb=execution_block_cb, pre_execute_cb=pre_execute_cb)
File "/home/ma-user/work/ComfyUI-master/execution.py", line 174, in _map_node_over_list
process_inputs(input_dict, i)
File "/home/ma-user/work/ComfyUI-master/execution.py", line 163, in process_inputs
results.append(getattr(obj, func)(**inputs))
File "/home/ma-user/work/ComfyUI-master/nodes.py", line 568, in load_checkpoint
out = comfy.sd.load_checkpoint_guess_config(ckpt_path, output_vae=True, output_clip=True, embedding_directory=folder_paths.get_folder_paths("embeddings"))
File "/home/ma-user/work/ComfyUI-master/comfy/sd.py", line 828, in load_checkpoint_guess_config
out = load_state_dict_guess_config(sd, output_vae, output_clip, output_clipvision, embedding_directory, output_model, model_options, te_model_options=te_model_options)
File "/home/ma-user/work/ComfyUI-master/comfy/sd.py", line 874, in load_state_dict_guess_config
vae = VAE(sd=vae_sd)
File "/home/ma-user/work/ComfyUI-master/comfy/sd.py", line 401, in __init__
dtype = model_management.vae_dtype(self.device, self.working_dtypes)
File "/home/ma-user/work/ComfyUI-master/comfy/model_management.py", line 788, in vae_dtype
if d == torch.bfloat16 and (not is_amd()) and should_use_bf16(device):
File "/home/ma-user/work/ComfyUI-master/comfy/model_management.py", line 1084, in should_use_bf16
if props.major >= 8:
AttributeError: 'torch_npu._C._NPUDeviceProperties' object has no attribute 'major'
2025-01-09T10:55:09.435814 - Prompt executed in 40.74 seconds
2025-01-09T10:55:10.452930 - Failed to get ComfyUI version: [Errno 2] No such file or directory: 'git'
```
## Attached Workflow
Please make sure that workflow does not contain any sensitive information such as API keys or passwords.
```
{"last_node_id":9,"last_link_id":9,"nodes":[{"id":5,"type":"EmptyLatentImage","pos":[473,609],"size":[315,106],"flags":{},"order":0,"mode":0,"inputs":[],"outputs":[{"name":"LATENT","type":"LATENT","links":[2],"slot_index":0}],"properties":{"Node name for S&R":"EmptyLatentImage"},"widgets_values":[512,512,1]},{"id":3,"type":"KSampler","pos":[863,186],"size":[315,262],"flags":{},"order":4,"mode":0,"inputs":[{"name":"model","type":"MODEL","link":1},{"name":"positive","type":"CONDITIONING","link":4},{"name":"negative","type":"CONDITIONING","link":6},{"name":"latent_image","type":"LATENT","link":2}],"outputs":[{"name":"LATENT","type":"LATENT","links":[7],"slot_index":0}],"properties":{"Node name for S&R":"KSampler"},"widgets_values":[827939377534405,"randomize",20,8,"euler","normal",1]},{"id":8,"type":"VAEDecode","pos":[1209,188],"size":[210,46],"flags":{},"order":5,"mode":0,"inputs":[{"name":"samples","type":"LATENT","link":7},{"name":"vae","type":"VAE","link":8}],"outputs":[{"name":"IMAGE","type":"IMAGE","links":[9],"slot_index":0}],"properties":{"Node name for S&R":"VAEDecode"},"widgets_values":[]},{"id":9,"type":"SaveImage","pos":[1451,189],"size":[210,58],"flags":{},"order":6,"mode":0,"inputs":[{"name":"images","type":"IMAGE","link":9}],"outputs":[],"properties":{},"widgets_values":["ComfyUI"]},{"id":4,"type":"CheckpointLoaderSimple","pos":[26,474],"size":[315,98],"flags":{},"order":1,"mode":0,"inputs":[],"outputs":[{"name":"MODEL","type":"MODEL","links":[1],"slot_index":0},{"name":"CLIP","type":"CLIP","links":[3,5],"slot_index":1},{"name":"VAE","type":"VAE","links":[8],"slot_index":2}],"properties":{"Node name for S&R":"CheckpointLoaderSimple"},"widgets_values":["sd_xl_base_1.0.safetensors"]},{"id":6,"type":"CLIPTextEncode","pos":[415,186],"size":[422.84503173828125,164.31304931640625],"flags":{},"order":2,"mode":0,"inputs":[{"name":"clip","type":"CLIP","link":3}],"outputs":[{"name":"CONDITIONING","type":"CONDITIONING","links":[4],"slot_index":0}],"properties":{"Node name for S&R":"CLIPTextEncode"},"widgets_values":["beautiful scenery nature glass bottle landscape, , purple galaxy bottle,"]},{"id":7,"type":"CLIPTextEncode","pos":[413,389],"size":[425.27801513671875,180.6060791015625],"flags":{},"order":3,"mode":0,"inputs":[{"name":"clip","type":"CLIP","link":5}],"outputs":[{"name":"CONDITIONING","type":"CONDITIONING","links":[6],"slot_index":0}],"properties":{"Node name for S&R":"CLIPTextEncode"},"widgets_values":["text, watermark"]}],"links":[[1,4,0,3,0,"MODEL"],[2,5,0,3,3,"LATENT"],[3,4,1,6,0,"CLIP"],[4,6,0,3,1,"CONDITIONING"],[5,4,1,7,0,"CLIP"],[6,7,0,3,2,"CONDITIONING"],[7,3,0,8,0,"LATENT"],[8,4,2,8,1,"VAE"],[9,8,0,9,0,"IMAGE"]],"groups":[],"config":{},"extra":{"ds":{"scale":0.7513148009015777,"offset":[67.718055579733,22.261773860736696]}},"version":0.4}
```
## Additional Context
(Please add any additional context or steps to reproduce the error here)