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)庫之間有比較強(qiáng)的依賴關(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操作JSON實現(xiàn)網(wǎng)絡(luò)數(shù)據(jù)交換
這篇文章主要介紹了Python操作JSON實現(xiàn)網(wǎng)絡(luò)數(shù)據(jù)交換,JSON的全稱是 JavaScript Object Notation,是一種輕量級的數(shù)據(jù)交換格式,關(guān)于JSON的更多相關(guān)內(nèi)容感興趣的小伙伴可以參考一下2022-06-06python函數(shù)運(yùn)行內(nèi)存時間等性能檢測工具
這篇文章主要為大家介紹了python函數(shù)運(yùn)行內(nèi)存時間等性能檢測工具,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-05-05python多進(jìn)程(加入進(jìn)程池)操作常見案例
這篇文章主要介紹了python多進(jìn)程(加入進(jìn)程池)操作,結(jié)合常見案例形式分析了Python多進(jìn)程復(fù)制文件、加入進(jìn)程池及多進(jìn)程聊天等相關(guān)操作技巧,需要的朋友可以參考下2019-10-10