Giter Club home page Giter Club logo

Comments (4)

Algue-Rythme avatar Algue-Rythme commented on July 28, 2024

When FLAGS.manual_loop=True we should also call a jax.jit(solver.update) method instead of solver.update; this implies making the solver class hashable.

from jaxopt.

fabianp avatar fabianp commented on July 28, 2024

Thanks @Algue-Rythme !

That almost works. Unfortunately, to make it work in flax_image_classif.py I need also to remove the pre_update=print_accuracy argument of the solver, as otherwise it crashes with this exception:

Traceback (most recent call last):
  File "examples/deep_learning/flax_image_classif.py", line 199, in <module>
    app.run(main)
  File "/home/pedregosa/anaconda3/lib/python3.8/site-packages/absl/app.py", line 300, in run
    _run_main(main, args)
  File "/home/pedregosa/anaconda3/lib/python3.8/site-packages/absl/app.py", line 251, in _run_main
    sys.exit(main(argv))
  File "examples/deep_learning/flax_image_classif.py", line 188, in main
    params, state = jax.jit(solver.update)(params=params, state=state,
  File "/home/pedregosa/dev/jaxopt/jaxopt/_src/optax_wrapper.py", line 120, in update
    params, state = self.pre_update(params, state, *args, **kwargs)
  File "examples/deep_learning/flax_image_classif.py", line 145, in print_accuracy
    if state.iter_num % 10 == 0:
jax._src.errors.ConcretizationTypeError: Abstract tracer value encountered where concrete value is expected: Traced<ShapedArray(bool[], weak_type=True)>with<DynamicJaxprTrace(level=0/1)>
The problem arose with the `bool` function. 
While tracing the function update at /home/pedregosa/dev/jaxopt/jaxopt/_src/optax_wrapper.py:104 for jit, this concrete value was not available in Python because it depends on the value of the argument 'state'.

See https://jax.readthedocs.io/en/latest/errors.html#jax.errors.ConcretizationTypeError

from jaxopt.

fabianp avatar fabianp commented on July 28, 2024

I tried to protect the problmatic lines with a with jax.disable_jit(): statement but it still failed

from jaxopt.

fabianp avatar fabianp commented on July 28, 2024

Solved for the flax_resnet.py example in #119 . Leaving this issue open since there are other examples where the GPU utilization is poor

from jaxopt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.