python3.6 無法使用tensorflow gpu
環境名稱 test1
在控制台里進入環境
conda activate test1
使用python
python
查看gpu能否使用
print(tf.config.list_physical_devices('GPU'))
cuda版本查看 nvcc -V
10.2.89
判斷是否使用了gpu:
推薦的方法是檢查TensorFlow是否使用GPU如下:
tf.config.list_physical_devices('GPU')
輸出:【這個很重要】
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
以下內容還將返回您的GPU設備的名稱。
import tensorflow as tf
tf.test.gpu_device_name()
如果non-GPU
安裝了該軟件包的版本,則該函數還將返回False
。使用tf.test.is_built_with_cuda
來驗證是否TensorFlow是建立在CUDA的支持。
*注意*:tf.test.is_gpu_available
已棄用。請參考這里
警告:此功能已被棄用。它將在將來的版本中刪除。更新說明:改用tf.config.list_physical_devices('GPU')。
我最后終於搞出來了
用的就是CUDA_VISIBLE_DEVICES網上的方法