【GPT模型训练】第一课:安装PyTorch环境

概述

为了深入深入理解大模型底层原理,未来更好微调,成为大模型架构师,开始从零到一开发一个大模型实践,实践过程笔记,进行记录,同时,帮志同道合的同学,打平这条学习的道路。

《从零构建大模型》书籍,运行环境配置
PyTorch版本 2.5.1

1.安装环境

1.1 conda环境

conda create --name scrach python=3.10

1.2 查看自己电脑的CUDA型号

命令:mvidia-smi
在这里插入图片描述

1.3 查看pytorch官网版本建议

https://pytorch.org/get-started/previous-versions/
在这里插入图片描述

在这里插入图片描述

  • torch2.4.1版本
pip install torch==2.4.1 torchvision==0.19.1 torchaudio==2.4.1 --index-url https://download.pytorch.org/whl/cu118
  • torch2.4.0版本 CUDA 11.8
# CUDA 11.8
pip install torch==2.4.0 torchvision==0.19.0 torchaudio==2.4.0 --index-url https://download.pytorch.org/whl/cu118

  • torch2.5.1版本
# CUDA 11.8
pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cu118

发现安装过程,主要卡住在下载torch包,该包2.5G,用浏览器或迅雷下载,

安装文件2.5G,可以下载回本地后,安装
在这里插入图片描述

1.4 安装本地的torch

pip install “torch-2.5.1+cu118-cp310-cp310-win_amd64.whl”

在这里插入图片描述
2.5.1版本,安装剩余模块
pip install torchvision0.20.1 torchaudio2.5.1 --index-url https://download.pytorch.org/whl/cu118
pip install tiktoken==0.7.0
pip install ipykernel

测试

File c:\ProgramData\anaconda3\envs\scratch\lib\site-packages\torch\utils\data\dataloader.py:701, in _BaseDataLoaderIter.__next__(self)
    698 if self._sampler_iter is None:
    699     # TODO(https://github.com/pytorch/pytorch/issues/76750)
    700     self._reset()  # type: ignore[call-arg]
--> 701 data = self._next_data()
    702 self._num_yielded += 1
    703 if (
    704     self._dataset_kind == _DatasetKind.Iterable
    705     and self._IterableDataset_len_called is not None
    706     and self._num_yielded > self._IterableDataset_len_called
    707 ):

File c:\ProgramData\anaconda3\envs\scratch\lib\site-packages\torch\utils\data\dataloader.py:756, in _SingleProcessDataLoaderIter._next_data(self)
    755 def _next_data(self):
--> 756     index = self._next_index()  # may raise StopIteration
...
File c:\ProgramData\anaconda3\envs\scratch\lib\site-packages\torch\utils\data\sampler.py:125, in SequentialSampler.__iter__(self)
    124 def __iter__(self) -> Iterator[int]:
--> 125     return iter(range(len(self.data_source)))

TypeError: object of type 'GPTDatasetV1' has no len()

检查版本:
把tiktoken改为与书本的环境一致就OK
pip install tiktoken==0.7.0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值