Source code for pytorch_lightning.plugins.environments.xla_environment
# 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.importloggingimportosfrompytorch_lightning.plugins.environments.cluster_environmentimportClusterEnvironmentfrompytorch_lightning.utilities.importsimport_TPU_AVAILABLEif_TPU_AVAILABLE:importtorch_xla.core.xla_env_varsasxenvimporttorch_xla.core.xla_modelasxmlog=logging.getLogger(__name__)
[docs]classXLAEnvironment(ClusterEnvironment):"""Cluster environment for training on a TPU Pod with the `PyTorch/XLA <https://pytorch.org/xla>`_ library. A list of environment variables set by XLA can be found `here <https://github.com/pytorch/xla/blob/master/torch_xla/core/xla_env_vars.py>`_. """@propertydefcreates_processes_externally(self)->bool:returnFalse@propertydefmain_address(self)->str:returnos.environ[xenv.TPU_MESH_CTLER_ADDR]@propertydefmain_port(self)->int:returnint(os.environ[xenv.TPU_MESH_CTLER_PORT])
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.