def cache_report(args=None): """ Gets info on memory by calling nuke.memory("info") If args are supplied they are passed to nuke.memory as well eg. nuke.memory( "info", args ) """ if args is not None and len(args) > 0: return nuke.memory("info", args) else: return nuke.memory("info")
def cache_clear(args=None): """ Clears the buffer memory cache by calling nuke.memory("free") If args are supplied they are passed to nuke.memory as well eg. nuke.memory( "free", args ) """ if args is not None and len(args) > 0: nuke.memory("free", args) else: nuke.memory("free")
def process(self, context): assert isinstance(context, pyblish.api.Context) number = nuke.memory('usage') context.create_instance('内存占用: {}GB'.format(round(number / 2.0**30, 2)), number=number, family='内存')
def get_memory_info(display=False): """ Return list of memory info. """ # values info = str(nuke.memory('info')) ram_total = byte_to_megabyte(nuke.memory('total_ram')) ram_in_use = byte_to_megabyte(nuke.memory('usage')) total_virtual_memory = byte_to_megabyte(nuke.memory('total_vm')) # memory_info memory_info = MemoryInfo(info, ram_total, ram_in_use, total_virtual_memory) # display if (display): # log logger.debug('{0}'.format(memory_info))
def render(frameList): _maxCache = str(max(nuke.memory("max_usage") / 1097152, 16) * 4) + "M" try: t = nuke.executeBackgroundNuke( nuke.EXE_PATH, [renderNode], nuke.FrameRanges(frameList), nuke.views(), {"maxThreads": 1, "maxCache": _maxCache}, ) THREAD_FRAMES[t] = frameList except Exception as e: print e
def _addPostKnobs(self): # Background render stuff self._bgRender = nuke.Boolean_Knob("bg_render", "Render in background") self._state.setKnob(self._bgRender, False) self._bgRender.setFlag(nuke.STARTLINE) self.addKnob(self._bgRender) self._numThreads = nuke.Int_Knob("num_threads", "Thread limit") self._numThreads.setVisible(self._bgRender.value()) self._state.setKnob(self._numThreads, max(nuke.NUM_CPUS / 2, 1)) self.addKnob(self._numThreads) self._maxMem = nuke.String_Knob("max_memory", "Memory limit") self._state.setKnob( self._maxMem, str(max(nuke.memory("max_usage") / 2097152, 16)) + "M") self._maxMem.setVisible(self._bgRender.value()) self.addKnob(self._maxMem)
def knobChanged(self, knob): RenderDialog.knobChanged(self, knob) if knob == self._defaultValues: self._setKnobAndStore(self._useRoi, False) self._setKnobAndStore(self._roi, (0, 0, 0, 0)) self._roi.setVisible(False) self._maxMem.setVisible(False) self._numThreads.setVisible(False) self._setKnobAndStore(self._viewerForSettings, "-") self._setKnobAndStore(self._channels, "rgba") self._setKnobAndStore(self._useProxy, False) self._setKnobAndStore(self._frameRange, str(nuke.root().frameRange())) self._setKnobAndStore(self._rangeEnum, "input") self._setKnobAndStore(self._continueOnError, True) self._setKnobAndStore(self._bgRender, False) self._setKnobAndStore(self._luts, "sRGB") self._setKnobAndStore(self._burnInLUT, False) self._setKnobAndStore(self._cleanup, True) self._setKnobAndStore( self._maxMem, str(max(nuke.memory("max_usage") / 2097152, 16)) + "M") self._setKnobAndStore(self._numThreads, max(nuke.NUM_CPUS / 2, 1)) elif (knob == self._viewerForSettings): if self._viewerForSettings.value() != "-": viewer = self._viewers[self._viewerForSettings.value()] self._setKnobAndStore(self._useRoi, viewer.roiEnabled()) roi = viewer.roi() if roi != None: self._roi.fromDict(roi) self._state.save(self._roi) self._channels.fromScript(viewer.knob("channels").toScript()) self._state.save(self._channels) self._setKnobAndStore(self._useProxy, nuke.root().proxy()) self._frameRangeFromViewer(viewer.name()) self._state.save(self._frameRange) self._setKnobAndStore(self._rangeEnum, viewer.name()) self._roi.setVisible(self._useRoi.value()) self._setKnobAndStore(self._luts, self._lutFromViewer(viewer.name())) elif (knob == self._useRoi): self._roi.setVisible(self._useRoi.value()) elif self._isViewerSettingKnob(knob): self._viewerForSettings.setValue("-") self._state.save(self._viewerForSettings) elif knob == self._luts: self._burnInLUT.setEnabled(self._luts.value() != "None")
def _addPostKnobs(self): # Background render stuff self._bgRender = nuke.Boolean_Knob("bg_render", "Render in background") self._state.setKnob(self._bgRender, False) self._bgRender.setFlag(nuke.STARTLINE) self.addKnob(self._bgRender) # Terminal Render self._termRender = nuke.Boolean_Knob("terminal_render", "Render in Terminal") self._state.setKnob(self._termRender, False) self._termRender.setFlag(nuke.STARTLINE) self.addKnob(self._termRender) if self._bgRender.value() or self._termRender.value(): self.bg_render_knobs = True else: self.bg_render_knobs = False self._numInstances = nuke.Int_Knob("num_instances", "Instance Number") self._numInstances.setVisible(self.bg_render_knobs) self._state.setKnob(self._numInstances, 1) self.addKnob(self._numInstances) self._numThreads = nuke.Int_Knob("num_threads", "Thread limit") self._numThreads.setVisible(self.bg_render_knobs) self._state.setKnob(self._numThreads, max(nuke.NUM_CPUS / 2, 1)) self.addKnob(self._numThreads) self._maxMem = nuke.String_Knob("max_memory", "Memory limit") self._state.setKnob( self._maxMem, str(max(nuke.memory("max_usage") / 2097152, 16)) + "M") self._maxMem.setVisible(self.bg_render_knobs) self.addKnob(self._maxMem) self._chunkSize = nuke.Int_Knob("chunk_size", "Chunk Size") self._chunkSize.setVisible(False) self._state.setKnob(self._chunkSize, 4) self.addKnob(self._chunkSize)
def knobChanged(self, knob): RenderDialog.knobChanged(self, knob) if knob == self._defaultValues: self._setKnobAndStore(self._useRoi, False) self._setKnobAndStore(self._roi, (0, 0, 0, 0)) self._roi.setVisible(False) self._maxMem.setVisible(False) self._numThreads.setVisible(False) self._setKnobAndStore(self._viewerForSettings, "-") self._setKnobAndStore(self._channels, "rgba") self._setKnobAndStore(self._useProxy, False) self._setKnobAndStore(self._frameRange, str(nuke.root().frameRange())) self._setKnobAndStore(self._rangeEnum, "input") self._setKnobAndStore(self._continueOnError, True) self._setKnobAndStore(self._bgRender, False) self._setKnobAndStore(self._luts, "sRGB") self._setKnobAndStore(self._burnInLUT, False) self._setKnobAndStore(self._cleanup, True) self._setKnobAndStore( self._maxMem, str(max(nuke.memory("max_usage") / 2097152, 16)) + "M") self._setKnobAndStore(self._numThreads, max(nuke.NUM_CPUS / 2, 1)) elif (knob == self._viewerForSettings): if self._viewerForSettings.value() != "-": viewer = self._viewers[self._viewerForSettings.value()] self._setKnobAndStore(self._useRoi, viewer.roiEnabled()) roi = viewer.roi() if roi != None: self._roi.fromDict(roi) self._state.save(self._roi) self._channels.fromScript(viewer.knob("channels").toScript()) self._state.save(self._channels) self._setKnobAndStore(self._useProxy, nuke.root().proxy()) self._frameRangeFromViewer(viewer.name()) self._state.save(self._frameRange) self._setKnobAndStore(self._rangeEnum, viewer.name()) self._roi.setVisible(self._useRoi.value()) self._setKnobAndStore(self._luts, self._lutFromViewer(viewer.name())) elif (knob == self._useRoi): self._roi.setVisible(self._useRoi.value()) elif self._isViewerSettingKnob(knob): self._viewerForSettings.setValue("-") self._state.save(self._viewerForSettings) elif knob == self._luts: self._burnInLUT.setEnabled(self._luts.value() != "None") if knob == self._flipbookEnum: for k in self._customKnobs: self.removeKnob(k) self.removeKnob(self.okButton) self.removeKnob(self.cancelButton) self._customKnobs = [] self.flipbookKnobs() self._makeOkCancelButton() elif knob in self._customKnobs: try: flipbookToRun = flipbooking.gFlipbookFactory.getApplication( self._flipbookEnum.value()) flipbookToRun.dialogKnobChanged(self, knob) except NotImplementedError: pass