PyTorch與PyTorch?Geometric的安裝過程
PyTorch與PyTorch Geometric的安裝
GPU與CUDA,Python,PyTorch的匹配
1. 查看Linux系統(tǒng)中GPU的基礎(chǔ)信息/NVIDIA Driver Version
nvidia-smi

nvidia-smi是nvidia 的系統(tǒng)管理界面 ,其中smi是System management interface的縮寫,它可以收集各種級別的信息,查看顯存使用情況。此外, 可以啟用和禁用 GPU 配置選項 (如 ECC 內(nèi)存功能)。
系統(tǒng)的Nvidia Driver Version決定著系統(tǒng)最高可以支持什么版本的cuda和cudatoolkit,Nvidia Driver是向下兼容的,詳情如下(見Table 3. CUDA Toolkit and Corresponding Driver Versions):

2. 查看當(dāng)前CUDA版本:
cat /usr/local/cuda/version.txt

我自己的環(huán)境最高可支持10.1版本的cuda和cudatoolkit,當(dāng)前是10.0,版本向下兼容,并無什么問題。
3. CUDA Toolkit匹配PyTorch
CUDA Toolkit 和PyTorch的對應(yīng)關(guān)系(見官網(wǎng))

! 注意事項:服務(wù)器本身的CUDA版本與虛擬環(huán)境中安裝的cudatoolkit包沒有太大關(guān)系,一般安裝pytorch時需要考慮的cuda版本指的應(yīng)該是虛擬環(huán)境中安裝的cudatoolkit包的版本
由于我需要用到v1.6.0的Pytorch,因此自己在虛擬環(huán)境里安裝v10.1的CUDA Toolkit,系統(tǒng)GPU可接受最高版本v10.1。
torch與torchvision對應(yīng)關(guān)系如下(詳情見PyTorch / Vision):

因此,我需要安裝的如下:
CUDA Toolkit == 10.1
Python == 3.7
PyTorch == 1.6
安裝PyTorch
pip install torch==1.6.0+cu101 torchvision==0.7.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html
安裝完成后可通過以下命令檢查torch版本及對應(yīng)的CUDA版本:
python -c "import torch; print(torch.__version__)" python -c "import torch; print(torch.version.cuda)"
再通過以下命令查看GPU是否可用:
python >>> import torch >>> torch.cuda.is_available() # GPU是否可用 >>> torch.cuda.device_count() # GPU數(shù)量 >>> torch.cuda.current_device() # 當(dāng)前GPU >>> exit()
注意,GPU devices從0開始編號。
安裝PyTorch Geometric
1. 快速安裝
根據(jù)官網(wǎng),如果PyTorch版本≥1.8.0,可以快速下載:
2. 自定義安裝
自定義下載需要根據(jù)當(dāng)前的PyTorch版本和CUDA版本下載相關(guān)的依賴,下載命令如下:
pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-${TORCH}+${CUDA}.html
pip install torch-sparse -f https://pytorch-geometric.com/whl/torch-${TORCH}+${CUDA}.html
pip install torch-geometric其中, ${TORCH}替換為當(dāng)前環(huán)境下的PyTorch版本,目前支持1.4.0、1.5.0、1.6.0、1.7.0、1.7.1、1.8.0、1.8.1、和1.9.0; ${CUDA}替換為指定的CUDA版本,目前支持cpu、cu92、cu101、cu102、cu110和cu111。
例如對于PyTorch 1.6.0和CUDA 10.1:
pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.6.0+cu101.html pip install torch-sparse -f https://pytorch-geometric.com/whl/torch-1.6.0+cu101.html pip install torch-geometric
3. 版本依賴
使用自定義安裝時,依然可能會出現(xiàn)安裝失敗的問題,因為pytorch_geometric幾個相關(guān)庫之間有比較強的依賴關(guān)系,建議是在自定義安裝的基礎(chǔ)上指定對應(yīng)庫的版本,例如對于pytorch1.6.0和cuda10.1:
pip install torch-scatter==2.0.5 -f https://pytorch-geometric.com/whl/torch-1.6.0+cu101.html pip install torch-cluster==1.5.8 -f https://pytorch-geometric.com/whl/torch-1.6.0+cu101.html pip install torch-sparse==0.6.7 -f https://pytorch-geometric.com/whl/torch-1.6.0+cu101.html pip install torch-spline-conv==1.2.0 -f https://pytorch-geometric.com/whl/torch-1.6.0+cu101.html pip install torch-geometric==1.6.1 -f https://pytorch-geometric.com/whl/torch-1.6.0+cu101.html
到此這篇關(guān)于PyTorch與PyTorch Geometric的安裝的文章就介紹到這了,更多相關(guān)PyTorch Geometric安裝內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
python?pandas創(chuàng)建多層索引MultiIndex的6種方式
這篇文章主要為大家介紹了python?pandas創(chuàng)建多層索引MultiIndex的6種方式,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2022-07-07
對pandas將dataframe中某列按照條件賦值的實例講解
今天小編就為大家分享一篇對pandas將dataframe中某列按照條件賦值的實例講解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-11-11
python內(nèi)置函數(shù)sorted()用法深入分析
這篇文章主要介紹了python內(nèi)置函數(shù)sorted()用法,結(jié)合實例形式較為深入的分析了Python內(nèi)置函數(shù)sorted()功能、使用方法及相關(guān)操作注意事項,需要的朋友可以參考下2019-10-10
python中pymysql的executemany使用方式
這篇文章主要介紹了python中pymysql的executemany使用方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-01-01
pip安裝py_zipkin時提示的SSL問題對應(yīng)
今天小編就為大家分享一篇關(guān)于pip安裝py_zipkin時提示的SSL問題對應(yīng),小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧2018-12-12

