GPytorch Runtime Error has different input types

298 Views Asked by At

I am following the simple regression tutorial on gpytorch and get the following error when trying to use 2 dimensional input space during a call to the loss function.

RuntimeError: !(has_different_input_dtypes && !config.promote_inputs_to_common_dtype_ && (has_undefined_outputs || config.enforce_safe_casting_to_output_ || config.cast_common_dtype_to_outputs_)) INTERNAL ASSERT FAILED at "../aten/src/ATen/TensorIterator.cpp":405, please report a bug to PyTorch. 

I am not quite sure what it means. Everything but the training data is still: https://github.com/cornellius-gp/gpytorch/blob/master/examples/01_Exact_GPs/Simple_GP_Regression.ipynb

2

There are 2 best solutions below

0
Olli On BEST ANSWER

The issue was my conversion of torch tensor.

I used: torch.from_numpy(array) Instead I should use: torch.tensor(array)

This is weird, but no issues now.

0
mgarort On

I came here looking for solutions for the same error, but in my case it was due to different precision types. For some reason different precision type errors are common and cryptic in GPytorch, and sometimes the origin of the rogue tensors with the wrong precision is not obvious.

A simple solution that I found here was to set the default floating point type for the entire script, for example

  • torch.set_default_dtype(torch.float64) for double precision (the usual for GPytorch), or

  • torch.set_default_dtype(torch.float32) for single precision.