Fix RuntimeError: “fill_cuda” not implemented for ‘ComplexHalf’ – PyTorch Tutoial

By | June 7, 2023

When we are training a pytorch model, we may get this error: RuntimeError: “fill_cuda” not implemented for ‘ComplexHalf’. In this tutorial, we will introduce you how to fix it.

This error may like:

fill_cuda not implemented for complexhalf

As to us, when we are running this code, this error is reported.

scaler = GradScaler(enabled=hps.train.fp16_run)
with autocast(enabled=hps.train.fp16_run):
    pass

In order to understand how to use GradScaler, you can read:

Implement Mixed Precision Training with GradScaler in PyTorch – PyTorch Tutorial

How to fix this error?

The simplest way is set enabled = False, it means:

with autocast(enabled=False):
    pass

Then, you will find this error is fixed.