diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a475a30..b27faf78 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ FIND_PACKAGE(Torch REQUIRED) #LINK_DIRECTORIES("${TENSORFLOW_DIR}/lib") # Specify the C++ version we are building for. -SET (CMAKE_CXX_STANDARD 11) +SET (CMAKE_CXX_STANDARD 14) # Set flags for linking on mac IF(APPLE) diff --git a/platforms/cuda/src/CudaTorchKernels.cpp b/platforms/cuda/src/CudaTorchKernels.cpp index ea43cb38..c0a891b5 100644 --- a/platforms/cuda/src/CudaTorchKernels.cpp +++ b/platforms/cuda/src/CudaTorchKernels.cpp @@ -83,7 +83,8 @@ double CudaCalcTorchForceKernel::execute(ContextImpl& context, bool includeForce torch::Tensor energyTensor = module.forward(inputs).toTensor(); if (includeForces) { energyTensor.backward(); - torch::Tensor forceTensor = posTensor.grad(); + // Note: "forceTensor" needs to be cloned due to a shared context (https://github.com/openmm/openmm-torch/issues/13) + torch::Tensor forceTensor = posTensor.grad().clone(); cu.setAsCurrent(); void* data; if (cu.getUseDoublePrecision()) {