返回 TensorFlow 是否可以訪問 GPU。 (已棄用)
用法
tf.test.is_gpu_available(
cuda_only=False, min_cuda_compute_capability=None
)
參數
-
cuda_only
將搜索限製在 CUDA GPU。 -
min_cuda_compute_capability
一個(主要,次要)對,指示所需的最低 CUDA 計算能力,如果沒有要求,則為 None。
返回
- 如果請求類型的 GPU 設備可用,則為真。
警告:此函數已棄用。它將在未來的版本中刪除。更新說明:改用tf.config.list_physical_devices('GPU')
。
警告:如果安裝了非 GPU 版本的包,該函數也將返回 False。使用 tf.test.is_built_with_cuda
來驗證 TensorFlow 是否是在 CUDA 支持下構建的。
例如,
>>> gpu_available = tf.test.is_gpu_available()
>>> is_cuda_gpu_available = tf.test.is_gpu_available(cuda_only=True)
>>> is_cuda_gpu_min_3 = tf.test.is_gpu_available(True, (3,0))
請注意,關鍵字 arg 名稱 "cuda_only" 具有誤導性(因為無論 TF 是使用 CUDA 支持還是 ROCm 支持構建的,例程都會在 GPU 設備可用時返回 true。但是這裏沒有更改,因為
++ 將名稱"cuda_only" 更改為更通用的名稱會破壞向後兼容性
++ 添加等效的"rocm_only" 將需要實現檢查構建類型。這反過來又需要對 CUDA 做同樣的事情,因此可能會破壞向後兼容性
++ 添加新的"cuda_or_rocm_only" 不會破壞向後兼容性,但需要大多數(如果不是全部)調用者更新調用以使用"cuda_or_rocm_only" 而不是"cuda_only"
相關用法
- Python tf.test.is_built_with_rocm用法及代碼示例
- Python tf.test.is_built_with_cuda用法及代碼示例
- Python tf.test.is_built_with_gpu_support用法及代碼示例
- Python tf.test.is_built_with_xla用法及代碼示例
- Python tf.test.TestCase.assertLogs用法及代碼示例
- Python tf.test.TestCase.assertItemsEqual用法及代碼示例
- Python tf.test.TestCase.assertWarns用法及代碼示例
- Python tf.test.TestCase.create_tempfile用法及代碼示例
- Python tf.test.TestCase.cached_session用法及代碼示例
- Python tf.test.TestCase.captureWritesToStream用法及代碼示例
- Python tf.test.create_local_cluster用法及代碼示例
- Python tf.test.TestCase.assertCountEqual用法及代碼示例
- Python tf.test.TestCase.assertRaises用法及代碼示例
- Python tf.test.compute_gradient用法及代碼示例
- Python tf.test.gpu_device_name用法及代碼示例
- Python tf.test.TestCase.session用法及代碼示例
- Python tf.test.TestCase.create_tempdir用法及代碼示例
- Python tf.tensor_scatter_nd_max用法及代碼示例
- Python tf.tensor_scatter_nd_sub用法及代碼示例
- Python tf.tensor_scatter_nd_update用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.test.is_gpu_available。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。