Pytorch AttributeError: module 'torch' has no attribute 'set_grad_enabled'
AttributeError: module 'torch' has no attribute 'set_grad_enabled' 

Traceback (most recent call last):
  File 
   "/home/thaqafi/PycharmProjects/transfer_learning/tutorial_transfer.py", line 280, in 

model_ft = train_model(model_ft, criterion, optimizer_ft, exp_lr_scheduler, num_epochs=25)


File 
 "/home/thaqafi/PycharmProjects/transfer_learning/tutorial_transfer.py", line 179, in train_model
    with torch.set_grad_enabled(True):

AttributeError: module 'torch' has no attribute 'set_grad_enabled'

using source code form Pytorch webiste. 

http://pytorch.org/tutorials/beginner/transfer_learning_tutorial.html

As far as I know this feature was not available before version 0.4.0, so probably you are using a version lower than 0.4.0 (e.g. 0.3.1.).

Try updating PyTorch to version 0.4.0. if possible.
