An example:
use_cuda = torch.cuda.is_available()
if use_cuda:
        X_tensor = Variable(torch.from_numpy(x_data_np).cuda()) # Note the conversion for pytorch    
    else:
        X_tensor = Variable(torch.from_numpy(x_data_np)) # Note the conversion for pytorch