maris205--dnagpt2
131 行
3.2 KiB
Plaintext
131 行
3.2 KiB
Plaintext
{
|
|
"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
|
|
}
|