Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] failed to convert the PyTorch model to a YAML file #4564

Closed
njzjz opened this issue Jan 20, 2025 · 0 comments · Fixed by #4565
Closed

[BUG] failed to convert the PyTorch model to a YAML file #4564

njzjz opened this issue Jan 20, 2025 · 0 comments · Fixed by #4565
Labels
bug reproduced This bug has been reproduced by developers

Comments

@njzjz
Copy link
Member

njzjz commented Jan 20, 2025

Thanks for reply! but error occurs when I tried this:

(deepmd-3rc0) [mps@GPU819 v2-7-3h-100w]$ dp --pt convert-backend frozen_model.pth frozen_model.yaml
[2025-01-20 16:29:41,739] DEEPMD WARNING To get the best performance, it is recommended to adjust the number of threads by setting the environment variables OMP_NUM_THREADS, DP_INTRA_OP_PARALLELISM_THREADS, and DP_INTER_OP_PARALLELISM_THREADS. See https://deepmd.rtfd.io/parallelism/ for more information.
Traceback (most recent call last):
  File "/home/mps/miniconda3/envs/deepmd-3rc0/bin/dp", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/mps/miniconda3/envs/deepmd-3rc0/lib/python3.11/site-packages/deepmd/main.py", line 927, in main
    deepmd_main(args)
  File "/home/mps/miniconda3/envs/deepmd-3rc0/lib/python3.11/site-packages/deepmd/entrypoints/main.py", line 86, in main
    convert_backend(**dict_args)
  File "/home/mps/miniconda3/envs/deepmd-3rc0/lib/python3.11/site-packages/deepmd/entrypoints/convert_backend.py", line 27, in convert_backend
    out_hook(OUTPUT, data)
  File "/home/mps/miniconda3/envs/deepmd-3rc0/lib/python3.11/site-packages/deepmd/dpmodel/utils/serialization.py", line 108, in save_dp_model
    model_dict = traverse_model_dict(
                 ^^^^^^^^^^^^^^^^^^^^
  File "/home/mps/miniconda3/envs/deepmd-3rc0/lib/python3.11/site-packages/deepmd/dpmodel/utils/serialization.py", line 42, in traverse_model_dict
    model_obj[kk] = traverse_model_dict(
                    ^^^^^^^^^^^^^^^^^^^^
  File "/home/mps/miniconda3/envs/deepmd-3rc0/lib/python3.11/site-packages/deepmd/dpmodel/utils/serialization.py", line 42, in traverse_model_dict
    model_obj[kk] = traverse_model_dict(
                    ^^^^^^^^^^^^^^^^^^^^
  File "/home/mps/miniconda3/envs/deepmd-3rc0/lib/python3.11/site-packages/deepmd/dpmodel/utils/serialization.py", line 51, in traverse_model_dict
    model_obj = callback(model_obj)
                ^^^^^^^^^^^^^^^^^^^
  File "/home/mps/miniconda3/envs/deepmd-3rc0/lib/python3.11/site-packages/deepmd/dpmodel/utils/serialization.py", line 114, in <lambda>
    "dtype": x.dtype.name,
             ^^^^^^^
AttributeError: 'float' object has no attribute 'dtype'

Should I open an issue about this ?

Originally posted by @QuantumMisaka in #4562 (reply in thread)

@njzjz njzjz added bug reproduced This bug has been reproduced by developers labels Jan 20, 2025
njzjz added a commit to njzjz/deepmd-kit that referenced this issue Jan 20, 2025
@njzjz njzjz linked a pull request Jan 20, 2025 that will close this issue
github-merge-queue bot pushed a commit that referenced this issue Jan 21, 2025
Fix #4564.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Bug Fixes**
- Improved serialization of NumPy arrays when saving model data to YAML
files.
- Enhanced metadata handling for array representations during model
export.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Signed-off-by: Jinzhe Zeng <[email protected]>
@njzjz njzjz closed this as completed Jan 21, 2025
@github-project-automation github-project-automation bot moved this from Todo to Done in Bugfixes for DeePMD-kit Jan 21, 2025
njzjz added a commit to njzjz/deepmd-kit that referenced this issue Feb 9, 2025
Fix deepmodeling#4564.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Bug Fixes**
- Improved serialization of NumPy arrays when saving model data to YAML
files.
- Enhanced metadata handling for array representations during model
export.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Signed-off-by: Jinzhe Zeng <[email protected]>
(cherry picked from commit ec19ab3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug reproduced This bug has been reproduced by developers
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant