Source code for pytorch_lightning.accelerators.accelerator
# Copyright The PyTorch Lightning team.## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.fromabcimportABC,abstractmethodfromtypingimportAny,Dict,Unionimporttorchimportpytorch_lightningaspl
[docs]classAccelerator(ABC):"""The Accelerator Base Class. An Accelerator is meant to deal with one type of Hardware. Currently there are accelerators for: - CPU - GPU - TPU - IPU - HPU """
[docs]defsetup_environment(self,root_device:torch.device)->None:"""Setup any processes or distributed connections. This is called before the LightningModule/DataModule setup hook which allows the user to access the accelerator environment before setup is complete. """
[docs]defsetup(self,trainer:"pl.Trainer")->None:"""Setup plugins for the trainer fit and creates optimizers. Args: trainer: the trainer instance """
[docs]defget_device_stats(self,device:Union[str,torch.device])->Dict[str,Any]:"""Get stats for a given device. Args: device: device for which to get stats Returns: Dictionary of device stats """raiseNotImplementedError
To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. Read PyTorch Lightning's Privacy Policy.