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]: Installation of Modulus-Sym on Google Colab: ValueError: mutable default <class 'modulus.sym.hydra.loss.NTKConf'> for field ntk is not allowed: use default_factory #223

Open
LoveCheeseHB opened this issue Feb 22, 2025 · 2 comments
Labels
? - Needs Triage Need team to review and classify bug Something isn't working

Comments

@LoveCheeseHB
Copy link

Version

Modulus 0.9.0 and 1.8.0 (?)

On which installation method(s) does this occur?

No response

Describe the issue

Hi Everyone!

I am trying to use Modulus-Sym in conjunction with Google Colab with NVIDIA A100-SXM4-40GB. I am using Python 3.9. I think I have installed Modulus-Sym, but it does not seem to be working. I am trying to run the following "Hello World" type of script to test functionality.

When I try to check:

import modulus.sym
print(modulus.sym.version)

I get the following error:

import modulus.sym
print(modulus.sym.version)
8 frames
/usr/lib/python3.11/dataclasses.py in _get_field(cls, a_name, a_type, default_kw_only)
813 # not the instance.
814 if f._field_type is _FIELD and f.default.class.hash is None:
--> 815 raise ValueError(f'mutable default {type(f.default)} for field '
816 f'{f.name} is not allowed: use default_factory')
817

ValueError: mutable default <class 'modulus.sym.hydra.loss.NTKConf'> for field ntk is not allowed: use default_factory

Can you please direct me as to what I need to do to resolve this error? It is clear I am doing something wrong in basic installation! If someone can provide me the correct Google Colab setup instructions for Modulus-Sym, that would be fantastic!

Thank you!

Minimum reproducible example

import modulus.sym
print(modulus.sym.__version__)

Relevant log output

ValueError                                Traceback (most recent call last)
<ipython-input-12-03b1f6b627a0> in <cell line: 0>()
----> 1 import modulus.sym
      2 print(modulus.sym.__version__)

8 frames
/usr/lib/python3.11/dataclasses.py in _get_field(cls, a_name, a_type, default_kw_only)
    813     # not the instance.
    814     if f._field_type is _FIELD and f.default.__class__.__hash__ is None:
--> 815         raise ValueError(f'mutable default {type(f.default)} for field '
    816                          f'{f.name} is not allowed: use default_factory')
    817 

ValueError: mutable default <class 'modulus.sym.hydra.loss.NTKConf'> for field ntk is not allowed: use default_factory

Environment details

Google Colab
Python 3.9
NVIDIA A100-SXM4-40G
Modulus 0.9.0
Modulus-Sym ?

Other/Misc.

No response

@LoveCheeseHB LoveCheeseHB added ? - Needs Triage Need team to review and classify bug Something isn't working labels Feb 22, 2025
@LoveCheeseHB LoveCheeseHB changed the title 🐛[BUG]: Installed Modulus-Sym on Google Colab: ValueError: mutable default <class 'modulus.sym.hydra.loss.NTKConf'> for field ntk is not allowed: use default_factory 🐛[BUG]: Installation of Modulus-Sym on Google Colab: ValueError: mutable default <class 'modulus.sym.hydra.loss.NTKConf'> for field ntk is not allowed: use default_factory Feb 22, 2025
@mcgicjn2
Copy link

Hi, I had the same problem and I found this worked as a work around:

!pip install --extra-index-url https://pypi.nvidia.com/ nvidia-modulus

!pip install "pint==0.19.2"

!git clone https://github.com/NVIDIA/modulus-sym.git

%cd modulus-sym
%pip install --upgrade pip
%pip install . --no-build-isolation

%cd /content/

@mcgicjn2
Copy link

Also FYI Google Colab is Python 3.11, and recently changed from 3.10, this change appears to cause much of this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
? - Needs Triage Need team to review and classify bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants