From 440746008db43b97365b3456c6a47aee81d58065 Mon Sep 17 00:00:00 2001 From: Douglas De Rizzo Meneghetti Date: Tue, 5 Nov 2019 19:13:56 -0300 Subject: [PATCH 1/3] fix async for usage with python 3.7 in python37, async is a reserved word, so I changed it --- elf/utils_elf.py | 6 +++--- elf_python/memory_receiver.py | 8 ++++---- rlpytorch/runner/parameter_server.py | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/elf/utils_elf.py b/elf/utils_elf.py index d3e30027..84e89e5a 100644 --- a/elf/utils_elf.py +++ b/elf/utils_elf.py @@ -188,13 +188,13 @@ def hist(self, s, key=None): else: return self[key][s] - def transfer_cpu2gpu(self, batch_gpu, async=True): + def transfer_cpu2gpu(self, batch_gpu, asynch=True): ''' transfer batch data to gpu ''' # For each time step for k, v in self.batch.items(): - batch_gpu[k].copy_(v, async=async) + batch_gpu[k].copy_(v, asynch=asynch) - def transfer_cpu2cpu(self, batch_dst, async=True): + def transfer_cpu2cpu(self, batch_dst, asynch=True): ''' transfer batch data to cpu ''' # For each time step diff --git a/elf_python/memory_receiver.py b/elf_python/memory_receiver.py index 4de5ebb7..9d91974c 100644 --- a/elf_python/memory_receiver.py +++ b/elf_python/memory_receiver.py @@ -75,19 +75,19 @@ def _cpu2gpu(batch_cpu, batch_gpu, allow_incomplete_batch=False): if isinstance(batch_cpu_t[k], (torch.FloatTensor, torch.LongTensor)): if allow_incomplete_batch: if len(batch_cpu_t[k].size()) == 1: - batch_gpu_t[k] = batch_cpu_t[k][:batchsize].cuda(async=True) + batch_gpu_t[k] = batch_cpu_t[k][:batchsize].cuda(asynch=True) else: - batch_gpu_t[k] = batch_cpu_t[k][:batchsize, :].cuda(async=True) + batch_gpu_t[k] = batch_cpu_t[k][:batchsize, :].cuda(asynch=True) else: if isinstance(batch_cpu_t[k], torch.FloatTensor): if k not in batch_gpu_t: batch_gpu_t[k] = torch.cuda.FloatTensor(batch_cpu_t[k].size()) - batch_gpu_t[k].copy_(batch_cpu_t[k], async=True) + batch_gpu_t[k].copy_(batch_cpu_t[k], asynch=True) elif isinstance(batch_cpu_t[k], torch.LongTensor): if k not in batch_gpu_t: batch_gpu_t[k] = torch.cuda.LongTensor(batch_cpu_t[k].size()) - batch_gpu_t[k].copy_(batch_cpu_t[k], async=True) + batch_gpu_t[k].copy_(batch_cpu_t[k], asynch=True) else: batch_gpu_t[k] = batch_cpu_t[k] diff --git a/rlpytorch/runner/parameter_server.py b/rlpytorch/runner/parameter_server.py index 62aee8a2..eddd6f4f 100644 --- a/rlpytorch/runner/parameter_server.py +++ b/rlpytorch/runner/parameter_server.py @@ -215,7 +215,7 @@ def process_main(self, i, gpu_id): while True: self.cvs_recv[i].wait() - utils_elf.transfer_cpu2gpu(batch, batch_gpu, async=True) + utils_elf.transfer_cpu2gpu(batch, batch_gpu, asynch=True) self.cvs_send[i].notify() self.cb_remote_batch_process(context, batch_gpu) From f6a632f4d6ff254fba3b50d5351e6672a70797c4 Mon Sep 17 00:00:00 2001 From: Douglas De Rizzo Meneghetti Date: Tue, 5 Nov 2019 22:34:08 -0300 Subject: [PATCH 2/3] apparently, async was never needed --- elf/utils_elf.py | 6 +++--- elf_python/memory_receiver.py | 8 ++++---- rlpytorch/runner/parameter_server.py | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/elf/utils_elf.py b/elf/utils_elf.py index 84e89e5a..e6904f17 100644 --- a/elf/utils_elf.py +++ b/elf/utils_elf.py @@ -188,13 +188,13 @@ def hist(self, s, key=None): else: return self[key][s] - def transfer_cpu2gpu(self, batch_gpu, asynch=True): + def transfer_cpu2gpu(self, batch_gpu, =True): ''' transfer batch data to gpu ''' # For each time step for k, v in self.batch.items(): - batch_gpu[k].copy_(v, asynch=asynch) + batch_gpu[k].copy_(v) - def transfer_cpu2cpu(self, batch_dst, asynch=True): + def transfer_cpu2cpu(self, batch_dst): ''' transfer batch data to cpu ''' # For each time step diff --git a/elf_python/memory_receiver.py b/elf_python/memory_receiver.py index 9d91974c..9e44655b 100644 --- a/elf_python/memory_receiver.py +++ b/elf_python/memory_receiver.py @@ -75,19 +75,19 @@ def _cpu2gpu(batch_cpu, batch_gpu, allow_incomplete_batch=False): if isinstance(batch_cpu_t[k], (torch.FloatTensor, torch.LongTensor)): if allow_incomplete_batch: if len(batch_cpu_t[k].size()) == 1: - batch_gpu_t[k] = batch_cpu_t[k][:batchsize].cuda(asynch=True) + batch_gpu_t[k] = batch_cpu_t[k][:batchsize].cuda() else: - batch_gpu_t[k] = batch_cpu_t[k][:batchsize, :].cuda(asynch=True) + batch_gpu_t[k] = batch_cpu_t[k][:batchsize, :].cuda() else: if isinstance(batch_cpu_t[k], torch.FloatTensor): if k not in batch_gpu_t: batch_gpu_t[k] = torch.cuda.FloatTensor(batch_cpu_t[k].size()) - batch_gpu_t[k].copy_(batch_cpu_t[k], asynch=True) + batch_gpu_t[k].copy_(batch_cpu_t[k]) elif isinstance(batch_cpu_t[k], torch.LongTensor): if k not in batch_gpu_t: batch_gpu_t[k] = torch.cuda.LongTensor(batch_cpu_t[k].size()) - batch_gpu_t[k].copy_(batch_cpu_t[k], asynch=True) + batch_gpu_t[k].copy_(batch_cpu_t[k]) else: batch_gpu_t[k] = batch_cpu_t[k] diff --git a/rlpytorch/runner/parameter_server.py b/rlpytorch/runner/parameter_server.py index eddd6f4f..9bf56d64 100644 --- a/rlpytorch/runner/parameter_server.py +++ b/rlpytorch/runner/parameter_server.py @@ -215,7 +215,7 @@ def process_main(self, i, gpu_id): while True: self.cvs_recv[i].wait() - utils_elf.transfer_cpu2gpu(batch, batch_gpu, asynch=True) + utils_elf.transfer_cpu2gpu(batch, batch_gpu) self.cvs_send[i].notify() self.cb_remote_batch_process(context, batch_gpu) From 0b76b731569782b5c01e8626106c94afd6f68882 Mon Sep 17 00:00:00 2001 From: Douglas De Rizzo Meneghetti Date: Wed, 6 Nov 2019 15:40:47 -0300 Subject: [PATCH 3/3] removed a runaway '=True' --- elf/utils_elf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elf/utils_elf.py b/elf/utils_elf.py index e6904f17..9a80b8d7 100644 --- a/elf/utils_elf.py +++ b/elf/utils_elf.py @@ -188,7 +188,7 @@ def hist(self, s, key=None): else: return self[key][s] - def transfer_cpu2gpu(self, batch_gpu, =True): + def transfer_cpu2gpu(self, batch_gpu): ''' transfer batch data to gpu ''' # For each time step for k, v in self.batch.items():