File size: 3,247 Bytes
83f9751 ca90249 83f9751 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
{
"cells": [
{
"cell_type": "markdown",
"id": "a25f3d36-e14f-4afd-8926-32748a42e1d1",
"metadata": {},
"source": [
"# 1 大模型运行环境简介\n",
"\n",
"\n",
"建议直接使用autodl,google colab等环境\n",
"\n",
"显卡:4090或者4090d\n",
"\n",
"内存:32G至少\n",
"\n",
"torch>=2.3.0\n",
"\n",
"具体可以参考:https://zhuanlan.zhihu.com/p/13479003076\n",
"\n",
"pip安装下面的基本transformer环境即可:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "cdeae2e5-2a39-4370-a5ec-47780f8fa76a",
"metadata": {},
"outputs": [],
"source": [
"!pip install transformers sentencepiece google protobuf deepspeed peft datasets "
]
},
{
"cell_type": "markdown",
"id": "a355a6e6-62fc-4b8f-ba35-b9c2f0ef48c8",
"metadata": {},
"source": [
"如要运行deepspeed,一般使用一机多卡即可,本教程一般不会涉及需要多机多卡的案例\n",
"\n",
"\n",
"推荐的gpu主机:\n",
"* autodl.com, 国内的 \n",
"* vast.ai, 海外的\n",
"\n",
"主流云平台gpu一般都特别贵,也不允许运行4090等显卡。"
]
},
{
"cell_type": "markdown",
"id": "4ee0674c-f001-453f-b0b0-7e3b25309040",
"metadata": {},
"source": [
"另外,建议把jupyter的注释打开,这样非常方便学习\n",
"\n",
"<img src=\"img/zhushi.png\" alt=\"示例图片\" width=\"500px\" />"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "444adc87-78c8-4209-8260-0c5c4a668ea0",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"\n",
"# 设置环境变量, autodl专区 其他idc\n",
"os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com'\n",
"\n",
"# 打印环境变量以确认设置成功\n",
"print(os.environ.get('HF_ENDPOINT'))"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "06d9dc67-dbd4-4d37-bbdb-ccf59c8fdbf9",
"metadata": {},
"outputs": [],
"source": [
"import subprocess\n",
"import os\n",
"# 设置环境变量, autodl一般区域\n",
"result = subprocess.run('bash -c \"source /etc/network_turbo && env | grep proxy\"', shell=True, capture_output=True, text=True)\n",
"output = result.stdout\n",
"for line in output.splitlines():\n",
" if '=' in line:\n",
" var, value = line.split('=', 1)\n",
" os.environ[var] = value"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2168e365-8254-4063-98bd-27afdbdb2f32",
"metadata": {},
"outputs": [],
"source": [
"#lfs 支持\n",
"!apt-get update\n",
"\n",
"!apt-get install git-lfs\n",
"\n",
"!git lfs install"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
|