Hi,
The following script consumes about 1 GB of memory in 100 iterations, and continually increases memory usage until it runs out of memory. I am using version 0.3.1 on Ubuntu 16.04.4 LTS(xenial)

class View(nn.Module):
“”“docstring for View"nn.Module”""
def init(self):
super(View, self).init()
def forward(self, input,shape):
return input.view(shape)


class LSTMAcousticModel(nn.Module):
“”“docstring for LSTMAcousticModel”""
def init(self, input_size=1800, lstm_hidden_size=1024, output_size=1945, nb_layers=3, context=True):
super(LSTMAcousticModel, self).init()
self._hidden_size = lstm_hidden_size
self._hidden_layers = nb_layers
self._context = context
self._input_size = input_size
self._output_size = output_size		
self.bn = nn.BatchNorm1d(num_features=self._input_size)
self.View = View()
self.LSTM = nn.LSTM(input_size=self._input_size, hidden_size=self._hidden_size, num_layers=self._hidden_layers, dropout=0.5, bias=True)
self.dropout = nn.Dropout(p=0.5)
self.hidden = nn.Linear(in_features=self.hidden_size, out_features=self.output_size, bias=True)
def forward(self, x):
x = self.bn(x)		
x = self.View(input=x, shape=(-1, x.data.size(0), x.data.size(1)))
x, (,) = self.LSTM(x)
x = self.dropout(self.hidden(x))
return x
model = LSTMAcousticModel(input_size=1800, lstm_hidden_size=1024, output_size=1945, nb_layers=3, context=True)
cross_entropy_loss = nn.CrossEntropyLoss()
optimizer = optim.Adam(
list(model.parameters()),
lr=args.lr,
betas=(args.beta_1, args.beta_2))
best_loss = 100000
patience_count = 0
start_iter = 0
for epochs in range(args.epochs):
running_loss = []
for i, data in enumerate(train_loader, start=start_iter):
inputs, targets, input_percentages, target_sizes = data		
inputs = inputs.view(inputs.size(0), inputs.size(2), -1)
if args.cuda:
inputs, targets = inputs.cuda(), targets.cuda()
model.cuda()
cross_entropy_loss.cuda()
target_sizes = target_sizes.cuda()
inputs, targets ,target_sizes = Variable(inputs), Variable(targets), Variable(target_sizes)
optimizer.zero_grad()
output = model(inputs)
loss = cross_entropy_loss(input=output.view(output.data.size(0)*output.data.size(1), -1), target=targets.view(-1))
loss.backward()
optimizer.step()

Is there something wrong in my code? I am not able to figure out. Kindly help. Sorry for the bad formatting. I am not able to figure out code formatting on this page.