一、安裝conda
安裝conda的方法請參考博主的另一篇文章,里面詳細(xì)的講解了安裝的方法。文章地址如下:
在Linux系統(tǒng)配置yolov5環(huán)境(tensorflow-gpu、cuda、cudnn)_安瑜丶的博客-CSDN博客
二、配置pytorch環(huán)境
1.創(chuàng)建虛擬環(huán)境
conda create –n pytorch?python=3.8
2.進(jìn)入虛擬環(huán)境,安裝pytorch
conda activate pytorch
conda install pytorch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2 cudatoolkit=11.0 -c pytorch
3.驗(yàn)證是否安裝好
import?torch
import?torchvision
print(torch.cuda.is_available())
a?=?torch.Tensor(5,?3)
a?=?a.cuda()
print(a)
print(torch.__version__)
結(jié)果如圖所示,即已成功安裝。
4.安裝需要的相關(guān)庫
所需要的庫如下:
scipy==1.7.1
numpy==1.21.2
matplotlib==3.4.3
opencv_python==4.5.3.56
torch==1.7.1
torchvision==0.8.2
tqdm==4.62.2
Pillow==8.3.2
h5py==2.10.0
tensorboard
scikit-learn
Cython
如果想更快速的安裝可以在一個文件夾里創(chuàng)建一個requirements.txt文件,復(fù)制上述內(nèi)容到txt文件中。并執(zhí)行如下命令,便可以一起安裝(xx為文件路徑):
pip install -r xx/requirements.txt文章來源:http://www.zghlxwxcb.cn/news/detail-614421.html
三、總結(jié)
以上就是博主自己安裝的方法了,希望對大家有所幫助,如果有什么問題,請?jiān)谠u論區(qū)留言,博主會積極為大家解答。文章來源地址http://www.zghlxwxcb.cn/news/detail-614421.html
到了這里,關(guān)于Linux系統(tǒng)下的pytorch環(huán)境配置的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!