gpt4 book ai didi

pytorch - __init__() 获得意外的关键字参数 'gpus'

转载 作者:行者123 更新时间:2023-12-03 07:56:55 28 4
gpt4 key购买 nike

我正在尝试使用 pytorch 来进行生成式人工智能。如该视频所示: https://www.youtube.com/watch?v=_pIMdDWK5sc

我导入所有内容,如图所示:

import os

import torch
import torchvision
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
import torchvision.datasets as datasets
import torchvision.transforms as transforms
from torch.utils.data import DataLoader, random_split
from torchvision.datasets import MNIST

import matplotlib.pyplot as plt

import pytorch_lightning as pl


random_seed = 42
torch.manual_seed(random_seed)

BATCH_SIZE=128
AVAIL_GPUS = min(1, torch.cuda.device_count())
NUM_WORKERS=int(os.cpu_count() / 2)

但是当我运行训练器时:

trainer = pl.Trainer(max_epochs=20, gpus=AVAIL_GPUS)
trainer.fit(model, dm)

它向我显示了错误:

__init__() got an unexpected keyword argument 'gpus'

最佳答案

https://lightning.ai/docs/pytorch/stable/common/trainer.html

使用训练器 = pl.Trainer(max_epochs=20,accelerator="auto")

关于pytorch - __init__() 获得意外的关键字参数 'gpus',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75844315/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com