当前位置: 首页 > news >正文

山西做网站优势做网站接私活价格怎么算

山西做网站优势,做网站接私活价格怎么算,游戏网站域名,公众号怎么推广快又有效在linux系统上进行多gpu卡的深度学习任务 确保已安装最新的 TensorFlow GPU 版本。 import tensorflow as tf print("Num GPUs Available: ", len(tf.config.list_physical_devices(GPU)))1、确保你已经正确安装了tensorflow和相关的GPU驱动,这里可以通…

在linux系统上进行多gpu卡的深度学习任务

  • 确保已安装最新的 TensorFlow GPU 版本。
import tensorflow as tf
print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))
  • 1、确保你已经正确安装了tensorflow和相关的GPU驱动,这里可以通过在命令行输入nvidia-smi来查看:
    在这里插入图片描述
    如果成功显示了类似上述的GPU信息和驱动版本信息,则说明NVIDIA驱动已经正确安装。

2、导入必要的库,设置可见的gpu设备列表:

import tensorflow as tf
# 设置可见的GPU设备列表(例如,使用GPU 0、1、2和3)
gpu_devices = tf.config.experimental.list_physical_devices('GPU')
tf.config.experimental.set_visible_devices(gpu_devices, 'GPU')

在这里插入图片描述

  • 3、创建一个MirroredStrategy对象,该对象将自动复制模型和数据到每个可见的GPU卡上:
strategy = tf.distribute.MirroredStrategy()
  • 4、在strategy范围内创建和训练模型:
with strategy.scope():# 创建和编译模型model = create_model()model.compile(...)# 加载数据train_dataset = load_train_data()test_dataset = load_test_data()# 训练模型model.fit(train_dataset, validation_data=test_dataset, ...)

以上,在MirroredStrategy范围内创建的模型将自动复制并分布到每个可见的GPU卡上,每个卡都将处理一部分数据。

使用多个 GPU 的最佳做法是使用 tf.distribute.Strategy

以下给出一个官网的简单示例:

tf.debugging.set_log_device_placement(True)
gpus = tf.config.list_logical_devices('GPU')
strategy = tf.distribute.MirroredStrategy(gpus)
with strategy.scope():inputs = tf.keras.layers.Input(shape=(1,))predictions = tf.keras.layers.Dense(1)(inputs)model = tf.keras.models.Model(inputs=inputs, outputs=predictions)model.compile(loss='mse',optimizer=tf.keras.optimizers.SGD(learning_rate=0.2))

当然,也有手动的放置方法:

tf.debugging.set_log_device_placement(True)gpus = tf.config.list_logical_devices('GPU')
if gpus:# Replicate your computation on multiple GPUsc = []for gpu in gpus:with tf.device(gpu.name):a = tf.constant([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]])b = tf.constant([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]])c.append(tf.matmul(a, b))with tf.device('/CPU:0'):matmul_sum = tf.add_n(c)print(matmul_sum)

在tensorflow上使用gpu:https://www.tensorflow.org/guide/gpu?hl=zh-cn

http://www.yayakq.cn/news/891830/

相关文章:

  • 生产做网站表带的制造厂家php手机网站模板
  • 校友会网站建设的目的php驾校网站源码
  • 预告网站正在建设中网站开发定位
  • 学做网站需要懂什么软件cms程序
  • 网站横幅代码传媒公司取名字
  • 网站开发体会800字专业郑州网站建设
  • 站长之家源码之家做ppt的网站有哪些内容
  • 平湖做网站网站上怎么做动画广告
  • 凡科网站官网登录入口模板设计图
  • 西安网站优化效果上海十大装修公司品牌排行榜
  • 电影网站制作模版网站设计套用模板
  • 2012r2网站建设网站建设与管理行业发展情况
  • 淘宝联盟怎么建网站免费软件的定义
  • 网站建设设计师招募软件工程课程
  • 做设计在哪个网站找图片大全alexa排名软件
  • 自己做网站需要什么条件搭建个人网站赚钱
  • 龙陵网站建设门户网站 建设方案
  • 网站建设游戏丹阳论坛
  • 让网站降权黑龙江省关于城市建设政策网站
  • 大型租车门户网站商业版源码如何制作一个二维码
  • 收费报名网站怎么做seo整站如何优化
  • 您与此网站之间建立的连接不安全单页营销网站怎么做
  • 华为云怎么建网站微信商城在哪里点开
  • 集团网站建wordpress修复插件
  • 做公众号主页面的有哪些网站05网补充答案全部
  • 黄浦上海网站建设wordpress自动短网址插件
  • 国外网站在国内做镜像站点移动端企业网站
  • 小说网站做编辑器医疗网站项目策划
  • 医联体网站建设手机网站建设新闻
  • 柳州网站建设公广东购物网站建设