介绍
介绍pytorch gpu搭建,目前ai领域的几个项目如yolov5、Stable Diffusion、Text Generation WebUI都需要使用python、torch、gpu,所以先搭好基础环境。
后面介绍yolov5、Stable Diffusion、Text Generation WebUI的安装过程
显卡选择
深度学习选择英伟达显卡,显存优先,比如8G的rtx3070就不如12G的rtx3060,显存大小对训练时间非常重要。
建议至少8G显存以上显卡,如rtx2060s、rtx3060,我个人购买的是rtx2060s,二手卡,价格1000;对于大模型项目显存依赖尤为重要,推荐rtx2080ti魔改22G显存版或tesla p40 24G显存。
其次对于个人电脑,内存、硬盘都要进行升级,比如内存推荐32G,硬盘500G 固态硬盘,CPU amd锐龙5 2600以上(intel类似)。
以上配置需要大机箱,且需要600w以上电源。
整套配置,价格在2500左右。
以上为基础条件。我的二手显卡购买经历
环境搭建
安装win10操作系统
安装anaconda
安装vscode
以上安装完成后,在命令行中输入“python”,确定python安装完成;
如果未出现python,则需要在系统环境变量中,将anaconda安装路径设置到’path’环境变量中安装pytorch gpu 版本,打开pytorch,选择cuda11.8,并保存”run
this commands”
- 安装显卡驱动
1 | 不需要安装显卡驱动,而是安装对应的cuda版本(里面带驱动) |
设置python,pip源,提升下载速度
1
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
安装pytorch
1 | pip install 'run this commands' (之前保存的) |
vscode 安装
最后
在vscode的终端中输入python,显示安装正常1
2
3
4
5
6
7
8
9
10PS D:\gitee.com\giteeDemo\removebg> python
Python 3.8.8 (default, Apr 13 2021, 15:08:03) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated. Libraries may fail to load. To activate this environment
please see https://conda.io/activation
Type "help", "copyright", "credits" or "license" for more information.
>>>