MaggotUBA breaks with GPU acceleration on
larvatagger.sh predict path/to/datafile --gpus all breaks with the following error message:
Traceback (most recent call last):
File "/app/MaggotUBA/src/maggotuba/models/predict_model.py", line 191, in <module>
main(predict_model)
File "/app/MaggotUBA/.venv/lib/python3.9/site-packages/taggingbackends/main.py", line 164, in main
return fun(backend, **args)
File "/app/MaggotUBA/src/maggotuba/models/predict_model.py", line 52, in predict_model
predict_individual_data_files(backend, model, input_files_and_labels)
File "/app/MaggotUBA/src/maggotuba/models/predict_model.py", line 121, in predict_individual_data_files
predictions = model.predict((t[larva], spines))
File "/app/MaggotUBA/.venv/lib/python3.9/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "/app/MaggotUBA/src/maggotuba/models/trainers.py", line 213, in predict
output = self.forward(data)
File "/app/MaggotUBA/src/maggotuba/models/trainers.py", line 132, in forward
y = self.model(x.to(self.device))
File "/app/MaggotUBA/.venv/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl
return forward_call(*input, **kwargs)
File "/app/MaggotUBA/src/maggotuba/models/modules.py", line 375, in forward
return self.clf(self.encoder(x))
File "/app/MaggotUBA/.venv/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl
return forward_call(*input, **kwargs)
File "/app/MaggotUBA/src/maggotuba/models/modules.py", line 69, in forward
return self.model(x)
File "/app/MaggotUBA/.venv/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl
return forward_call(*input, **kwargs)
File "/app/MaggotUBA/.venv/lib/python3.9/site-packages/behavior_model/models/neural_nets.py", line 31, in forward
convolutions = self.convolutional_blocks(x)
File "/app/MaggotUBA/.venv/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl
return forward_call(*input, **kwargs)
File "/app/MaggotUBA/.venv/lib/python3.9/site-packages/torch/nn/modules/container.py", line 204, in forward
input = module(input)
File "/app/MaggotUBA/.venv/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1190, in _call_impl
return forward_call(*input, **kwargs)
File "/app/MaggotUBA/.venv/lib/python3.9/site-packages/torch/nn/modules/conv.py", line 463, in forward
return self._conv_forward(input, self.weight, self.bias)
File "/app/MaggotUBA/.venv/lib/python3.9/site-packages/torch/nn/modules/conv.py", line 459, in _conv_forward
return F.conv2d(input, weight, bias, self.stride,
RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor) should be the same
This happens with the Docker image only, but it's not clear whether GPU acceleration is enabled with larvatagger.jl predict.
EDIT: Reproduced with JULIA_PROJECT=$(pwd)/TaggingBackends LarvaTagger/scripts/larvatagger.jl predict MaggotUBA-adapter 20221005-1 path/to/datafile
This happens if NVIDIA GPUs are available on the host.
Edited by François LAURENT