From 673dba1e628177dd5f6cad4d7cb3289cc77249b2 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Thu, 9 Aug 2018 15:38:02 -0700 Subject: [PATCH] Python 3.7 compatibility --- CMakeLists.txt | 2 +- src_py/elf/utils_elf.py | 12 ++++++------ src_py/rlpytorch/runner/parameter_server.py | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 43b4c5f..2302f89 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,7 +43,7 @@ endif() set(CMAKE_CXX_STANDARD 17) set(PYBIND11_CPP_STANDARD -std=c++17) set(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} -Wall -Werror -Wextra -Wno-register -fPIC -march=native") + "${CMAKE_CXX_FLAGS} -Wall -Werror -Wextra -Wno-register -Wno-deprecated-declarations -fPIC -march=native") set(CMAKE_CXX_FLAGS_RELEASE "-O3") if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) diff --git a/src_py/elf/utils_elf.py b/src_py/elf/utils_elf.py index 81c615d..3a2fba3 100644 --- a/src_py/elf/utils_elf.py +++ b/src_py/elf/utils_elf.py @@ -245,28 +245,28 @@ def half(self): for k, v in self.batch.items()} return new_batch - def cpu2gpu(self, gpu, async=True): + def cpu2gpu(self, gpu, non_blocking=True): ''' transfer batch data to gpu ''' # For each time step new_batch = self.empty_copy() - new_batch.batch = {k: v.cuda(gpu, async=async) + new_batch.batch = {k: v.cuda(gpu, non_blocking=non_blocking) for k, v in self.batch.items()} return new_batch - def cpu2cpu(self, gpu, async=True): + def cpu2cpu(self, gpu, non_blocking=True): ''' transfer batch data to gpu ''' # For each time step new_batch = self.empty_copy() new_batch.batch = {k: v.clone() for k, v in self.batch.items()} return new_batch - def transfer_cpu2gpu(self, batch_gpu, async=True): + def transfer_cpu2gpu(self, batch_gpu, non_blocking=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, non_blocking=non_blocking) - def transfer_cpu2cpu(self, batch_dst, async=True): + def transfer_cpu2cpu(self, batch_dst, non_blocking=True): ''' transfer batch data to cpu ''' # For each time step diff --git a/src_py/rlpytorch/runner/parameter_server.py b/src_py/rlpytorch/runner/parameter_server.py index a8594d5..d492166 100644 --- a/src_py/rlpytorch/runner/parameter_server.py +++ b/src_py/rlpytorch/runner/parameter_server.py @@ -245,7 +245,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, non_blocking=True) self.cvs_send[i].notify() self.cb_remote_batch_process(context, batch_gpu)