Issue
I have two GPUs and when I run
import torch
print('count: ', torch.cuda.device_count()) # prints count: 2
However, my model throws an error
RuntimeError: Attempting to deserialize object on CUDA device 2 but torch.cuda.device_count() is 1
on the line
torch.load(model_path, map_location='cuda:1')
What could cause it and how to fix it?
This issue is somehow linked to my Flask, because the training itself works with torch.load(model_path, map_location='cuda:1')
Solution
This is a known Flask-CUDA issue. Please run Flask with it with
print('count: ', torch.cuda.device_count())
and check if you see
count: 2
reloading
count: 1
If so, add app.run(... , use_reloader=False)
Answered By - Анастасия 86
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.