当前位置: 首页 > news >正文

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

这里写自定义目录标题

  • 概述
  • 1.安装环境
    • 1.1 conda环境
    • 1.2 查看自己电脑的CUDA型号
    • 1.3 查看pytorch官网版本建议
    • 1.4 安装本地的torch
    • 测试

概述

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

《从零构建大模型》书籍,运行环境配置
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 += 1703 if (704     self._dataset_kind == _DatasetKind.Iterable705     and self._IterableDataset_len_called is not None706     and self._num_yielded > self._IterableDataset_len_called707 ):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

相关文章:

  • Python-Flask
  • Learning Smooth Humanoid Locomotion through Lipschitz-Constrained Policies
  • Visio粘贴Word公式技巧
  • 动态工作流:目标结构来自外部数据集
  • MySQL 故障排查:从 `SHOW PROCESSLIST` 到死锁检测的完整流程
  • 博图 SCL 编程技巧:灵活实现上升沿与下降沿检测案例分享(上)
  • Context API 应用与局限性
  • STM32的DMA简介
  • Secs/Gem第九讲(基于secs4net项目的ChatGpt介绍)
  • DAX权威指南9:DAX 查询分析与优化1
  • SpringTask-02.Cron表达式
  • Simulink中sine Wave的使用方法
  • Java Math工具类
  • UML用例模型与用例图
  • 性能测试和自动化测试
  • 一文看懂Spring Boot集成智谱清言 AI最佳实践
  • 【Linux应用】Linux系统日志上报服务,以及thttpd的配置、发送函数
  • 手写RPC框架<一> SPI机制
  • Vue3 + TypeSrcipt 防抖、防止重复点击实例
  • python:Tkinter 开发邮件客户端,能编写邮件,发送邮件带附件
  • 套用别人产品图片做网站/企业网站seo多少钱
  • 公司网站做推广/互联网舆情
  • 计算机专业主要学什么课程/保定seo排名外包
  • 心悦dnf免做卡网站/seo推广专员招聘
  • 做旅游网站需要引进哪些技术人才/免费的网站软件下载
  • 魔客吧是什麼程序做的网站/推广app拿返佣的平台