c00cjz00
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
5
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# 大型語言模型LLMs課程教學 課程大綱 (五) ## [高階] 如何於國網超級電腦台灣杉二號使用多顆GPU微調語言模型 ## :memo: Where do I start? - 聯絡窗口 Email us : 2303117@narlabs.org.tw 王小姐 ### 課程說明 - 上課時間: 2024 3/12 星期一 9:00-10:30 - 上課方式: 視訊課程 (請參考信件說明) - 基本能力: 皆可 - 環境需求: Windows或Mac或Linux作業系統環境皆可 ### 課程內容: - 本堂課為示範教學為主, 下課後若學員有興趣, 會保留時間讓學員實地操作, 課程說明如下 ### :A: 簡報檔案: - [[高階課程 PDF]](https://drive.google.com/file/d/1bWrcc1u1kdRhBXpVK8Dwbdr5cC9mXxjK/view?usp=sharing) - [[程式碼 GITHUB]](https://github.com/c00cjz00/deepspeed_code.git) ### :B: 教學文件 - [初階課程] [建立基於RAG方案的專屬私有知識庫教學](https://hackmd.io/@whYPD8MBSHWRZV6y-ymFwQ/ryqUCfu6T) - [中階課程] [基於RAG方案的專屬私有知識庫服務網站建置](https://hackmd.io/@whYPD8MBSHWRZV6y-ymFwQ/Bk3TbayAp) - [高階課程] [如何於國網台灣杉二號使用多顆GPU微調語言模型](https://hackmd.io/@whYPD8MBSHWRZV6y-ymFwQ/SklMGVOaT) ### A. 台灣杉二號 (TAIWANIA 2)介紹 <font color="#f00">[請自己閱讀]</font> * 帳號註冊 - [註冊網址](https://iservice.nchc.org.tw/nchc_service/nchc_member_apply_0.php) - [文件說明](https://man.twcc.ai/@twccdocs/guide-twnia2-prerequisite-for-connection-zh) * 計算資源 - [文件說明](https://man.twcc.ai/@twccdocs/guide-twnia2-compute-capability-zh) * 儲存資源 - [文件說明](https://man.twcc.ai/@twccdocs/guide-twnia2-storage-capability-zh) * 登入與檔案傳輸節點 - [文件說明](https://man.twcc.ai/@twccdocs/guide-twnia2-login-and-data-transfer-node-zh) * 如何登入主機 - [文件說明](https://man.twcc.ai/@twccdocs/guide-twnia2-login-and-logout-zh) * 如何執行檔案傳輸 - [文件說明](https://man.twcc.ai/@twccdocs/doc-hfs-main-zh/%2F%40twccdocs%2Fhfs-overview-zh) * GPU Queue - [文件說明](https://man.twcc.ai/@twccdocs/guide-twnia2-queue-zh) * Slurm提交工作 - [文件說明](https://man.twcc.ai/@twccdocs/howto-twnia2-run-parallel-job-container-zh#Step-4-%E6%92%B0%E5%AF%AB-Slurm-Job-Script) ### :flag-tw: B. 台灣杉二號操作方法介紹 [現場示範] * 課程重點: 學習如何使用Singularity操作Docker Image - [教學文件](https://hackmd.io/@whYPD8MBSHWRZV6y-ymFwQ/H1r-_wbHT) - [範例影片](https://youtu.be/ogKFcLj0cSw) - [LLama-factory] https://github.com/c00cjz00/llama-factory-docker * 課程重點: 學習如何派送 HPC Slurm job - [教學文件](https://hackmd.io/@whYPD8MBSHWRZV6y-ymFwQ/B1wplDWST) - [範例影片](https://youtu.be/Xl1liXv14As) * 課程重點: 如何啟動 Jupyter Notebook操作介面 - [教學文件](https://hackmd.io/@whYPD8MBSHWRZV6y-ymFwQ/H1eKSV9jp6) - [範例影片](https://youtu.be/IALJNs-Ho-U6) * 課程重點: 如何建立 Singularity Image kernel in Jupyter Notebook - [教學文件](https://hackmd.io/@whYPD8MBSHWRZV6y-ymFwQ/HkNVrcsT6) - [範例影片](https://youtu.be/N7BwcdMYl2k) ### :flag-tw: C. 如何於國網超級電腦台灣杉二號使用多顆GPU微調語言模型 [現場示範] * GITHUB: https://github.com/c00cjz00/deepspeed_code.git * DEEPSPEED 介紹 - ZeRO主要包括三個等級的最佳化:ZeRO-1,ZeRO-2和ZeRO-3,每個等級都在前一個等級的基礎上進行了進一步的最佳化。 - [教學文件](https://hackmd.io/@whYPD8MBSHWRZV6y-ymFwQ/r1A88Lip6) * 模型所需要的硬體資源 - [詳細程式碼說明文件](https://hackmd.io/@whYPD8MBSHWRZV6y-ymFwQ/ByQAPIoTa) - 概略程式碼範例如下 ``` from transformers import AutoModel from deepspeed.runtime.zero.stage_1_and_2 import estimate_zero2_model_states_mem_needs_all_live model = AutoModel.from_pretrained("/work/u00cjz00/slurm_jobs/github/models/Llama-2-7b-chat-hf") estimate_zero2_model_states_mem_needs_all_live(model, num_gpus_per_node=1, num_nodes=1 ``` * 單顆GPU微調語言模型 - python - [詳細程式碼說明文件](https://hackmd.io/@whYPD8MBSHWRZV6y-ymFwQ/SylNV8opp) - 概略程式碼範例如下 ``` CUDA_VISIBLE_DEVICES=0 python src/train_bash.py ``` * 多顆GPU微調語言模型 - deepspeed (指定GPU --include localhost:0,1) - [詳細程式碼說明文件](https://hackmd.io/@whYPD8MBSHWRZV6y-ymFwQ/SJiIzHoap) - 概略程式碼範例如下 - zero0 (DDP), zero1 (優化器狀態分片), zero2 (梯度優化分片), zero3 (參數優化分片) ) ``` #參數設定 export GPUS_PER_NODE=2 #GPU數量 #執行工作 deepspeed \ --num_gpus ${GPUS_PER_NODE} \ src/train_bash.py \ --deepspeed ds_config.json ``` - 跨節點微調語言模型 (多台電腦) - torchrun + deepspeed - [詳細程式碼說明文件](https://hackmd.io/@whYPD8MBSHWRZV6y-ymFwQ/rytivEiaT) - 概略程式碼範例如下 - zero0 (DDP), zero1 (優化器狀態分片), zero2 (梯度優化分片), zero3 (參數優化分片) ) ``` #參數設定 export GPUS_PER_NODE=2 #GPU數量 export MASTER_ADDR=gpn3002 #Master HOSTNAME export MASTER_PORT=9001 #Master IP #執行工作 ##${SLURM_NNODES} ${SLURM_PROCID} 為系統自動給予參數 torchrun \ --nproc_per_node ${GPUS_PER_NODE} \ --master_addr ${MASTER_ADDR} \ --master_port ${MASTER_PORT} \ --nnodes ${SLURM_NNODES} \ --node_rank ${SLURM_PROCID} \ src/train_bash.py \ --deepspeed ds_config.json ``` ### :flag-tw: D. 資料處理 [現場示範] * 微調模型資料下載 - [詳細程式碼說明文件](https://hackmd.io/@whYPD8MBSHWRZV6y-ymFwQ/rJhJ3P26T) - 概略程式碼範例如下 ``` from datasets import load_dataset dataset = load_dataset("michaelwzhu/ChatMed_Consult_Dataset", split="train", streaming=True,encoding='utf-8') ``` * 繁體簡體中文互轉 - 概略程式碼範例如下 ``` import opencc #繁体简体互转 s2t or s2twp op_cc=opencc.OpenCC('s2twp') op_cc.convert("现在你是一名专业的中医医生,请用你的专业知识提供详尽而清晰的关于中医问题的回答。"), ```

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully