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

python heat_tmax.py --optimizer newton fails #7

Open
slitvinov opened this issue Nov 14, 2024 · 1 comment
Open

python heat_tmax.py --optimizer newton fails #7

slitvinov opened this issue Nov 14, 2024 · 1 comment

Comments

@slitvinov
Copy link
Collaborator

slitvinov commented Nov 14, 2024

I do

$ python3.11 -m ensurepip
$ python3.11 -m pip install numpy matplotlib tensorflow
$ python3.11 -m pip install git+https://github.com/cselab/odil.git
$ cd examples/heat_tmax
$ python3.11 heat_tmax.py --optimizer newton

and it fails with the following error message

WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
E0000 00:00:1731580699.079602 3103184 cuda_dnn.cc:8310] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
E0000 00:00:1731580699.083125 3103184 cuda_blas.cc:1418] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
heat_tmax.py --optimizer newton
Running Newton optimizer

epoch=00000
residual: eqn:5.6127, imp:0.011106
tmax=1
memory: 544 MiB
walltime: 2.017 s
walltime+callback: 2.019 s
u_00000.png
Traceback (most recent call last):
  File "/n/home13/slitvinov/odil/examples/heat_tmax/heat_tmax.py", line 189, in <module>
    main()
  File "/n/home13/slitvinov/odil/examples/heat_tmax/heat_tmax.py", line 185, in main
    odil.optimize(args, args.optimizer, problem, state, callback)
  File "/n/home13/slitvinov/.local/lib/python3.11/site-packages/odil/util.py", line 316, in optimize
    return optimize_newton(args, problem, state, callback, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/n/home13/slitvinov/.local/lib/python3.11/site-packages/odil/util.py", line 244, in optimize_newton
    vector, matrix = problem.linearize(state)
                     ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/n/home13/slitvinov/.local/lib/python3.11/site-packages/odil/core.py", line 1321, in linearize
    m = modsp.csr_array(garray)
        ^^^^^^^^^^^^^^^^^^^^^^^
  File "/n/home13/slitvinov/.local/lib/python3.11/site-packages/scipy/sparse/_compressed.py", line 92, in __init__
    coo = self._coo_container(arg1, dtype=dtype)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/n/home13/slitvinov/.local/lib/python3.11/site-packages/scipy/sparse/_coo.py", line 84, in __init__
n    self._shape = check_shape(M.shape, allow_1d=is_array)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/n/home13/slitvinov/.local/lib/python3.11/site-packages/scipy/sparse/_sputils.py", line 332, in check_shape
    raise ValueError('shape must be a 1- or 2-tuple of positive '
ValueError: shape must be a 1- or 2-tuple of positive integers

It works as expected with default optimizer

$ python3.11 heat_tmax.py
heat_tmax.py
Running L-BFGS-B optimizer

epoch=00000
residual: eqn:5.6127, imp:0.011106
tmax=1
memory: 547 MiB
walltime: 2.092 s
walltime+callback: 2.093 s
u_00000.png

epoch=01000
residual: eqn:0.0074659, imp:0.002916
tmax=3.6493
memory: 588 MiB
walltime: 5.631 s
walltime+callback: 5.860 s
walltime/epoch: 5.631 ms
throughput: 0.727M cells/s
u_00001.png
...

I have

$ python3.11 --version
Python 3.11.9
$ python3.11 -c 'import tensorflow as tf; print(tf.version.VERSION)'
2.18.0
$ python3.11 -c 'import numpy; print(numpy.version.version)'
2.0.2
$ cat /etc/*rel*
Rocky Linux release 8.9 (Green Obsidian)
NAME="Rocky Linux"
VERSION="8.9 (Green Obsidian)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="8.9"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Rocky Linux 8.9 (Green Obsidian)"
ANSI_COLOR="0;32"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:rocky:rocky:8:GA"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
SUPPORT_END="2029-05-31"
ROCKY_SUPPORT_PRODUCT="Rocky-Linux-8"
ROCKY_SUPPORT_PRODUCT_VERSION="8.9"
REDHAT_SUPPORT_PRODUCT="Rocky Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="8.9"
Rocky Linux release 8.9 (Green Obsidian)
Rocky Linux release 8.9 (Green Obsidian)
Derived from Red Hat Enterprise Linux 8.9
Rocky Linux release 8.9 (Green Obsidian)
cpe:/o:rocky:rocky:8:GA
@kangbeicai
Copy link

Thanks for your reply. I found that the inverse problem cannot be solved by Newton, which has been mentioned in the paper. When I remove the imp term, "shape must be a 1- or 2-tuple of positive integers" no longer appears. However, res after optimization becomes nan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants