Jump to content

Does tensorflow use tensor cores?

Go to solution Solved by AnAverageName,

In short, as long as you're using TF 2.4+, yes. TF will automatically use the tensor cores on Ampere GPUs for supported supported FP32 operations using TensorFloat math mode.

 

You can check that by running:

import tensorflow as tf 
print(tf.config.experimental.tensor_float_32_execution_enabled())  

 

Ampere tensor cores also support FP16/BP16 operations so you may be able to get some more performance (or at least speed) when training by switching to mixed precision training where multiplications are done in 16-bit FP16 and accumulations in 32-bit FP32, halving the memory traffic while still using the Tensor Cores.

 

You can enable that with:

from tensorflow.keras import mixed_precision
mixed_precision.set_global_policy('mixed_float16')

 

End of the day some stuff will still run on CUDA though (any operations not supported by TF32 or with mixed precision kernels like FP32/FP64).

 

Hope this helps. Let me know if you have any questions!

In short, as long as you're using TF 2.4+, yes. TF will automatically use the tensor cores on Ampere GPUs for supported supported FP32 operations using TensorFloat math mode.

 

You can check that by running:

import tensorflow as tf 
print(tf.config.experimental.tensor_float_32_execution_enabled())  

 

Ampere tensor cores also support FP16/BP16 operations so you may be able to get some more performance (or at least speed) when training by switching to mixed precision training where multiplications are done in 16-bit FP16 and accumulations in 32-bit FP32, halving the memory traffic while still using the Tensor Cores.

 

You can enable that with:

from tensorflow.keras import mixed_precision
mixed_precision.set_global_policy('mixed_float16')

 

End of the day some stuff will still run on CUDA though (any operations not supported by TF32 or with mixed precision kernels like FP32/FP64).

 

Hope this helps. Let me know if you have any questions!

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×