最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

pytorch+torchvision+python版本對應(yīng)及環(huán)境安裝

 更新時(shí)間:2025年03月16日 10:31:56   作者:半畝花海  
本文主要介紹了pytorch+torchvision+python版本對應(yīng)及環(huán)境安裝,安裝過程中需要注意Numpy版本的降級,以確保與PyTorch兼容,具有一定的參考價(jià)值,感興趣的可以了解一下

一、版本對應(yīng)

下表來自 pytorch 的 github 官方文檔:pytorch/vision: Datasets, Transforms and Models specific to Computer Vision

其中,命令中 "-c pytorch" 表示官方源,自己換源可以去掉。

torch 版本torchvision 版本torchaudio 版本支持的 Python 版本(示例)Cuda 版本
2.5.10.20.12.5.1>=3.9, <3.13(3.12)[9/10/11/12]12.4/12.1/11.8
2.5.00.20.02.5.0>=3.9, <3.13(3.12)12.4/12.1/11.8
2.4.10.19.12.4.1>=3.8, <3.13(3.12)[8/9/10/11/12]12.4/12.1/11.8
2.4.00.19.02.4.0>=3.8, <3.13(3.12)12.4/12.1/11.8
2.3.10.18.12.3.1>=3.8, <3.13(3.12)8/9/10/11/1212.1/11.8
2.3.00.18.02.3.0>=3.8, <3.13(3.12)12.1/11.8
2.2.20.17.22.2.2>=3.8, <3.12 [8/9/10/11]12.1/11.8
2.2.10.17.12.2.1>=3.8, <3.1212.1/11.8
2.2.00.17.02.2.0>=3.8, <3.1212.1/11.8
2.1.20.16.22.1.2>=3.8, <3.12(3.10)8/9/10/1112.1/11.8
2.1.10.16.12.1.1>=3.8, <3.12(3.10)12.1/11.8
2.1.00.16.02.1.0>=3.8, <3.12(3.10)12.1/11.8
2.0.00.15.02.0.0>=3.8, <3.12(3.8)[8/9/10/11]11.8/11.7
1.13.10.14.10.13.1>=3.7.2, <=3.10(3.8)[7/8/9/10]11.7/11.6
1.13.00.14.00.13.0>=3.7.2, <=3.10(3.8)11.7/11.6
1.12.10.13.11.12.1>=3.7, <=3.10(3.8)[7/8/9/10]11.6/11.3/10.2
1.12.00.13.01.12.0>=3.7, <=3.10(3.8)11.6/11.3/10.2
1.11.00.12.01.11.0>=3.7, <=3.10(3.8)11.3/10.2
1.10.10.11.20.10.1>=3.6, <=3.9(3.8)[6/7/8/9]11.3/10.2
1.10.00.11.00.10.0>=3.6, <=3.9(3.8)11.3/10.2
1.9.10.10.10.9.1>=3.6, <=3.9(3.8)[6/7/8/9]11.1/10.2
1.9.00.10.00.9.0>=3.6, <=3.9(3.8)11.1/10.2
1.8.10.9.10.8.1>=3.6, <=3.9(3.8)[6/7/8/9]11.1/10.2
1.8.00.9.00.8.0>=3.6, <=3.9(3.8)11.1/10.2
1.7.10.8.20.7.2>=3.6(3.6)11.0/10.2/10.1
1.7.00.8.00.7.0>=3.6(3.6)11.0/10.2/10.1

二、安裝命令(pip)

1. 版本

(1)v2.5.1 ~ v2.0.0

# v2.5.1
# CUDA 12.4
pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cu124 -i https://pypi.tuna.tsinghua.edu.cn/simple/
# CPU only
pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cpu -i https://pypi.tuna.tsinghua.edu.cn/simple/

(2)v1.13.1 ~ v1.11.0

# v1.13.1
# CUDA 11.7
pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 torchaudio==0.13.1 --extra-index-url https://download.pytorch.org/whl/cu117 -i https://pypi.tuna.tsinghua.edu.cn/simple/
# CPU only
pip install torch==1.13.1+cpu torchvision==0.14.1+cpu torchaudio==0.13.1 --extra-index-url https://download.pytorch.org/whl/cpu -i https://pypi.tuna.tsinghua.edu.cn/simple/

(3)v1.10.1 ~ v1.7.0

# v1.10.1
# CUDA 10.2
pip install torch==1.10.1+cu102 torchvision==0.11.2+cu102 torchaudio==0.10.1 -f https://download.pytorch.org/whl/cu102/torch_stable.html -i https://pypi.tuna.tsinghua.edu.cn/simple/
# CPU only
pip install torch==1.10.1+cpu torchvision==0.11.2+cpu torchaudio==0.10.1 -f https://download.pytorch.org/whl/cpu/torch_stable.html -i https://pypi.tuna.tsinghua.edu.cn/simple/

2. 安裝全過程

(1)選擇版本

torch 版本torchvision 版本torchaudio 版本支持的 Python 版本(示例)Cuda 版本
2.1.00.16.02.1.0>=3.8, <3.12(3.10)12.1/11.8

這里選擇的框架和環(huán)境如下:torch2.1.0 | torchvision0.16.0 | torchaudio2.1.0 | python3.10 | Cuda12.1,若需要將創(chuàng)建的虛擬環(huán)境添加到 Jupyter Lab / Jupyter Notebook 中使用,則需要第 3-6 步,否則不用。

打開 WIN + R,輸入 “cmd”,進(jìn)入命令行窗口,其他步驟如下:

# 1. Anaconda 創(chuàng)建虛擬環(huán)境
conda create -n torch python=3.10
# 2. 激活并進(jìn)入虛擬環(huán)境
activate torch
# 3. 安裝 ipykernel 
pip install ipykernel -i https://pypi.tuna.tsinghua.edu.cn/simple/
# 4. 安裝ipykernel,將虛擬環(huán)境加入 jupyter 內(nèi)核中
python -m ipykernel install --name torch --display-name torch
# 5. 檢查新虛擬環(huán)境是否成功加入內(nèi)核
jupyter kernelspec list
# 6. 從指定文件夾里進(jìn)入 jupyter
jupyter lab
# 7. 安裝 torch 等軟件包
pip install torch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 --index-url https://download.pytorch.org/whl/cpu -i https://pypi.tuna.tsinghua.edu.cn/simple/

注意:此時(shí),因?yàn)?Numpy 2.x 等其他的相關(guān)庫 與 Pytorch 2.1.0 的不兼容(以 Numpy 庫為例),所以需要將 numpy 庫的版本降級至1.x.x(如 1.24.x 或 1.23.x 版本)才能與 Pytorch 2.1.0 是兼容,從而適配以上版本。具體示例步驟如下:

  • pip uninstall numpy
  • pip install numpy==1.24.3

注意:若在安裝途中不小心關(guān)閉了命令窗或者發(fā)現(xiàn)沒有關(guān)閉梯子,可先將 Anaconda 的環(huán)境中刪除未完全安裝好的虛擬環(huán)境(如在  E:\Anaconda\envs\torch 此目錄下),即可重新進(jìn)行上述安裝步驟。

(2)安裝結(jié)果

3. 命令相關(guān)解釋

(1)-i / --index-url

第一條命令:pip install torch==2.5.1 torchvision==0.20.1 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cpu -i https://pypi.tuna.tsinghua.edu.cn/simple/

  • --index-url https://download.pytorch.org/whl/cpu:這個(gè)參數(shù)指定了主要的包索引源 URL,即使用 https://download.pytorch.org/whl/cpu 作為 PyTorch 相關(guān)庫的包來源。這是 PyTorch 官方的 CPU 版本的二進(jìn)制文件源。
  • -i https://pypi.tuna.tsinghua.edu.cn/simple/:這個(gè)參數(shù)指定了鏡像源,指向清華大學(xué)的 PyPI 鏡像源,以加速從 PyPI 安裝包的速度。
  • 當(dāng)同時(shí)使用 --index-url 和 -i 時(shí),--index-url 會設(shè)置 主索引源(比如官方 PyTorch 或其他自定義源),而 -i 用來指定 一個(gè)額外的索引源 / 備用源(如清華鏡像)。此時(shí),pip 會先從 --index-url 指定的源查找包,如果找不到,才會去 -i 指定的額外源查找。

(2)--extra-index-url

第二條命令:pip install torch==1.13.1+cpu torchvision==0.14.1+cpu torchaudio==0.13.1 --extra-index-url https://download.pytorch.org/whl/cpu -i https://pypi.tuna.tsinghua.edu.cn/simple/

  • --extra-index-url https://download.pytorch.org/whl/cpu:這個(gè)參數(shù)指定了額外的索引源 URL。與 --index-url 不同,--extra-index-url 只是添加額外的索引源,而不是替換原有源。此處指定的是 PyTorch 官方 CPU 版本的源。
  • -i https://pypi.tuna.tsinghua.edu.cn/simple/:同樣指定了 PyPI 鏡像源,指向清華大學(xué)的 PyPI 鏡像源。

(3)-f / --find-links

第三條命令:pip install torch==1.10.1+cpu torchvision==0.11.2+cpu torchaudio==0.10.1 -f https://download.pytorch.org/whl/cpu/torch_stable.html -i https://pypi.tuna.tsinghua.edu.cn/simple/

  • -f https://download.pytorch.org/whl/cpu/torch_stable.html:這個(gè)參數(shù)用于指定一個(gè)包的 URL 文件列表(一個(gè) .html 或 .xml 文件),其中列出了穩(wěn)定版本的 PyTorch 安裝包。
  • -i https://pypi.tuna.tsinghua.edu.cn/simple/:同樣指定了 PyPI 鏡像源,指向清華大學(xué)的 PyPI 鏡像源。

參考文章

[1] pytorch,torchvision與python版本對應(yīng)關(guān)系及安裝命令_pytorch python版本-CSDN博客

[2] Python安裝torch(含torch和torchvision對應(yīng)版本)-CSDN博客

到此這篇關(guān)于pytorch+torchvision+python版本對應(yīng)及環(huán)境安裝的文章就介紹到這了,更多相關(guān)pytorch torchvision python版本對應(yīng)內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論

武强县| 兴城市| 喀喇沁旗| 宜兴市| 英超| 吴桥县| 西贡区| 沙洋县| 芜湖市| 安阳市| 阿拉善左旗| 武穴市| 泽普县| 浮梁县| 三江| 论坛| 阿巴嘎旗| 宜君县| 新昌县| 周口市| 罗田县| 万载县| 吉安县| 天峨县| 临武县| 浠水县| 宁明县| 晋中市| 香格里拉县| 禹州市| 普洱| 泰来县| 金昌市| 府谷县| 绥化市| 融水| 宜春市| 新泰市| 十堰市| 固阳县| 平乡县|