### 本地安裝 ## 安裝GPU驅動 ``` sudo apt-get install intel-opencl-icd ``` ## 安裝Git ``` sudo apt install git ``` ## 透過huggingface令牌下載llama-2-chat-7b (直接使用模型檔案,可略過) ``` pip install huggingface_hub python -c "from huggingface_hub.hf_api import HfFolder; HfFolder.save_token('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')" ``` ## 安裝python3虛擬環境 ``` sudo apt install python3.10-venv ``` ## 創建虛擬環境 ``` python3 -m venv openvino_llm_env ``` ## 進入虛擬環境 ``` source openvino_llm_env/bin/activate ``` ## 有問題才需要 ``` python3 -m pip install --upgrade pip ``` ## 僅安裝所需套件 ``` pip install -q --extra-index-url https://download.pytorch.org/whl/cpu git+https://github.com/huggingface/optimum-intel.git git+https://github.com/openvinotoolkit/nncf@release_v280 openvino-nightly gradio onnx einops transformers_stream_generator tiktoken transformers>=4.34.0 pip install ipywidgets ``` ## 官方預設安裝套件 ``` # openvino and its dependencies openvino-dev>=2023.2.0 openvino-telemetry>=2023.2.1 nncf==2.7.0 # deep learning frameworks tensorflow-macos>=2.5,<=2.14; sys_platform == 'darwin' and platform_machine == 'arm64' and python_version > "3.8" # macOS M1 and M2 tensorflow-macos>=2.5,<=2.12.0; sys_platform == 'darwin' and platform_machine == 'arm64' and python_version <= "3.8" # macOS M1 and M2 tensorflow>=2.5,<=2.14; sys_platform == 'darwin' and platform_machine != 'arm64' and python_version > "3.8" # macOS x86 tensorflow>=2.5,<=2.12.0; sys_platform == 'darwin' and platform_machine != 'arm64' and python_version <= "3.8" # macOS x86 tensorflow>=2.5,<=2.14; sys_platform != 'darwin' and python_version > "3.8" tensorflow>=2.5,<=2.12.0; sys_platform != 'darwin' and python_version <= "3.8" onnx>=1.11.0 --extra-index-url https://download.pytorch.org/whl/cpu torch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 transformers>=4.21.1 # jupyter jupyterlab ipywidgets ipykernel>=5.* ipython>=7.16.3 # others numpy>=1.21.0 opencv-python Pillow>=8.3.2 matplotlib>=3.4 scipy # The packages below are not directly required. They are dependencies of # other dependencies that are pinned to a specific version to avoid # compatibility issues or vulnerabilities scikit-image>=0.19.2 setuptools>=56.0.0 ``` ## Openvino_LLM虛擬環境自動建置.sh檔案 ``` #!/bin/bash #安裝並進入虛擬環境 python3 -m venv openvino_llm_env source openvino_llm_env/bin/activate # 安裝LLM所需套件 pip install -q --extra-index-url https://download.pytorch.org/whl/cpu git+https://github.com/huggingface/optimum-intel.git git+https://github.com/openvinotoolkit/nncf@release_v280 openvino-nightly gradio onnx einops transformers_stream_generator tiktoken transformers>=4.34.0 pip install ipywidgets #環境建立完成 ``` ## Openvino_LLM虛擬環境轉移方式 首先,我們需要理解問題的核心概念,即Python的虛擬環境(venv)。Python的虛擬環境是一種特殊的工具,可以在單一系統上建立多個獨立的Python環境。 再來,我們需要釐清問題的範疇。你想要將一個已經建立的Python虛擬環境移動到另一個目錄或者另一台電腦,並且希望在新的位置可以正常運行。 然後,我們需要了解Python虛擬環境的基本原理。Python的虛擬環境是在特定目錄下建立的,並且包含了自己的Python解釋器和軟體套件。虛擬環境的概念是為了解決軟體套件版本衝突和系統Python環境污染的問題。 基於上述的分析,我們可以得出以下解決方案: 首先,我們可以將虛擬環境所在的整個目錄複製或移動到新的位置。但這並不保證虛擬環境可以在新的位置正常運行,因為虛擬環境中的Python解釋器和軟體套件可能與原來的系統環境緊密相關。 一個更可靠的方法是在新的位置重新建立一個虛擬環境,並且安裝與原虛擬環境相同的軟體套件。這可以通過以下步驟完成: a. 在原虛擬環境中,使用以下命令將所有已安裝的軟體套件及其版本信息導出到一個requirements.txt文件中: `pip freeze > requirements.txt ` b. 在新的位置,使用以下命令建立一個新的虛擬環境: `python3 -m venv new_venv ` c. 啟動新的虛擬環境,並使用以下命令安裝requirements.txt文件中的軟體套件: ``` source new_venv/bin/activate pip install -r requirements.txt ``` 這樣,新的虛擬環境就應該可以正常運行,並且具有與原虛擬環境相同的軟體套件和版本。 請注意,如果你想要將虛擬環境移動到另一台電腦,則需要確保新電腦的操作系統、Python版本和其他系統環境與原電腦相同,否則可能會出現軟體套件安裝或運行的問題。 ### 用Openvino預建Docker安裝 Docker容器網路通訊教學 https://medium.com/cow-say/%E7%B5%A6%E6%96%B0%E6%89%8B%E7%9A%84-docker-%E7%B6%B2%E7%B5%A1%E5%85%A5%E9%96%80-272410c688ff (openvino_env) llm@llm-Default-string:~$ docker pull openvino/ubuntu22_runtime Using default tag: latest Error response from daemon: Get "https://registry-1.docker.io/v2/": tls: failed to verify certificate: x509: certificate signed by unknown authority #### docker build -t advigw/genai-intel:1.0.1 . ``` FROM openvino/ubuntu22_runtime:2023.3.0 USER root SHELL ["/bin/bash", "-c"] ENV HOME=/opt/intel/openvino_2023.3.0.13775 WORKDIR /opt/intel/openvino_2023.3.0.13775/ COPY *.* ./ COPY llama2.openvino/ llama2.openvino/ RUN apt-get update && \ apt-get install -y git && \ mkdir Model && \ pip install -r requirements.txt RUN python3 -c "from huggingface_hub.hf_api import HfFolder; HfFolder.save_token('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')" # RUN python3 254-llm-chatbot_loading.py CPU ./Model/llama-2-chat-7b ``` ### LLM運作參數 模型回應參數 貪心解碼(Greedy Decoding)  > Top-k 從 top-k 令牌的候選清單中進行取樣 - 0 表示停用並從所有令牌中取樣。   > Top-p(核採樣) 從累積機率超過 top_p 的最小可能標記集合中進行取樣。 設定為 1 以停用所有令牌並對其進行採樣。  > Temperature 溫度 更高的值會產生更多樣化的輸出  > Repetition Penalty 重複處罰 懲罰重複(降低字(包含標記符號)的重複出現),數值越高逞罰越重 — 1.0 停用。
×
Sign in
Email
Password
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