BERT-Dialog-State-Tracking icon indicating copy to clipboard operation
BERT-Dialog-State-Tracking copied to clipboard

AttributeError: 'NoneType' object has no attribute 'to'

Open larunxn opened this issue 2 years ago • 1 comments

Traceback (most recent call last): File "E:\Project\DST\BERT-Dialog-State-Tracking-master21\main.py", line 120, in main(opts) File "E:\Project\DST\BERT-Dialog-State-Tracking-master21\main.py", line 75, in main model.move_to_device(opts) File "E:\Project\DST\BERT-Dialog-State-Tracking-master21\models.py", line 78, in move_to_device self.bert.to(args.device) AttributeError: 'NoneType' object has no attribute 'to'

larunxn avatar Apr 01 '22 13:04 larunxn

@larunxn Hi, probably you are using Windows not Linux. I had the same problem and solved it. The problem is in file_utils.py file, in get_from_cache function. This line "urllib.request.urlretrieve(url, temp_file.name)" internally tries to open the temp file, which is already opened, so that causes an error on windows. I solved this by closing the tmp file before the function call "temp_file.close()" the open it again after it "temp_file = open(temp_file.name, 'w')". It worked. But at the end, downloaded model is a tar file, so I will try to run code now in an ubuntu docker container to avoid the headache of trying to made code windows compatible.

BelalElhossany avatar Nov 05 '22 20:11 BelalElhossany