cellpose
cellpose copied to clipboard
"element 0 of tensors does not require grad" when training model
When I try to train my model (through the GUI), I get the following error:
Traceback (most recent call last):
File "/Users/kelsey/cellpose/cellpose/gui/gui.py", line 1618, in new_model
self.train_model()
File "/Users/kelsey/cellpose/cellpose/gui/gui.py", line 1642, in train_model
self.new_model_path = self.model.train(self.train_data, self.train_labels,
File "/Users/kelsey/cellpose/cellpose/models.py", line 784, in train
model_path = self._train_net(train_data, train_flows,
File "/Users/kelsey/cellpose/cellpose/core.py", line 892, in _train_net
train_loss = self._train_step(imgi, lbl)
File "/Users/kelsey/cellpose/cellpose/core.py", line 745, in _train_step
loss.backward()
File "/Users/kelsey/mambaforge/envs/cellpose-env/lib/python3.9/site-packages/torch/_tensor.py", line 488, in backward
torch.autograd.backward(
File "/Users/kelsey/mambaforge/envs/cellpose-env/lib/python3.9/site-packages/torch/autograd/__init__.py", line 197, in backward
Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass
RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn
I'm running on a mac with an M1 chip, so I had to follow the instructions here to get it running on GPU (which it appears to be doing), but not sure if I'm having issues b/c of that
just found a relevant thread on this here: https://forum.image.sc/t/cellpose-on-macos-m1-pro-apple-silicon-arm64/68018/30 starting yesterday (2/12/23)
PR #668 might be the fix, we'll look into it.