2017-08-24 132 views
1

我試圖在python中區分用戶是否安裝了tensorflow-gpu或者僅僅是tensorflow(在CPU上,它缺乏GPU支持)。如何判斷我是否使用python安裝了tensorflow-gpu?

我不想運行一個微不足道的模型(與log_device_placement)必須弄清楚。

我試過使用tensorflow.__version__,但好像1.3.0-rc2是雙面打印的。

+1

無下面是你需要什麼? – MedAli

回答

0

運行pip freeze | grep tensorflow如果已安裝,您將在結果中看到tensorflow-gpu

如果你想以編程內蟒蛇檢查,這是一條路可走:

import pip 

l = next(str(i) for i in pip.get_installed_distributions() if 'tensorflow-gpu' in str(i)) 
print(l) 

,用於輸出我的情況:

tensorflow-gpu 0.12.0rc0 
1

是它通過PIP安裝?您可以檢查pip list,它會告訴之一:

tensorflow-gpu 

tensorflow 

二是CPU版本的答案

相關問題