def a(): """ """ print(torch.cuda.memory_cached(global_torch_device())) with TorchCacheSession(): torch.tensor([0.0], device=global_torch_device()) print(torch.cuda.memory_cached(global_torch_device())) print(torch.cuda.memory_cached(global_torch_device()))
def e(): """ """ print( global_torch_device(override=global_torch_device( device_preference=True))) print(global_torch_device()) with TorchCpuSession(): print(global_torch_device()) print(global_torch_device())
def d(): """ """ print( global_torch_device(override=global_torch_device( device_preference=False))) print(global_torch_device()) with TorchCudaSession(): print(global_torch_device()) print(global_torch_device())
def __init__(self, using_cuda: bool = global_torch_device().type == "cuda"): self.using_cuda = using_cuda