pytorch?cuda安裝報(bào)錯(cuò)的解決方法
2022.12.8在win+cuda11.8下安裝最新Pytorch GPU版時(shí)遇到包不兼容的問題,該文記錄安裝的整個(gè)流程
一、按照cuda版本在官網(wǎng)找命令
Pytorch官網(wǎng)命令如下
在win、cuda11.8下安裝GPU版Pytorch
conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia
分析該命令,-c后面為安裝包的源,-c pytorch表示使用官方源,可能出現(xiàn)速度慢等問題
二、換源
因此一般先將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 conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/win-64/
三、Bug描述
換源后去掉-c執(zhí)行命令如下
conda install pytorch torchvision torchaudio pytorch-cuda=11.7
報(bào)錯(cuò)包不兼容,出現(xiàn)沖突
Found conflicts! Looking for incompatible packages. This can take several minutes. Press CTRL-C to abort. Examining torchaudio: 43%|██████████████████████████████████████████████▎ | 3/7 [00:22<00:24, 6.10s/it]/failed UnsatisfiableError: The following specifications were found to be incompatible with the existing python installation in your environment: Specifications: - torchaudio -> python[version='2.7.*|3.5.*|3.6.*|>=2.7,<2.8.0a0|>=3.5,<3.6.0a0|3.4.*'] Your python: python=3.7 If python is on the left-most side of the chain, that's the version you've asked for. When python appears to the right, that indicates that the thing on the left is somehow not available for the python version you are constrained to. Note that conda will not change your python version to a different minor version unless you explicitly specify that. The following specifications were found to be incompatible with each other: Output in format: Requested package -> Available versions Package typing conflicts for: torchvision -> typing_extensions -> typing[version='>=3.7.4'] pytorch -> typing_extensions -> typing[version='>=3.7.4'] Package pytorch conflicts for: torchaudio -> pytorch[version='1.10.0|1.10.1|1.10.2|1.11.0|1.12.0|1.12.1|1.13.0|1.9.1|1.9.0|1.8.1|1.8.0|1.7.1|1.7.0|1.6.0'] torchvision -> pytorch[version='1.10.0|1.10.1|1.10.2|1.11.0|1.12.0|1.12.1|1.13.0|1.9.1|1.9.0|1.8.1|1.8.0|1.7.1|1.7.0|1.6.0|1.5.1|1.5.0|1.4.0|1.3.1|1.3.0|1.2.0|>=1.1.0|>=1.0.0|>=0.4'] Package pytorch-cuda conflicts for: pytorch -> pytorch-cuda[version='>=11.6,<11.7|>=11.7,<11.8'] torchaudio -> pytorch-cuda[version='11.6.*|11.7.*'] torchvision -> pytorch==1.13.0 -> pytorch-cuda[version='>=11.6,<11.7|>=11.7,<11.8'] torchaudio -> pytorch==1.13.0 -> pytorch-cuda[version='>=11.6,<11.7|>=11.7,<11.8'] torchvision -> pytorch-cuda[version='11.6.*|11.7.*'] Package requests conflicts for: python=3.7 -> pip -> requests torchvision -> request
四、解決方法
參考之前安裝成功的命令為
conda install pytorch torchvision torchaudio cudatoolkit=11.3
嘗試執(zhí)行
conda install pytorch torchvision torchaudio cudatoolkit=11.7
報(bào)錯(cuò)找不到包
PackagesNotFoundError: The following packages are not available from current channels: - cudatoolkit=11.7
推測(cè)原因可能是cuda11.7將cudatoolkit=11.7換為pytorch-cuda=11.7,而-c nvidia為pytorch-cuda的源。
執(zhí)行如下命令成功安裝
conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c nvidia
五、查看是否使用GPU
import torch
use_gpu = torch.cuda.is_available()
print(use_gpu)
print("devices count:", torch.cuda.device_count())
輸出
True
devices count: 1
總結(jié)
到此這篇關(guān)于pytorch cuda安裝報(bào)錯(cuò)解決的文章就介紹到這了,更多相關(guān)pytorch cuda安裝報(bào)錯(cuò)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
pandas 實(shí)現(xiàn)將NaN轉(zhuǎn)換為None
這篇文章主要介紹了pandas 實(shí)現(xiàn)將NaN轉(zhuǎn)換為None的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2021-05-05
Python?pyecharts案例超市4年數(shù)據(jù)可視化分析
這篇文章主要介紹了Python?pyecharts案例超市4年數(shù)據(jù)可視化分析,文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的小伙伴可以參考一下2022-08-08
python實(shí)現(xiàn)自動(dòng)搶課腳本的示例代碼
本文主要介紹了python實(shí)現(xiàn)自動(dòng)搶課腳本的示例代碼,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-12-12
python實(shí)現(xiàn)文件分片上傳的接口自動(dòng)化
這篇文章主要為大家詳細(xì)介紹了python實(shí)現(xiàn)文件分片上傳的接口自動(dòng)化,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-11-11
python通過apply使用元祖和列表調(diào)用函數(shù)實(shí)例
這篇文章主要介紹了python通過apply使用元祖和列表調(diào)用函數(shù),實(shí)例分析了python中apply方法的使用技巧,需要的朋友可以參考下2015-05-05
Python單元測(cè)試框架unittest簡明使用實(shí)例
這篇文章主要介紹了Python單元測(cè)試框架unittest簡明使用實(shí)例,本文講解了基本測(cè)試步驟、和測(cè)試實(shí)例,需要的朋友可以參考下2015-04-04

