首頁  >  文章  >  系統教程  >  如何在沒有 root 權限和網路的情況下使用學校高效能 GPU 運行 stable diffusion

如何在沒有 root 權限和網路的情況下使用學校高效能 GPU 運行 stable diffusion

PHPz
PHPz原創
2024-07-19 00:30:09757瀏覽

如何在没有 root 权限和网络的情况下使用学校高性能 GPU 运行 stable diffusion

眾所周知,stablediffusion通常筆記本gpu是帶不動的。說是起碼須要4GB的GPUVRAM,但想要「正常速率(1)」使用根本不夠。想用雲端? cloudgpu租用有的價錢倒是可以接受,而且通常也不給存文件,再開個cloudstorage又是一筆開銷,且文件傳來傳去很麻煩。所以我(主要是我導師)為了省錢決定用中學的gpu。

(1)不談GPU機型速率大約參考:我的GPU2GB:一張圖3分鐘linux使用代理伺服器linux系統編程,友AGPU6GB:一張圖50s,友BGPU32GB:一張圖2S...

中學的GPU性能還是挺好的鳥哥的linux私房菜,而且沒有root權限啊!驅動程式也不是想更新才能給你更新的!更煩的是我連的機器連個網都還得代理(這是我下載sd過程中遇見的最麻煩的事)。

鑑於我還沒看到有誰用linuxconda繞開各類root權限問題+proxy問題裝過SD,以下我分享一下我的stablediffusionwebui安裝經驗。此經驗應同樣適用於須要linuxconda沒有權限和代理問題的同事。

*我的機器是LinuxCentOS(Redhat),NVidiaGPU

**我指的安裝sd是指安裝這個github上比較流行的AUTOMATIC1111的webgui:

***我在美國

****我不是學CS的如有不專業之處請拜謝,不喜勿噴,只分享經驗

安裝prerequisite:

(1)GPU夠大嗎(顯存起碼4GB)?不夠就別費力了,去huggingface上用免費乞丐版吧(真心)。

(2)請複查你機器的CUDAdrive版本(由於torch要用到)按照我的經驗10.幾的應當是用不了的,不管哪些torchcuda組合都不行...CUDA11及以上的兼容性都不錯,我裝的torch寫的適配cu117雖然我11.2也能用。 (前面安裝torch,CUDA版本相容性出問題的可以嘗試不同版本組合,在launch.py​​裡改下載路徑)

linux使用代理服务器_linux代理服务_linux代理服务器软件

1.首先用gitclone這個repo(git沒有的話裝git哈;git須要設定代理能夠聯網的請看步驟4)

<code class=" language-javascript"></code>

2.由於我沒有root權限下載各類包我須要使用conda(我的情況得用miniconda)。具體參考這裡其實就是自動下載anaconda/miniconda安裝包(wget一下哪些的)並安裝

3.下載好後創造你的conda環境(python3.10.6不能少哦)

<code class=" language-javascript"></code>

4.(沒有須要設定proxy聯網的伙伴可以省略此步驟)這時侯通常來說就可以開始下載了,而且須要設置網路代理的伙伴可能須要檢測如下幾個地方有沒有如下設置:

~/.bashrc(設定環境,負責通常意義上的聯網...)

<code class=" language-javascript"></code>

~/.condarc(負責condainstall之類的聯網...通常來說在這個位置)

linux代理服务_linux使用代理服务器_linux代理服务器软件

<code class=" language-javascript"></code>

git聯網

<code class=" language-javascript"></code>

還有就是下載各類包須要用到的pipinstall也須要聯網,她們在文件launch.py​​裡:

第一個須要改的地方在defrun_pip上面,129行左右

<code class=" language-javascript"></code>

第二個須要改的地方是defprepare_environment裡下載torch這兒,228行左右

<code class=" language-javascript"></code>

5.之後理論上就可以開始下載了,但只須要:

linux代理服务器软件_linux代理服务_linux使用代理服务器

<code class=" language-javascript"></code>

*這兒須要注意:用bashwenui.sh安裝雖然是用了python的virtualenviornment安裝同在目錄裡的launch.py​​。我之前認為既然在conda裡可能差異不大所以我直接運行了launch.py​​並且旁邊出現了許多奇奇怪怪的錯誤,致使我重新配了好多次環境,所以我強烈建議哪怕在conda裡也要用bashwebui.sh讓它在python的虛擬環境安裝不要直接執行launch.py​​!

但對我來說我的踩坑之路才剛剛開始。 。 。

以下分享幾個我的踩坑和workaround(僅經驗分享linux使用代理伺服器,我的解決方式毫無道理可言,而且最後能用!哈哈!)

1.難以下載gfpgan

"RuntimeError:Couldn'tinstallgfpgan."

我認為是網路問題,我的話恐怕是proxy的問題但鬼曉得哪不對(國外有這個問題的似乎可以參考這個,可能是[上網]的問題)

我的解決方式:先把launch.py​​裡的gfpgan下載程式碼註解掉

<code class=" language-javascript"></code>

linux使用代理服务器_linux代理服务器软件_linux代理服务

之後嘗試自動下載(須要代理的記得加--proxy=你的代理位址)

<code class=" language-javascript"></code>

假如還是不行那叫瞧瞧報錯,缺哪些補哪些,我嘗試了在conda裡重新裝了numpy,更新了pip,git,setuptools,cython...最後竟然能用了(我猜想git和numpy比較重要),儘管還是自動裝的但總比不能用好。

參考:

2.下載stabilityai的stablediffusion出錯

"RuntimeError:Couldn'tdetermineStableDiffusion'shash"wheninstalling

My solution: update git in conda (I used to use 1.8, and it will be fine if I update to 2.)

Reference:

At this point, there are no problems in downloading the model. What follows are some other simple bugs:

linux使用代理服务器_linux代理服务器软件_linux代理服务

3. Because the localhost of the machine I am using cannot be accessed, I need to generate external links

ValueError:Whenlocalhostisnotaccessible,ashareablelinkmustbecreated.Pleasesetshare=True.

linux使用代理服务器_linux代理服务器软件_linux代理服务

My solution: remove the comments and add --share in webui-user.sh, and run webui-user.sh again

<code class=" language-javascript"></code>

In this way, you can use Gradio’s external link to access webgui

4. The web interface can be opened and it is difficult to generate images, and the error SomethingwentwrongExpectingvalue: line1column1(char0)

My solution: I heard that it would be good to turn off the agent, but I can’t turn it off. . . So similar to the previous question, just add --no-gradio-queue and run webui-user.sh

<code class=" language-javascript"></code>

Reference:

You are welcome to exchange your experiences with stablediffusion and other generativeai!

以上是如何在沒有 root 權限和網路的情況下使用學校高效能 GPU 運行 stable diffusion的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn