為 Ubuntu/Anaconda/pip 添加國內下載源


背景

正在看 tensorflow-lite 壓縮模型的部分,結果 tutorial 一上來就要卸舊版安裝 tf-nightly (新版?反正小白下就vans了)
然而好不容易才編譯好源碼舍不得刪。又建了一個 env 下載新版,速度慢的一比,掛了一上午還超時斷了。
我尋思着好像之前同學幫我配過國內的鏡像下載源,試了一下。

“一鍵使用TUNA”服務

按照清華開源軟件鏡像站上面說的步驟,進行如下操作就可以一鍵為Anaconda/PyPi/Ubuntu Linux等添加清華鏡像:

wget https://tuna.moe/oh-my-tuna/oh-my-tuna.py
# For yourself
python oh-my-tuna.py
# ...or for everyone!
sudo python oh-my-tuna.py --global
# Get some help
python oh-my-tuna.py -h

但實測時,僅發現 /etc/apt/sources.list 文件修改了,但 pip 下載時並沒有提速,暫未查明原因

手動修改 pip 下載源

Linux下,修改 ~/.pip/pip.conf (沒有就創建一個文件夾及文件。文件夾要加“.”,表示是隱藏文件夾),內容如下:

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=mirrors.aliyun.com

實測 pip 下載提速較為明顯

手動修改 conda 下載源

運行以下命令:

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes

實測提速明顯

參考資料:

  1. https://tuna.moe/oh-my-tuna/
  2. https://www.cnblogs.com/microman/p/6107879.html
  3. https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM