ClearCudaCache¶ class torchrl.trainers.ClearCudaCache(interval: int)[source]¶ 以给定间隔清除 cuda 缓存。 示例 >>> clear_cuda = ClearCudaCache(100) >>> trainer.register_op("pre_optim_steps", clear_cuda) abstract register(trainer: Trainer, name: str)¶ Registers the hook in the trainer at a default location. 参数: trainer (Trainer) – the trainer where the hook must be registered. name (str) – the name of the hook. 注意 To register the hook at another location than the default, use register_op().