简体   繁体   中英

Can I run an AMD GPU and NVIDIA GPU on TensorFlow together?

Simple question: Can I run a dual GPU setup (as shown below) together in TensorFlow?

 1 AMD RX 480 and 1 NVIDIA 3070
 (ROCm 3.5.1 and CUDA 11)

I have attempted to do this by installing TensorFlow (2.4) and TensorFlow ROCm(2.4) as well as all the appropriate drivers. Unfortunately, TensorFlow only chooses one of them, depending on if TensorFlow ROCm is installed or not.

How can I fix this?

If it's not possible, what is the reason?

I don't really think you can do it. Tensorflow-rocm is a fork of Tensorflow. AMD has changed a lot to achieve compability with their GPUs. Therefore, as they are different packages, they can't be run altogether.

For AMD you have different package,Tensorflow require NVIDIA GPU. I have seen slowness as well in new NVIDIA GPU due to their new architecture. I would recommend you to use tf-nightly-gpu 2.5.0.dev20210126 which worked will with my RTX 3090.Also you can combine two 3090 but you can not combine two 3070.You can check NVIDIA documentation to read about SLI based graphics card. Also you can pair two 3090 with same brand which means 3090 from ASUS will not connect with RTX3090 founders edition.

While running code please ensure that tensorflow 2.5 is being called

To make execution faster you can also use allocate memory

Here since i am using RTX 3090 i am allocating 22GB for Tensorflow in your case you can change it to 8 GB

gpus = tf.config.experimental.list_physical_devices('GPU')
if gpus:
# Restrict TensorFlow to only allocate 22GB of memory on the first GPU
try:
tf.config.experimental.set_virtual_device_configuration(
    gpus[0],
[tf.config.experimental.VirtualDeviceConfiguration(memory_limit=22000)])
logical_gpus = tf.config.experimental.list_logical_devices('GPU')
print(len(gpus), "Physical GPUs,", len(logical_gpus), "Logical GPUs")
except RuntimeError as e:
# Virtual devices must be set before GPUs have been initialized
print(e)

memory_limit=8000

You can refer this documentation from tensorflow regarding GPU tweaks https://www.tensorflow.org/guide/gpu

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM