diff options
author | Patrick Mours <pmours@nvidia.com> | 2020-06-08 18:16:10 +0300 |
---|---|---|
committer | Patrick Mours <pmours@nvidia.com> | 2020-06-08 18:55:49 +0300 |
commit | 9f7d84b656fbb56966620ecc249ce5bc7089a1d1 (patch) | |
tree | d0a022feae43f6db2166cf5214b56cce99b96a60 /intern/cycles/blender | |
parent | 0a907657d4d525d320e0c8518f583b7210736214 (diff) |
Cycles: Add support for P2P memory distribution (e.g. via NVLink)
This change modifies the multi-device implementation to support memory distribution
across devices, to reduce the overall memory footprint of large scenes and allow scenes to
fit entirely into combined GPU memory that previously had to fall back to host memory.
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D7426
Diffstat (limited to 'intern/cycles/blender')
-rw-r--r-- | intern/cycles/blender/addon/properties.py | 27 | ||||
-rw-r--r-- | intern/cycles/blender/blender_device.cpp | 4 | ||||
-rw-r--r-- | intern/cycles/blender/blender_python.cpp | 3 |
3 files changed, 26 insertions, 8 deletions
diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py index da18ac7c693..1635afab210 100644 --- a/intern/cycles/blender/addon/properties.py +++ b/intern/cycles/blender/addon/properties.py @@ -1535,6 +1535,12 @@ class CyclesPreferences(bpy.types.AddonPreferences): devices: bpy.props.CollectionProperty(type=CyclesDeviceSettings) + peer_memory: BoolProperty( + name="Distribute memory across devices", + description="Make more room for large scenes to fit by distributing memory across interconnected devices (e.g. via NVLink) rather than duplicating it", + default=False, + ) + def find_existing_device_entry(self, device): for device_entry in self.devices: if device_entry.id == device[2] and device_entry.type == device[1]: @@ -1632,14 +1638,21 @@ class CyclesPreferences(bpy.types.AddonPreferences): row = layout.row() row.prop(self, "compute_device_type", expand=True) - devices = self.get_devices_for_type(self.compute_device_type) + if self.compute_device_type == 'NONE': + return row = layout.row() - if self.compute_device_type == 'CUDA': - self._draw_devices(row, 'CUDA', devices) - elif self.compute_device_type == 'OPTIX': - self._draw_devices(row, 'OPTIX', devices) - elif self.compute_device_type == 'OPENCL': - self._draw_devices(row, 'OPENCL', devices) + devices = self.get_devices_for_type(self.compute_device_type) + self._draw_devices(row, self.compute_device_type, devices) + + import _cycles + has_peer_memory = 0 + for device in _cycles.available_devices(self.compute_device_type): + if device[3] and self.find_existing_device_entry(device).use: + has_peer_memory += 1 + if has_peer_memory > 1: + row = layout.row() + row.use_property_split = True + row.prop(self, "peer_memory") def draw(self, context): self.draw_impl(self.layout, context) diff --git a/intern/cycles/blender/blender_device.cpp b/intern/cycles/blender/blender_device.cpp index 5140f190f36..3a923459782 100644 --- a/intern/cycles/blender/blender_device.cpp +++ b/intern/cycles/blender/blender_device.cpp @@ -113,6 +113,10 @@ DeviceInfo blender_device_info(BL::Preferences &b_preferences, BL::Scene &b_scen device = Device::get_multi_device(used_devices, threads, background); } /* Else keep using the CPU device that was set before. */ + + if (!get_boolean(cpreferences, "peer_memory")) { + device.has_peer_memory = false; + } } } diff --git a/intern/cycles/blender/blender_python.cpp b/intern/cycles/blender/blender_python.cpp index 79c16856462..0be19dbffd1 100644 --- a/intern/cycles/blender/blender_python.cpp +++ b/intern/cycles/blender/blender_python.cpp @@ -416,10 +416,11 @@ static PyObject *available_devices_func(PyObject * /*self*/, PyObject *args) for (size_t i = 0; i < devices.size(); i++) { DeviceInfo &device = devices[i]; string type_name = Device::string_from_type(device.type); - PyObject *device_tuple = PyTuple_New(3); + PyObject *device_tuple = PyTuple_New(4); PyTuple_SET_ITEM(device_tuple, 0, pyunicode_from_string(device.description.c_str())); PyTuple_SET_ITEM(device_tuple, 1, pyunicode_from_string(type_name.c_str())); PyTuple_SET_ITEM(device_tuple, 2, pyunicode_from_string(device.id.c_str())); + PyTuple_SET_ITEM(device_tuple, 3, PyBool_FromLong(device.has_peer_memory)); PyTuple_SET_ITEM(ret, i, device_tuple); } |