When I use the Ray with pytorch, I do not set any num_gpus flag for the remote class.
I get the following error:
RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False.
The main process is: I create a remote class and transfer a pytorch model state_dict()(created in main function)
to it. In the main function, the torch.cuda.is_available()
is True
, but In the remote function, torch.cuda.is_available()
is False
. Thanks
I try to set the num_gpus=1 and got a new issue: the program just got stuck. Below is the minimal example code for reproducing this issue. Thanks.
import ray
@ray.remote(num_gpus=1)
class Worker(object):
def __init__(self, args):
self.args = args
self.gen_frames = 0
def set_gen_frames(self, value):
self.gen_frames = value
return self.gen_frames
def get_gen_num(self):
return self.gen_frames
class Parameters:
def __init__(self):
self.is_cuda = False;
self.is_memory_cuda = True
self.pop_size = 10
if __name__ == "__main__":
ray.init()
args = Parameters()
workers = [Worker.remote(args) for _ in range(args.pop_size)]
get_num_ids = [worker.get_gen_num.remote() for worker in workers]
gen_nums = ray.get(get_num_ids)
print(gen_nums)