Try   HackMD

Python Server Build Log

建置環境

1.更新python版本

sudo add-apt-repository ppa:deadsnakes/ppa sudo apt-get update sudo apt-get install python3.10 sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1 sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 2 sudo update-alternatives --config python3

2.清空資料

cd /usr/share/keyrings/ sudo rm -rf /usr/lib/nvidia/ sudo apt-get --purge remove "*cublas*" "*cuda*" "nsight*" "*nvidia*" sudo apt autoremove sudo apt autoclean sudo apt-get install build-essential linux-headers-$(uname -r)

2.安裝nvidia driver

sudo apt-get update #https://www.nvidia.com/Download/index.aspx?lang=en-us sudo bash NVIDIA-Linux-x86_64-550.67.run # sudo apt install nvidia-detect # sudo apt install nvidia-driver

3.安裝cuda

#https://developer.nvidia.com/cuda-downloads wget https://developer.download.nvidia.com/compute/cuda/11.7.1/local_installers/cuda-repo-debian11-11-7-local_11.7.1-515.65.01-1_amd64.deb sudo dpkg -i cuda-repo-debian11-11-7-local_11.7.1-515.65.01-1_amd64.deb sudo cp /var/cuda-repo-debian11-11-7-local/cuda-*-keyring.gpg /usr/share/keyrings/ sudo add-apt-repository contrib sudo apt-get update sudo apt-get -y install cuda nvidia-smi

4.安裝cudnn

#https://developer.nvidia.com/rdp/cudnn-download sudo tar -xzvf cudnn-11.3-linux-x64-v8.2.1.32.tgz sudo cp cuda/include/cudnn.h /usr/local/cuda/include sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64 sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*

5.安裝miniconda

$wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh $bash conda create -n myDL python=3.10 pip conda activate myDL

6.安裝PyTorch

conda install pytorch torchvision torchaudio cudatoolkit=11.7 -c pytorch -c conda-forge

7.其他指令

pip3 install -U d2l jupyter sudo apt install nvidia-driver firmware-misc-nonfree 檢驗版本 dpkg -l | grep -i nvidia

8.遠端Jupyter

https://stackoverflow.com/questions/42848130/why-i-cant-access-remote-jupyter-notebook-server jupyter notebook --no-browser & disown

10.故障排除

perl 語言錯誤 sudo apt-get update && sudo apt-get install locales sudo dpkg-reconfigure locales header搜尋 ls /usr/src/linux-6.1.0-headers sudo apt list linux-headers-$(uname -r) sudo apt install linux-headers-amd64 #sudo apt install kernel-headers-$(uname -r) sudo apt install build-essential sudo dpkg --configure -a sudo dkms install -m nvidia-current -v 535.104.05 sudo apt-get install multipath-tools

11.Stable Diffusion

mkdir StableDiff cd StableDiff # 程式框架部分 git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git # 下載權重檔 wget https://huggingface.co/runwayml/stable-diffusion-v1-5/resolve/main/v1-5-pruned-emaonly.ckpt mv v1-5-pruned-emaonly.ckpt stable-diffusion-webui/models/Stable-diffusion/ # 執行 ./webui.sh --xformers --share

參考資料

https://docs.conda.io/en/latest/miniconda.html https://developer.nvidia.com/cuda-downloads https://developer.nvidia.com/rdp/cudnn-download https://pytorch.org/get-started/locally/ https://docs.nvidia.com/deploy/cuda-compatibility/index.html https://www.datacamp.com/tutorial/how-to-run-stable-diffusion