Answers for "pytorch lightning init not on cuda"

0

pytorch lightning init not on cuda

# tensor created in __init__ wont be added to cuda
# use self.register_buffer to register variables 

class LitModel(LightningModule):

    def __init__(self):
        ...
        self.register_buffer("sigma", torch.eye(3))
        # you can now access self.sigma anywhere in your module
Posted by: Guest on January-15-2021

Python Answers by Framework

Browse Popular Code Answers by Language