lanbda_20080810 2024-03-24 16:55 采纳率: 60.9%
浏览 18

三显卡交火,RX580 8G两张P106,找不到合适的软硬件方案

需要跑AI绘画,计划三张显卡,一张RX580 8G,两张P106或104,需要三张显卡交火,共同运算,有没有合适的软件和硬件方案?用什么主板和电源。

  • 写回答

3条回答 默认 最新

  • 码农阿豪@新空间代码工作室 Java领域优质创作者 2024-03-24 16:56
    关注
    让阿豪来帮你解答,本回答参考chatgpt3.5编写提供,如果还有疑问可以评论或留言
    1. 软件方案 对于AI绘画的软件,可以选择支持多显卡交火的深度学习框架,如TensorFlow、PyTorch、Caffe等。这些框架均支持CUDA加速,可以充分利用显卡的计算能力。其中,CUDA是NVIDIA提供的并行计算平台和编程模型,只能在NVIDIA的显卡上使用。因此,如果选择PyTorch或Caffe作为AI绘画的框架,需要使用NVIDIA显卡。
    1. 硬件方案 由于计划使用三张显卡,需要选择能够支持三张显卡交火的主板。一些主流的主板,如华硕PRIME Z370-A、技嘉Z370 AORUS GAMING WIFI等,均支持多显卡的交火。 另外,需要考虑电源的功率需求。一般来说,三张显卡的功耗会达到600W以上,因此需要选择700W以上的电源。推荐选择可靠的品牌,如海盗船、安钛克等。
    2. 示例硬件配置 主板:华硕PRIME Z370-A 显卡:1张RX580 8G,2张NVIDIA P106或104 CPU:英特尔 i7-8700K 内存:32GB DDR4 SSD:512GB 电源:海盗船RM750x 代码示例:
    3. TensorFlow样例代码: import tensorflow as tf import numpy as np import time

    设定三个GPU

    gpus = [0, 1, 2]

    设定TensorFlow的默认计算设备和配置

    tf_config = tf.ConfigProto() tf_config.gpu_options.allow_growth = True tf_config.gpu_options.visible_device_list = ','.join([str(i) for i in gpus]) tf_config.allow_soft_placement = True

    创建一个TensorFlow会话

    sess = tf.Session(config=tf_config)

    尝试在三个GPU上创建三个变量,进行加法操作

    with tf.device('/gpu:0'): a1 = tf.Variable(tf.random.normal([2, 2])) b1 = tf.Variable(tf.random.normal([2, 2])) c1 = a1 + b1 with tf.device('/gpu:1'): a2 = tf.Variable(tf.random.normal([2, 2])) b2 = tf.Variable(tf.random.normal([2, 2])) c2 = a2 + b2 with tf.device('/gpu:2'): a3 = tf.Variable(tf.random.normal([2, 2])) b3 = tf.Variable(tf.random.normal([2, 2])) c3 = a3 + b3

    启动TensorFlow会话

    sess.run(tf.global_variables_initializer())

    分别输出三个计算结果,并计算运行时间

    start_time = time.time() print(sess.run(c1)) print("time for c1:", time.time()-start_time) start_time = time.time() print(sess.run(c2)) print("time for c2:", time.time()-start_time) start_time = time.time() print(sess.run(c3)) print("time for c3:", time.time()-start_time)

    关闭TensorFlow会话

    sess.close() 2. PyTorch样例代码: import torch import time

    设定三个GPU

    devices = [0, 1, 2]

    创建PyTorch张量,并移到设定好的GPU上

    a1 = torch.randn(2, 2).cuda(devices[0]) b1 = torch.randn(2, 2).cuda(devices[0]) a2 = torch.randn(2, 2).cuda(devices[1]) b2 = torch.randn(2, 2).cuda(devices[1]) a3 = torch.randn(2, 2).cuda(devices[2]) b3 = torch.randn(2, 2).cuda(devices[2])

    在设定好的三个GPU上进行张量加法操作

    start_time = time.time() with torch.cuda.device(devices[0]): c1 = a1 + b1 with torch.cuda.device(devices[1]): c2 = a2 + b2 with torch.cuda.device(devices[2]): c3 = a3 + b3 print(c1) print("time for c1:", time.time()-start_time) print(c2) print("time for c2:", time.time()-start_time) print(c3) print("time for c3:", time.time()-start_time)

    评论

报告相同问题?

问题事件

  • 创建了问题 3月24日

悬赏问题

  • ¥30 Pytorch深度学习服务器跑不通问题解决?
  • ¥15 部分客户订单定位有误的问题
  • ¥15 如何在maya程序中利用python编写领子和褶裥的模型的方法
  • ¥15 Linux权限管理相关操作(求解答)
  • ¥15 Bug traq 数据包 大概什么价
  • ¥15 在anaconda上pytorch和paddle paddle下载报错
  • ¥25 自动填写QQ腾讯文档收集表
  • ¥15 DbVisualizer Pro 12.0.7 sql commander光标错位 显示位置与实际不符
  • ¥15 android 打包报错
  • ¥15 关于stm32的问题