Closed vinhqdang closed 5 years ago
Hi vinhqdang,
cuda_functional is only required when you want to use SRU instead of LSTM. I modified model.py
so that you don't have to from cuda_functional import SRU
when you use LSTM. (I simply moved the location of from cuda_functional import SRU
like this:
.
class RNNPredictor(nn.Module):
"""Container module with an encoder, a recurrent module, and a decoder."""
def __init__(self, rnn_type, enc_inp_size, rnn_inp_size, rnn_hid_size, dec_out_size, nlayers, dropout=0.5,
tie_weights=False,res_connection=False):
super(RNNPredictor, self).__init__()
self.enc_input_size = enc_inp_size
self.drop = nn.Dropout(dropout)
self.encoder = nn.Linear(enc_inp_size, rnn_inp_size)
if rnn_type in ['LSTM', 'GRU']:
self.rnn = getattr(nn, rnn_type)(rnn_inp_size, rnn_hid_size, nlayers, dropout=dropout)
elif rnn_type == 'SRU':
from cuda_functional import SRU
self.rnn = SRU(input_size=rnn_inp_size,hidden_size=rnn_hid_size,num_layers=nlayers,dropout=dropout,
use_tanh=False,use_selu=True,layer_norm=True)
else:
'''
Attempting to run the code on cpu with LSTM default;
python 1_train_predictor.py --data nyc_taxi --filename nyc_taxi.pkl --device cpu
I've run this model successfully on the GPU but when switching to CPU I have the following error.
RuntimeError: invalid argument 2: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Call .contiguous() before .view(). at /pytorch/aten/src/TH/generic/THTensor.cpp:237
@drillep See #2.
Hi there
When I tried to follow the example, it seems that the package "cuda_functional" is required. However, this package requires GPU and CUDA.
Is there a way that I can perform your code on CPU only?
Thanks