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

TypeError: requires_grad_() takes 1 positional argument but 2 were given #41

Closed
randywreed opened this issue Jan 27, 2021 · 11 comments
Closed

Comments

@randywreed
Copy link

randywreed commented Jan 27, 2021

Here's the code I'm using

from fastai.text.all import *  
from fastinference.inference import *   
learn_class=load_learner('/content/gdrive/MyDrive/TuesdayChatbot/classifier_model-'+ver+'.pkl')   
test=["In the article there were several things left out."]   
learn_class.predict(test)   
learn_class.intrinsic_attention(test[0])   
TypeError                                 Traceback (most recent call last)
<ipython-input-76-ba2c19ef8949> in <module>()
----> 1 learn_class.intrinsic_attention(test[0])

1 frames
/usr/local/lib/python3.6/dist-packages/fastinference/inference/text.py in _intrinsic_attention(learn, text, class_id)
    149     dl = learn.dls.test_dl([text])
    150     batch = next(iter(dl))[0]
--> 151     emb = learn.model[0].module.encoder(batch).detach().requires_grad_(True)
    152     lstm = learn.model[0].module(emb, True)
    153     learn.model.eval()

TypeError: requires_grad_() takes 1 positional argument but 2 were given
@muellerzr
Copy link
Owner

Can you please post the entire stack trace wrapped around the code ticks?

I'm pretty sure this has been fixed in the master version of fastai, but I can't tell without that.

@randywreed
Copy link
Author

edited above comment accordingly

@muellerzr
Copy link
Owner

muellerzr commented Jan 27, 2021

Yes, this has been fixed in master of fastai. However I'm also relooking the intrinsic attention implementation right now, so you may want to wait a day or two

@randywreed
Copy link
Author

So I was loading fastai through fastbook. I should load fastai directly from github?

@muellerzr
Copy link
Owner

Yes, this is what I mean by master

@xspellsteal
Copy link

xspellsteal commented Feb 14, 2021

Hello, I've faced the same issue while i was trying to set up a tensorboard with the fastai v2. I have posted the issue here:

Anyway i ll duplicate it here :)

TypeError Traceback (most recent call last) in

1 from fastai.callback.tensorboard import *
2 cbs = [TensorBoardCallback(log_dir=‘logs’, projector=True)]
----> 3 learn.fit_one_cycle(3, cbs=cbs)

/opt/conda/lib/python3.7/site-packages/fastai/callback/schedule.py in fit_one_cycle(self, n_epoch, lr_max, div, div_final, pct_start, wd, moms, cbs, reset_opt)
110 scheds = {‘lr’: combined_cos(pct_start, lr_max/div, lr_max, lr_max/div_final),
111 ‘mom’: combined_cos(pct_start, *(self.moms if moms is None else moms))}
–> 112 self.fit(n_epoch, cbs=ParamScheduler(scheds)+L(cbs), reset_opt=reset_opt, wd=wd)
113
114 # Cell

/opt/conda/lib/python3.7/site-packages/fastai/learner.py in fit(self, n_epoch, lr, wd, cbs, reset_opt)
209 self.opt.set_hypers(lr=self.lr if lr is None else lr)
210 self.n_epoch = n_epoch
–> 211 self._with_events(self._do_fit, ‘fit’, CancelFitException, self._end_cleanup)
212
213 def _end_cleanup(self): self.dl,self.xb,self.yb,self.pred,self.loss = None,(None,),(None,),None,None

/opt/conda/lib/python3.7/site-packages/fastai/learner.py in with_events(self, f, event_type, ex, final)
158
159 def with_events(self, f, event_type, ex, final=noop):
–> 160 try: self(f’before{event_type}’); f()
161 except ex: self(f’after_cancel{event_type}’)
162 self(f’after_{event_type}’); final()

/opt/conda/lib/python3.7/site-packages/fastai/learner.py in call(self, event_name)
139
140 def ordered_cbs(self, event): return [cb for cb in self.cbs.sorted(‘order’) if hasattr(cb, event)]
–> 141 def call(self, event_name): L(event_name).map(self._call_one)
142
143 def _call_one(self, event_name):

/opt/conda/lib/python3.7/site-packages/fastcore/foundation.py in map(self, f, gen, *args, **kwargs)
152 def range(cls, a, b=None, step=None): return cls(range_of(a, b=b, step=step))
153
–> 154 def map(self, f, *args, gen=False, **kwargs): return self._new(map_ex(self, f, *args, gen=gen, **kwargs))
155 def argwhere(self, f, negate=False, **kwargs): return self._new(argwhere(self, f, negate, **kwargs))
156 def filter(self, f=noop, negate=False, gen=False, **kwargs):

/opt/conda/lib/python3.7/site-packages/fastcore/basics.py in map_ex(iterable, f, gen, *args, **kwargs)
664 res = map(g, iterable)
665 if gen: return res
–> 666 return list(res)
667
668 # Cell

/opt/conda/lib/python3.7/site-packages/fastcore/basics.py in call(self, *args, **kwargs)
649 if isinstance(v,_Arg): kwargs[k] = args.pop(v.i)
650 fargs = [args[x.i] if isinstance(x, _Arg) else x for x in self.pargs] + args[self.maxi+1:]
–> 651 return self.func(*fargs, **kwargs)
652
653 # Cell

/opt/conda/lib/python3.7/site-packages/fastai/learner.py in _call_one(self, event_name)
143 def _call_one(self, event_name):
144 if not hasattr(event, event_name): raise Exception(f’missing {event_name}’)
–> 145 for cb in self.cbs.sorted(‘order’): cb(event_name)
146
147 def _bn_bias_state(self, with_bias): return norm_bias_params(self.model, with_bias).map(self.opt.state)

/opt/conda/lib/python3.7/site-packages/fastai/callback/core.py in call(self, event_name)
42 (self.run_valid and not getattr(self, ‘training’, False)))
43 res = None
—> 44 if self.run and _run: res = getattr(self, event_name, noop)()
45 if event_name==‘after_fit’: self.run=True #Reset self.run to True at each end of fit
46 return res

/opt/conda/lib/python3.7/site-packages/fastai/callback/tensorboard.py in before_fit(self)
57 b = self.dls.one_batch()
58 self.learn._split(b)
—> 59 self.writer.add_graph(self.model, *self.xb)
60
61 def after_batch(self):

/opt/conda/lib/python3.7/site-packages/torch/utils/tensorboard/writer.py in add_graph(self, model, input_to_model, verbose)
722 if hasattr(model, ‘forward’):
723 # A valid PyTorch model should have a ‘forward’ method
–> 724 self._get_file_writer().add_graph(graph(model, input_to_model, verbose))
725 else:
726 # Caffe2 models do not have the ‘forward’ method

/opt/conda/lib/python3.7/site-packages/torch/utils/tensorboard/_pytorch_graph.py in graph(model, args, verbose)
284 with torch.onnx.select_model_mode_for_export(model, torch.onnx.TrainingMode.EVAL): # TODO: move outside of torch.onnx?
285 try:
–> 286 trace = torch.jit.trace(model, args)
287 graph = trace.graph
288 torch._C._jit_pass_inline(graph)

/opt/conda/lib/python3.7/site-packages/torch/jit/_trace.py in trace(func, example_inputs, optimize, check_trace, check_inputs, check_tolerance, strict, _force_outplace, _module_class, _compilation_unit)
740 strict,
741 _force_outplace,
–> 742 _module_class,
743 )
744

/opt/conda/lib/python3.7/site-packages/torch/jit/_trace.py in trace_module(mod, inputs, optimize, check_trace, check_inputs, check_tolerance, strict, _force_outplace, _module_class, _compilation_unit)
964 _force_outplace,
965 True,
–> 966 _module_class,
967 )
968 finally:

/opt/conda/lib/python3.7/site-packages/torch/autograd/grad_mode.py in decorate_context(*args, **kwargs)
24 def decorate_context(*args, **kwargs):
25 with self.class():
—> 26 return func(*args, **kwargs)
27 return cast(F, decorate_context)
28

/opt/conda/lib/python3.7/site-packages/torch/jit/_trace.py in _check_trace(check_inputs, func, traced_func, check_tolerance, strict, force_outplace, is_trace_module, _module_class)
325 copied_dict = {}
326 for name, data in inputs.items():
–> 327 copied_dict[name] = _clone_inputs(data)
328 check_mod = torch.jit.trace_module(
329 func.self if hasattr(func, “self”) else func,

/opt/conda/lib/python3.7/site-packages/torch/jit/_trace.py in _clone_inputs(args)
158 return function._nested_map(
159 lambda x: isinstance(x, torch.Tensor), clone_input, condition_msg=“tensors”
–> 160 )(args)
161
162

/opt/conda/lib/python3.7/site-packages/torch/autograd/function.py in _map(obj)
272 def _map(obj):
273 if condition(obj):
–> 274 return fn(obj)
275 elif obj is None:
276 return None

/opt/conda/lib/python3.7/site-packages/torch/jit/trace.py in clone_input(a)
148 a.detach()
149 .clone(memory_format=torch.preserve_format)
–> 150 .requires_grad(a.requires_grad)
151 )
152 if a.grad is not None:

TypeError: requires_grad_() takes 1 positional argument but 2 were given

@muellerzr
Copy link
Owner

Same solution. Load with github until the latest release.

@xspellsteal
Copy link

xspellsteal commented Feb 14, 2021

Could you please tell me how to do that? My issue is not related to fastinference, but the error is same using fastai when i was trying to activate tensorboard callbacks

@muellerzr
Copy link
Owner

pip install git+https://github.com/fastai/fastai
pip install git+https://github.com/fastai/fastcore

@xspellsteal
Copy link

pip install git+https://github.com/fastai/fastai
pip install git+https://github.com/fastai/fastcore

I did as you said, but im still facing that error.

Collecting git+https://github.com/fastai/fastai
  Cloning https://github.com/fastai/fastai to /tmp/pip-req-build-cvi2wka1
Requirement already satisfied (use --upgrade to upgrade): fastai==2.2.5 from git+https://github.com/fastai/fastai in /opt/conda/lib/python3.7/site-packages
Requirement already satisfied: pip in /opt/conda/lib/python3.7/site-packages (from fastai==2.2.5) (20.2.2)
Requirement already satisfied: packaging in /opt/conda/lib/python3.7/site-packages (from fastai==2.2.5) (20.1)
Requirement already satisfied: fastcore<1.4,>=1.3.8 in /opt/conda/lib/python3.7/site-packages (from fastai==2.2.5) (1.3.19)
Requirement already satisfied: torchvision<0.9,>=0.8 in /opt/conda/lib/python3.7/site-packages (from fastai==2.2.5) (0.8.2)
Requirement already satisfied: matplotlib in /opt/conda/lib/python3.7/site-packages (from fastai==2.2.5) (3.2.1)
Requirement already satisfied: pandas in /opt/conda/lib/python3.7/site-packages (from fastai==2.2.5) (1.1.1)
Requirement already satisfied: requests in /opt/conda/lib/python3.7/site-packages (from fastai==2.2.5) (2.23.0)
Requirement already satisfied: pyyaml in /opt/conda/lib/python3.7/site-packages (from fastai==2.2.5) (5.3.1)
Requirement already satisfied: fastprogress>=0.2.4 in /opt/conda/lib/python3.7/site-packages (from fastai==2.2.5) (1.0.0)
Requirement already satisfied: pillow>6.0.0 in /opt/conda/lib/python3.7/site-packages (from fastai==2.2.5) (7.2.0)
Requirement already satisfied: scikit-learn in /opt/conda/lib/python3.7/site-packages (from fastai==2.2.5) (0.23.2)
Requirement already satisfied: scipy in /opt/conda/lib/python3.7/site-packages (from fastai==2.2.5) (1.4.1)
Requirement already satisfied: spacy<3 in /opt/conda/lib/python3.7/site-packages (from fastai==2.2.5) (2.2.4)
Requirement already satisfied: torch<1.8,>=1.7.0 in /opt/conda/lib/python3.7/site-packages (from fastai==2.2.5) (1.7.1)
Requirement already satisfied: six in /opt/conda/lib/python3.7/site-packages (from packaging->fastai==2.2.5) (1.14.0)
Requirement already satisfied: pyparsing>=2.0.2 in /opt/conda/lib/python3.7/site-packages (from packaging->fastai==2.2.5) (2.4.7)
Requirement already satisfied: numpy in /opt/conda/lib/python3.7/site-packages (from torchvision<0.9,>=0.8->fastai==2.2.5) (1.18.5)
Requirement already satisfied: cycler>=0.10 in /opt/conda/lib/python3.7/site-packages (from matplotlib->fastai==2.2.5) (0.10.0)
Requirement already satisfied: python-dateutil>=2.1 in /opt/conda/lib/python3.7/site-packages (from matplotlib->fastai==2.2.5) (2.8.1)
Requirement already satisfied: kiwisolver>=1.0.1 in /opt/conda/lib/python3.7/site-packages (from matplotlib->fastai==2.2.5) (1.2.0)
Requirement already satisfied: pytz>=2017.2 in /opt/conda/lib/python3.7/site-packages (from pandas->fastai==2.2.5) (2019.3)
Requirement already satisfied: chardet<4,>=3.0.2 in /opt/conda/lib/python3.7/site-packages (from requests->fastai==2.2.5) (3.0.4)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /opt/conda/lib/python3.7/site-packages (from requests->fastai==2.2.5) (1.24.3)
Requirement already satisfied: certifi>=2017.4.17 in /opt/conda/lib/python3.7/site-packages (from requests->fastai==2.2.5) (2020.6.20)
Requirement already satisfied: idna<3,>=2.5 in /opt/conda/lib/python3.7/site-packages (from requests->fastai==2.2.5) (2.9)
Requirement already satisfied: joblib>=0.11 in /opt/conda/lib/python3.7/site-packages (from scikit-learn->fastai==2.2.5) (0.14.1)
Requirement already satisfied: threadpoolctl>=2.0.0 in /opt/conda/lib/python3.7/site-packages (from scikit-learn->fastai==2.2.5) (2.1.0)
Requirement already satisfied: thinc==7.4.0 in /opt/conda/lib/python3.7/site-packages (from spacy<3->fastai==2.2.5) (7.4.0)
Requirement already satisfied: cymem<2.1.0,>=2.0.2 in /opt/conda/lib/python3.7/site-packages (from spacy<3->fastai==2.2.5) (2.0.3)
Requirement already satisfied: tqdm<5.0.0,>=4.38.0 in /opt/conda/lib/python3.7/site-packages (from spacy<3->fastai==2.2.5) (4.45.0)
Requirement already satisfied: blis<0.5.0,>=0.4.0 in /opt/conda/lib/python3.7/site-packages (from spacy<3->fastai==2.2.5) (0.4.1)
Requirement already satisfied: murmurhash<1.1.0,>=0.28.0 in /opt/conda/lib/python3.7/site-packages (from spacy<3->fastai==2.2.5) (1.0.2)
Requirement already satisfied: setuptools in /opt/conda/lib/python3.7/site-packages (from spacy<3->fastai==2.2.5) (46.1.3.post20200325)
Requirement already satisfied: plac<1.2.0,>=0.9.6 in /opt/conda/lib/python3.7/site-packages (from spacy<3->fastai==2.2.5) (1.1.3)
Requirement already satisfied: srsly<1.1.0,>=1.0.2 in /opt/conda/lib/python3.7/site-packages (from spacy<3->fastai==2.2.5) (1.0.2)
Requirement already satisfied: wasabi<1.1.0,>=0.4.0 in /opt/conda/lib/python3.7/site-packages (from spacy<3->fastai==2.2.5) (0.7.1)
Requirement already satisfied: catalogue<1.1.0,>=0.0.7 in /opt/conda/lib/python3.7/site-packages (from spacy<3->fastai==2.2.5) (1.0.0)
Requirement already satisfied: preshed<3.1.0,>=3.0.2 in /opt/conda/lib/python3.7/site-packages (from spacy<3->fastai==2.2.5) (3.0.2)
Requirement already satisfied: typing-extensions in /opt/conda/lib/python3.7/site-packages (from torch<1.8,>=1.7.0->fastai==2.2.5) (3.7.4.1)
Requirement already satisfied: importlib-metadata>=0.20; python_version < "3.8" in /opt/conda/lib/python3.7/site-packages (from catalogue<1.1.0,>=0.0.7->spacy<3->fastai==2.2.5) (1.6.0)
Requirement already satisfied: zipp>=0.5 in /opt/conda/lib/python3.7/site-packages (from importlib-metadata>=0.20; python_version < "3.8"->catalogue<1.1.0,>=0.0.7->spacy<3->fastai==2.2.5) (3.1.0)
Building wheels for collected packages: fastai
  Building wheel for fastai (setup.py) ... done
  Created wheel for fastai: filename=fastai-2.2.5-py3-none-any.whl size=192192 sha256=59360ca5832e9c61b43f57e42770410b0b6745c692c9e64d465403a98fafc076
  Stored in directory: /tmp/pip-ephem-wheel-cache-q7qywaxj/wheels/40/be/4f/b7f2aec4df5712626ceed9f20a8996eb05e31244e57e58d632
Successfully built fastai
WARNING: You are using pip version 20.2.2; however, version 21.0.1 is available.
You should consider upgrading via the '/opt/conda/bin/python3.7 -m pip install --upgrade pip' command.
Collecting git+https://github.com/fastai/fastcore
  Cloning https://github.com/fastai/fastcore to /tmp/pip-req-build-36paufmg
Requirement already satisfied: pip in /opt/conda/lib/python3.7/site-packages (from fastcore==1.3.20) (20.2.2)
Requirement already satisfied: packaging in /opt/conda/lib/python3.7/site-packages (from fastcore==1.3.20) (20.1)
Requirement already satisfied: pyparsing>=2.0.2 in /opt/conda/lib/python3.7/site-packages (from packaging->fastcore==1.3.20) (2.4.7)
Requirement already satisfied: six in /opt/conda/lib/python3.7/site-packages (from packaging->fastcore==1.3.20) (1.14.0)
Building wheels for collected packages: fastcore
  Building wheel for fastcore (setup.py) ... done
  Created wheel for fastcore: filename=fastcore-1.3.20-py3-none-any.whl size=52134 sha256=b416c69fbce3a247b3812df59eaffaec9ac6a36a9d45329db9a4b371e78f91d8
  Stored in directory: /tmp/pip-ephem-wheel-cache-zgt35c_2/wheels/74/46/b7/0d3dddeb22ca1b6f226a3d5b096df11a632951327002d86f1f
Successfully built fastcore
Installing collected packages: fastcore
  Attempting uninstall: fastcore
    Found existing installation: fastcore 1.3.19
    Uninstalling fastcore-1.3.19:
      Successfully uninstalled fastcore-1.3.19
Successfully installed fastcore-1.3.20
WARNING: You are using pip version 20.2.2; however, version 21.0.1 is available.
You should consider upgrading via the '/opt/conda/bin/python3.7 -m pip install --upgrade pip' command.

The error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-25-4b7157f74a3c> in <module>
      1 from fastai.callback.tensorboard import *
      2 cbs = [TensorBoardCallback(log_dir='logs', projector=True)]
----> 3 learn.fit_one_cycle(3, cbs=cbs)

/opt/conda/lib/python3.7/site-packages/fastai/callback/schedule.py in fit_one_cycle(self, n_epoch, lr_max, div, div_final, pct_start, wd, moms, cbs, reset_opt)
    110     scheds = {'lr': combined_cos(pct_start, lr_max/div, lr_max, lr_max/div_final),
    111               'mom': combined_cos(pct_start, *(self.moms if moms is None else moms))}
--> 112     self.fit(n_epoch, cbs=ParamScheduler(scheds)+L(cbs), reset_opt=reset_opt, wd=wd)
    113 
    114 # Cell

/opt/conda/lib/python3.7/site-packages/fastai/learner.py in fit(self, n_epoch, lr, wd, cbs, reset_opt)
    209             self.opt.set_hypers(lr=self.lr if lr is None else lr)
    210             self.n_epoch = n_epoch
--> 211             self._with_events(self._do_fit, 'fit', CancelFitException, self._end_cleanup)
    212 
    213     def _end_cleanup(self): self.dl,self.xb,self.yb,self.pred,self.loss = None,(None,),(None,),None,None

/opt/conda/lib/python3.7/site-packages/fastai/learner.py in _with_events(self, f, event_type, ex, final)
    158 
    159     def _with_events(self, f, event_type, ex, final=noop):
--> 160         try: self(f'before_{event_type}');  f()
    161         except ex: self(f'after_cancel_{event_type}')
    162         self(f'after_{event_type}');  final()

/opt/conda/lib/python3.7/site-packages/fastai/learner.py in __call__(self, event_name)
    139 
    140     def ordered_cbs(self, event): return [cb for cb in self.cbs.sorted('order') if hasattr(cb, event)]
--> 141     def __call__(self, event_name): L(event_name).map(self._call_one)
    142 
    143     def _call_one(self, event_name):

/opt/conda/lib/python3.7/site-packages/fastcore/foundation.py in map(self, f, gen, *args, **kwargs)
    152     def range(cls, a, b=None, step=None): return cls(range_of(a, b=b, step=step))
    153 
--> 154     def map(self, f, *args, gen=False, **kwargs): return self._new(map_ex(self, f, *args, gen=gen, **kwargs))
    155     def argwhere(self, f, negate=False, **kwargs): return self._new(argwhere(self, f, negate, **kwargs))
    156     def filter(self, f=noop, negate=False, gen=False, **kwargs):

/opt/conda/lib/python3.7/site-packages/fastcore/basics.py in map_ex(iterable, f, gen, *args, **kwargs)
    664     res = map(g, iterable)
    665     if gen: return res
--> 666     return list(res)
    667 
    668 # Cell

/opt/conda/lib/python3.7/site-packages/fastcore/basics.py in __call__(self, *args, **kwargs)
    649             if isinstance(v,_Arg): kwargs[k] = args.pop(v.i)
    650         fargs = [args[x.i] if isinstance(x, _Arg) else x for x in self.pargs] + args[self.maxi+1:]
--> 651         return self.func(*fargs, **kwargs)
    652 
    653 # Cell

/opt/conda/lib/python3.7/site-packages/fastai/learner.py in _call_one(self, event_name)
    143     def _call_one(self, event_name):
    144         if not hasattr(event, event_name): raise Exception(f'missing {event_name}')
--> 145         for cb in self.cbs.sorted('order'): cb(event_name)
    146 
    147     def _bn_bias_state(self, with_bias): return norm_bias_params(self.model, with_bias).map(self.opt.state)

/opt/conda/lib/python3.7/site-packages/fastai/callback/core.py in __call__(self, event_name)
     42                (self.run_valid and not getattr(self, 'training', False)))
     43         res = None
---> 44         if self.run and _run: res = getattr(self, event_name, noop)()
     45         if event_name=='after_fit': self.run=True #Reset self.run to True at each end of fit
     46         return res

/opt/conda/lib/python3.7/site-packages/fastai/callback/tensorboard.py in before_fit(self)
     57             b = self.dls.one_batch()
     58             self.learn._split(b)
---> 59             self.writer.add_graph(self.model, *self.xb)
     60 
     61     def after_batch(self):

/opt/conda/lib/python3.7/site-packages/torch/utils/tensorboard/writer.py in add_graph(self, model, input_to_model, verbose)
    722         if hasattr(model, 'forward'):
    723             # A valid PyTorch model should have a 'forward' method
--> 724             self._get_file_writer().add_graph(graph(model, input_to_model, verbose))
    725         else:
    726             # Caffe2 models do not have the 'forward' method

/opt/conda/lib/python3.7/site-packages/torch/utils/tensorboard/_pytorch_graph.py in graph(model, args, verbose)
    284     with torch.onnx.select_model_mode_for_export(model, torch.onnx.TrainingMode.EVAL):  # TODO: move outside of torch.onnx?
    285         try:
--> 286             trace = torch.jit.trace(model, args)
    287             graph = trace.graph
    288             torch._C._jit_pass_inline(graph)

/opt/conda/lib/python3.7/site-packages/torch/jit/_trace.py in trace(func, example_inputs, optimize, check_trace, check_inputs, check_tolerance, strict, _force_outplace, _module_class, _compilation_unit)
    740             strict,
    741             _force_outplace,
--> 742             _module_class,
    743         )
    744 

/opt/conda/lib/python3.7/site-packages/torch/jit/_trace.py in trace_module(mod, inputs, optimize, check_trace, check_inputs, check_tolerance, strict, _force_outplace, _module_class, _compilation_unit)
    964                         _force_outplace,
    965                         True,
--> 966                         _module_class,
    967                     )
    968     finally:

/opt/conda/lib/python3.7/site-packages/torch/autograd/grad_mode.py in decorate_context(*args, **kwargs)
     24         def decorate_context(*args, **kwargs):
     25             with self.__class__():
---> 26                 return func(*args, **kwargs)
     27         return cast(F, decorate_context)
     28 

/opt/conda/lib/python3.7/site-packages/torch/jit/_trace.py in _check_trace(check_inputs, func, traced_func, check_tolerance, strict, force_outplace, is_trace_module, _module_class)
    325             copied_dict = {}
    326             for name, data in inputs.items():
--> 327                 copied_dict[name] = _clone_inputs(data)
    328             check_mod = torch.jit.trace_module(
    329                 func.__self__ if hasattr(func, "__self__") else func,

/opt/conda/lib/python3.7/site-packages/torch/jit/_trace.py in _clone_inputs(args)
    158     return function._nested_map(
    159         lambda x: isinstance(x, torch.Tensor), clone_input, condition_msg="tensors"
--> 160     )(args)
    161 
    162 

/opt/conda/lib/python3.7/site-packages/torch/autograd/function.py in _map(obj)
    272     def _map(obj):
    273         if condition(obj):
--> 274             return fn(obj)
    275         elif obj is None:
    276             return None

/opt/conda/lib/python3.7/site-packages/torch/jit/_trace.py in clone_input(a)
    148                 a.detach()
    149                 .clone(memory_format=torch.preserve_format)
--> 150                 .requires_grad_(a.requires_grad)
    151             )
    152             if a.grad is not None:

TypeError: requires_grad_() takes 1 positional argument but 2 were given

@muellerzr
Copy link
Owner

muellerzr commented Feb 14, 2021

Given this is a fastai issue open an issue there. This repo isn't meant for fastai issues. And please include a complete reproducer as well when you do.

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

3 participants