Anaconda配置pytorch-gpu虛擬環(huán)境的圖文教程
1、更新NVIDIA驅(qū)動
選對應(yīng)自己顯卡的驅(qū)動,(選studio版本,不要game版本)驅(qū)動鏈接

2、添加Anaconda清華鏡像
方法一:anaconda命令替換
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2 conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r 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
(Mark)換回默認源代碼:
conda config --remove-key channels
方法二:替換.condarc

show_channel_urls: true channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda default_channels: - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2 - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/ custom_channels: conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
3.創(chuàng)建虛擬環(huán)境
創(chuàng)建: conda create -n 環(huán)境名 python=X.X 開啟: activate 環(huán)境名 關(guān)閉: conda deactivate 刪除: conda remove -n 環(huán)境名 --all 添加包: conda install -n 環(huán)境名 包名 移除包: conda remove -n 環(huán)境名 包名
4. 安裝pytorch命令——對應(yīng)情況自選:命令代碼鏈接(pytorch官網(wǎng))
1.PIP安裝(推薦)
pip install torch===1.4.0 torchvision===0.5.0 -f https://download.pytorch.org/whl/torch_stable.html

這個速度比conda穩(wěn)定 卡住了按回車好像還可以救回來

2.conda安裝(不推薦 老是中斷)
conda install pytorch torchvision cudatoolkit=10.1 -c pytorch (要去掉-c pytorch 不然還是默認源) 最終輸入命令: conda install pytorch torchvision cudatoolkit=10.1

網(wǎng)絡(luò)在各處中斷 有時候48%又斷了

5.PIP安裝完之后測試
import torch
flag = torch.cuda.is_available()
print(flag)
ngpu= 1
# Decide which device we want to run on
device = torch.device("cuda:0" if (torch.cuda.is_available() and ngpu > 0) else "cpu")
print(device)
print(torch.cuda.get_device_name(0))
print(torch.rand(3,3).cuda())
結(jié)果:被conda命令折騰一下午,終于被pip命令解救了!

總結(jié)
到此這篇關(guān)于Anaconda配置pytorch-gpu虛擬環(huán)境步驟整理的文章就介紹到這了,更多相關(guān)Anaconda pytorch-gpu虛擬環(huán)境內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
python+selenium 點擊單選框-radio的實現(xiàn)方法
今天小編就為大家分享一篇python+selenium 點擊單選框-radio的實現(xiàn)方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-09-09
關(guān)于Keras模型可視化教程及關(guān)鍵問題的解決
今天小編就為大家分享一篇關(guān)于Keras模型可視化教程及關(guān)鍵問題的解決,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-01-01
Python中的JSON?Pickle?Shelve模塊特性與區(qū)別實例探究
在Python中,處理數(shù)據(jù)序列化和持久化是極其重要的,JSON、Pickle和Shelve是三種常用的模塊,它們提供了不同的方法來處理數(shù)據(jù)的序列化和持久化,本文將深入研究這三個模塊,探討它們的特性、用法以及各自的優(yōu)缺點2024-01-01
關(guān)于Python?Selenium自動化導(dǎo)出新版WOS(web?of?science)檢索結(jié)果的問題
這篇文章主要介紹了Python?Selenium自動化導(dǎo)出新版WOS(web?of?science)檢索結(jié)果,本代碼屬于半自動化導(dǎo)出,考慮到開發(fā)效率等因素,有兩處在首次導(dǎo)出時需要手動操作,具體實現(xiàn)過程跟隨小編一起看看吧2022-01-01

