When cuda() is called, a list of modules cannot shift to the GPU

Hi, below is my definition of network:

class  CNN_Text(nn.Module):
    def __init__(self, args):
        self.args = args
        V = args.embed_num
        D = args.embed_dim
        C = args.class_num
        Ci = 1
        Co = args.kernel_num
        Ks = args.kernel_sizes

        self.embed = nn.Embedding(V, D)
        self.convs1 = [nn.Conv2d(Ci, Co, (K, D)) for K in Ks]

        self.dropout = nn.Dropout(args.dropout)
        self.fc1 = nn.Linear(len(Ks)*Co, C)

However, when i called cuda() on the model, the modules in the list self.convs1 will not shift to the GPU, how to solve this problem, any ideas ?

You need to use nn.ModuleList rather than a plain Python list of modules.

thanksm but it gives me the error

AttributeError: 'module' object has no attribute 'ModuleList'

is it a problem related to the version of pytorch?

Many Thanks, it solves my problem. And Updating my pytorch makes ModuleList available.