筆者使用Window11,Nvidia RTX 3080Ti顯卡。
Step1)安裝Python虛擬環境
#conda create -n unsloth python=3.11
#conda activate unsloth
Step2)安裝cuda12.6.3與cudnn9.8.0。
請參考Windows11升級Cuda12.6、Cudnn9.8與安裝yolov4
筆者使用RTX 3080Ti,系統path新增「C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.6\bin」與「C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.6\libnvpp」,系統CUDA_PATH修改為「C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.6」,如下圖。
此時執行nvcc -V會顯示12.6,表示cuda為12.6版本。
執行nvidia-smi會顯示驅動程式版本為12.6,目前cuda使用12.6。
Step3)安裝unsloth
(unsloth)#pip install "unsloth[windows] @ git+https://github.com/unslothai/unsloth.git"
Step4)安裝pytorch,到網站https://pytorch.org/get-started/locally/,查詢想要安裝的pytorch版本,筆者安裝pytorch的cuda12.6版本。
#pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126
Step2)安裝ipykernel與pypiwin32
(unsloth)#pip install ipykernel
(unsloth)#pip install pypiwin32
註冊虛擬環境到Jupyter notebook,取名為ml,使用Jupyter notebook新增
(unsloth)#python -m ipykernel install --user --name unsloth --display-name "unsloth"
列出目前所有Jupyter Notebook的虛擬環境
#jupyter kernelspec list
接著啟用Jupyter Notebook,點選「Anaconda3 -> Jupyter Notebook」
#pip install unsloth_zoo
出現錯誤TqdmWarning: IProgress not found. Please update jupyter and ipywidgets
#pip install --upgrade jupyter ipywidgets