@Eric_K posted a new topic, subject "UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 918: ordinal not in range(128)". It read:

   I meet a problem about loading model. The IDE raise “UnicodeDecodeError: ‘ascii' codec can't decode byte 0xc3 in position 918: ordinal not in range(128)” error when I use model = torch.load(“file.pth”)  
    (ps: the .pth file comes from somewhere, and it was not trained by myself. The pth file trained by myself can be loaded using torch.load) .  
    Thanks for helps!!

@herleeyandi (Herleeyandi Markoni) replied

    @Eric_K Hello I have the same problem. I am using anaconda pytorch 0.3.1.post2 in python 3.6 with cuda8.0 . Have you figuring out how to solve this problem?

After which, @Eric_K added

    Someone told me the most possible reason is the version of python. Maybe the model is saved in python 2 that lead to your error. But I haven't implement it.

@Eric_K replied

    Someone told me the most possible reason is that the version of python…
    
      
      
      
    信工 刘蓬博
    
    邮箱：theresa60@example.net
    
    签名由 网易邮箱大师 定制

Then @herleeyandi (Herleeyandi Markoni) said

    I see man. That makes sense. Have you explored possiblity to convert that to pytorch python 3?  
    I also make it as issues in pytorch github here. I hope it can solve soon.

After which, @Eric_K added

    Because it's not the main problem that bother me. I haven't figure out how to convert it…I will focus on your issues in pytorch github. Thank you~

After which, @ariaaay (Aria Wang) added

    The same error happens to me.  
    What happens in my case is that, the model is saved as a ‘DataParallel' object with python 2.  
    I solved it by loading the model with torch.load() in python 2. I then extracted the state_dict and saved it as a dictionary using torch.save. The dictionary then can be loaded with python 3 with no error.
    
    In python 2,
    [code] 
        saved = torch.load(fpath)
        saved_sd = saved.state_dict()
        output = {'arch': 'resnet18',\
                  'state_dict': saved_sd}
        torch.save(output, newpath)
        
    [/code]
    
    In python 3,
    [code] 
        torch.load(newpath)
        
    [/code]


{'source': 'discourse', 'url': 'https://discuss.pytorch.org/t/unicodedecodeerror-ascii-codec-cant-decode-byte-0xc3-in-position-918-ordinal-not-in-range-128/15356', 'title': "UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 918: ordinal not in range(128)", 'views': 6366, 'has_accepted_answer': False, 'word_count': 401, 'like_count': 3, 'reply_count': 4, 'participant_count': 3, 'posts': 7, 'tags': '', 'author': '@Eric_K', 'participants': '@Eric_K, @herleeyandi (Herleeyandi Markoni), @ariaaay (Aria Wang)', 'image_url': [None], 'created_at': '2018-03-23T13:57:10.071Z', 'last_posted_at': '2018-04-26T20:18:55.503Z'}