Float16 (HalfTensor) in pytorch + cuda

1.9k views Asked by At

Can I set torch.HalfTensor as default and use it with CUDA?

I can't even create usual Conv2D:

In [1]: import torch 
In [2]: torch.__version__
Out[2]: '0.2.0_3'

In [3]: from torch import nn

In [4]: torch.set_default_tensor_type('torch.HalfTensor')

In [5]: conv1 = nn.Conv2d(1, 64, kernel_size=3, stride=1, padding=1, bias=False)
terminate called after throwing an instance of 'std::invalid_argument'
  what():  Unsupported tensor type
Aborted (core dumped)

UPD: it doesn't work without CUDA too but I'm interested in case with CUDA support.

0

There are 0 answers