在我的機器上,我無法“pip install torch”——我得到了臭名昭著的“單一源外部管理錯誤”——我無法修復它并使用了 anaconda 的“conda install torch”。不過,檢查版本很容易 -torch.__version__但是如何查看它安裝在哪里 - 火炬的主目錄?假設如果我通過 pip 和 conda 安裝了兩個手電筒——如何知道項目中使用了哪個?import torch
print(torch__version__)
3 回答

慕蓋茨4494581
TA貢獻1850條經驗 獲得超11個贊
pip show torch在終端將為您提供所有必需的信息。
Name: torch
Version: 1.3.1
Summary: Tensors and Dynamic neural networks in Python with strong GPU acceleration
Home-page: https://pytorch.org/
Author: PyTorch Team
Author-email: [email protected]
License: BSD-3
Location: c:\programdata\anaconda3\lib\site-packages
Requires: numpy
Required-by: torchvision, torchtext, efficientunet-pytorch

四季花海
TA貢獻1811條經驗 獲得超5個贊
如果您已經安裝了PyTorch庫,請打開Google Colab,粘貼以下代碼并點擊運行按鈕:
import torch print(torch.__file__)
然后你會看到PyTorch的版本。
如果它不起作用,請訪問https://pytorch.org/get-started/locally/并按照有關如何安裝PyTorch 的說明進行操作,因為有時Python和PyTorch存在依賴關系問題。
添加回答
舉報
0/150
提交
取消