- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在安装并启用了 GPU 的机器上使用了 this script to train a model & predict,它似乎在预测阶段只使用了 CPU。
我在 .predict()
部分看到的设备放置日志如下:
2020-09-01 06:08:19.085400: I tensorflow/core/common_runtime/eager/execute.cc:573] Executing op RangeDataset in device /job:localhost/replica:0/task:0/device:CPU:0
2020-09-01 06:08:19.085617: I tensorflow/core/common_runtime/eager/execute.cc:573] Executing op RepeatDataset in device /job:localhost/replica:0/task:0/device:CPU:0
2020-09-01 06:08:19.089558: I tensorflow/core/common_runtime/eager/execute.cc:573] Executing op MapDataset in device /job:localhost/replica:0/task:0/device:CPU:0
2020-09-01 06:08:19.090003: I tensorflow/core/common_runtime/eager/execute.cc:573] Executing op PrefetchDataset in device /job:localhost/replica:0/task:0/device:CPU:0
2020-09-01 06:08:19.097064: I tensorflow/core/common_runtime/eager/execute.cc:573] Executing op FlatMapDataset in device /job:localhost/replica:0/task:0/device:CPU:0
2020-09-01 06:08:19.097647: I tensorflow/core/common_runtime/eager/execute.cc:573] Executing op TensorDataset in device /job:localhost/replica:0/task:0/device:CPU:0
2020-09-01 06:08:19.097802: I tensorflow/core/common_runtime/eager/execute.cc:573] Executing op RepeatDataset in device /job:localhost/replica:0/task:0/device:CPU:0
2020-09-01 06:08:19.097957: I tensorflow/core/common_runtime/eager/execute.cc:573] Executing op ZipDataset in device /job:localhost/replica:0/task:0/device:CPU:0
2020-09-01 06:08:19.101284: I tensorflow/core/common_runtime/eager/execute.cc:573] Executing op ParallelMapDataset in device /job:localhost/replica:0/task:0/device:CPU:0
2020-09-01 06:08:19.101865: I tensorflow/core/common_runtime/eager/execute.cc:573] Executing op ModelDataset in device /job:localhost/replica:0/task:0/device:CPU:0
即使当我运行时:
print(tf.config.experimental.list_physical_devices('GPU'))
我收到:
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU'), PhysicalDevice(name='/physical_device:GPU:1', device_type='GPU'), PhysicalDevice(name='/physical_device:GPU:2', device_type='GPU')]
我使用的代码
can be found here 。
full output logs can be seen here 。
3.7.7
tensorflow :
2.1.0
GPU:
Nvidia Tesla V100-PCIE-16GB
CPU:
Intel Xeon Gold 5218 CPU @ 2.30GHz
内存:
394851272 KB
操作系统:
Linux
最佳答案
听起来您需要根据文档使用 Distributed Strategy
。您的代码将变成如下所示:
tf.debugging.set_log_device_placement(True)
strategy = tf.distribute.MirroredStrategy()
with strategy.scope():
model = keras.Sequential(
[
keras.layers.Flatten(input_shape=(28, 28)),
keras.layers.Dense(128, activation='relu'),
keras.layers.Dense(10)
]
)
model.compile(
optimizer='adam',
loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),
metrics=['accuracy']
)
model.fit(train_images, train_labels, epochs=10)
test_loss, test_acc = model.evaluate(test_images, test_labels, verbose=2)
probability_model = tf.keras.Sequential(
[model, tf.keras.layers.Softmax()]
)
probability_model.predict(test_images)
根据文档,
使用多个 GPU 的最佳做法是使用 tf.distribute.Strategy 。
关于python - .predict() 仅在 CPU 上运行,即使 GPU 可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63682454/
这里有没有人在使用Google Prediction API?为了什么?它“起作用”了吗? 最佳答案 如果您正在寻找实际案例,请查看此案例automatically assigns priority
无论如何,学习R ..: 在简单的x和y回归中,我输入: predict(data1.lm, interval="prediction") 和 predict(data1.lm, interval="
我创建并调整了多个模型,但在尝试预测它们时遇到了问题。我首先按如下方式运行代码来调整 LDA 模型。 library(MASS) library(caret) library(randomForest
问题 我在 R 中训练了一个线性回归来预测 this.target来自 city , 数据框中的变量 data .这个训练是在数据的一个子集上完成的,它由 train.index 指定。 . mode
我正在检查 tf-serving 示例,发现 inception_client.py mnist_client.py 时使用 result = Stub.Predict(request, 10.0)使
我已在 Google ML Engine 中上传了该模型的一个版本,其中包含 saved_model.pb 和一个变量文件夹。当我尝试执行命令时: gcloud ml-engine local pre
请先在我们的 GitHub 存储库中搜索类似问题。如果您找不到类似的示例,您可以使用以下模板: 系统(请填写以下信息): - 操作系统:Ubuntu 18.04 - Python版本:3.6.7 -
我正在研究一个简单的 LL(1) 解析器生成器,我遇到了给定某些输入语法的 PREDICT/PREDICT 冲突问题。例如,给定如下输入语法: E → E + E | P P → 1 我可以
我正在对具有多个预测变量的线性模型的预测值求和,如下例所示,并希望计算该总和的组合方差、标准误差和可能的置信区间。 lm.tree <- lm(Volume ~ poly(Girth,2), data
我是 R 和统计学的新手。所以这个问题可能有点愚蠢,但我想知道 R 中的 predict() 和 predict.lm() 之间是否有任何区别?我认为它们是相同的,但如果它们是相同的,为什么会有两个不
我尝试了针对this question而发布的答案,但是错误没有改变。我试图以相同的方式预处理训练集和测试集。它们来自两个不同的文件,我不确定我的老师是否会把我混合在一起,所以在拆分它们之前进行预处理
使用随机森林包:- #install.packages("randomForest") library(randomForest) 我使用在线代码在我的系统上运行随机森林。我得到了一个具有混淆矩阵和准
我有一个模型 (fit),基于上个月之前的历史信息。现在我想使用我的模型来预测当月的情况。当我尝试调用以下代码时: predicted fit$modelInfo$label [1]“随机森林” 因此
我正在尝试找出应用于列表的操作。我有列表/数组名称预测并执行以下指令集。 predictions[predictions >> a = np.array([1,2,3,4,5]) #define ar
此 R 代码引发警告 # Fit regression model to each cluster y fit$rank 检查 另一种方法是拥有比可用变量更多的参数: fit2 <- lm(y ~
我不是 R 专家。我正在尝试计算多项式模型生成的偏差: f calc.bias(f, polydeg, x))。我使用的整个代码: library(PolynomF) f <- function(x)
谁能帮我解决我的问题?我似乎无法从互联网上得到任何答案。我一直在寻找一整天。所以这是我的问题。我正在使用 opencv4android 2.4.10 和 Android Studio 作为我的 IDE
我可以使用哪种方法来根据姓氏来预测某人的国籍? 我有大量的文字和作者姓氏。我想确定哪些语言是由拉丁语使用者撰写的,哪些文本是由以英语为母语的使用者撰写的,以便研究一组中的某些写作风格模式是否与另一组中
我很好奇克服“冷启动”问题的方法/途径是什么,当新用户或项目进入系统时,由于缺乏有关该新实体的信息,因此进行推荐是一个问题。 我可以考虑做一些基于预测的推荐(例如性别、国籍等)。 最佳答案 您可以冷启
我正在使用零膨胀负二项式模型(包:pscl)对电影通过联系网络(基于电话数据)的传播进行建模 m1 我的变量是: 因变量: 扩散链的长度(计数 [0,36]) 自变量: 电影特征(虚拟变量和连续变量
我是一名优秀的程序员,十分优秀!