You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ValueErrorTraceback (mostrecentcalllast)
46train_loader=utils.data.DataLoader(dataset)
47--->48trainer=Trainer(
49max_epochs=4,
50accelerator="auto",
[/usr/local/lib/python3.10/dist-packages/pytorch_lightning/trainer/connectors/accelerator_connector.py](https://localhost:8080/#) in _check_config_and_set_final_flags(self, strategy, accelerator, precision, plugins, sync_batchnorm)207208ifstrategy!="auto"andstrategynotinself._registered_strategiesandnotisinstance(strategy, Strategy):
-->209raiseValueError(
210f"You selected an invalid strategy name: `strategy={strategy!r}`."211" It must be either a string or an instance of `pytorch_lightning.strategies.Strategy`."ValueError: Youselectedaninvalidstrategyname: `strategy=<lightning_hivemind.strategy.HivemindStrategy object at 0x7f3d206726e0>`. Itmustbeeitherastringoraninstanceof`pytorch_lightning.strategies.Strategy`. Examplechoices: auto, ddp, ddp_spawn, deepspeed, ... Findacompletelistofoptionsinourdocumentationathttps://lightning.ai/
Code sample
importosfromtorchimportoptim, nn, utils, Tensorfromtorchvision.datasetsimportMNISTfromtorchvision.transformsimportToTensorimportlightning.pytorchasplfromlightning_hivemind.strategyimportHivemindStrategyfrompytorch_lightningimportTrainerimporttorch# define any number of nn.Modules (or use your current ones)encoder=nn.Sequential(nn.Linear(28*28, 64), nn.ReLU(), nn.Linear(64, 3))
decoder=nn.Sequential(nn.Linear(3, 64), nn.ReLU(), nn.Linear(64, 28*28))
# define the LightningModuleclassLitAutoEncoder(pl.LightningModule):
def__init__(self, encoder, decoder):
super().__init__()
self.encoder=encoderself.decoder=decoderdeftraining_step(self, batch, batch_idx):
# training_step defines the train loop.# it is independent of forwardx, y=batchx=x.view(x.size(0), -1)
z=self.encoder(x)
x_hat=self.decoder(z)
loss=nn.functional.mse_loss(x_hat, x)
# Logging to TensorBoard (if installed) by defaultself.log("train_loss", loss)
returnlossdefconfigure_optimizers(self):
optimizer=optim.Adam(self.parameters(), lr=1e-3)
returnoptimizer# init the autoencoderautoencoder=LitAutoEncoder(encoder, decoder)
dataset=MNIST(os.getcwd(), download=True, transform=ToTensor())
train_loader=utils.data.DataLoader(dataset)
trainer=Trainer(
max_epochs=4,
accelerator="auto",
devices=1iftorch.cuda.is_available() elseNone,strategy=HivemindStrategy(target_batch_size=8192)
)
trainer.fit(model=autoencoder, train_dataloaders=train_loader)
Environment
PyTorch Version (e.g., 1.0): 2.0.0+cu118
OS (e.g., Linux): Ubuntu 20.04.5 LTS
How you installed PyTorch (conda, pip, source): pip
Python version: Python 3.10.11
CUDA/cuDNN version: CUDA Version: 12.0
GPU models and configuration: Tesla T4
The text was updated successfully, but these errors were encountered:
🐛 Bug
Code sample
Environment
conda
,pip
, source): pipThe text was updated successfully, but these errors were encountered: