相关疑难解决方法(0)

如何使用SSE4.2和AVX指令编译Tensorflow?

这是从运行脚本以检查Tensorflow是否正常工作时收到的消息:

I tensorflow/stream_executor/dso_loader.cc:125] successfully opened CUDA library libcublas.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:125] successfully opened CUDA library libcudnn.so.5 locally
I tensorflow/stream_executor/dso_loader.cc:125] successfully opened CUDA library libcufft.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:125] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:125] successfully opened CUDA library libcurand.so.8.0 locally
W tensorflow/core/platform/cpu_feature_guard.cc:95] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:95] The TensorFlow library wasn't compiled to use AVX instructions, but these are available …
Run Code Online (Sandbox Code Playgroud)

x86 simd compiler-optimization compiler-options tensorflow

265
推荐指数
9
解决办法
23万
查看次数

使用带有pip的SSE指令进行Tensorflow安装

我使用此处提供的默认指令在ubuntu 16.04上成功安装了cpu only tensorflow .建议使用virtualenv和pip的指令,所以我没有从源代码构建.我按照这些说明安装没有问题.

我提供的说明验证了我安装的进一步下跌在同一页上,并在程序运行成功,它输出下列警告.

W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up …
Run Code Online (Sandbox Code Playgroud)

python sse pip virtualenv tensorflow

11
推荐指数
1
解决办法
1万
查看次数

Keras VGG16 预测速度慢

我正在为这个迁移学习个人项目开发一个特征提取器,Kera 的 VGG16 模型的预测功能似乎很慢(一批 4 张图像需要 31 秒)。我确实希望它会很慢,但不确定预测函数是否比它应该的慢。

data = DataGenerator() 
data = data.from_csv(csv_path=csv_file,
                     img_dir=img_folder,
                     batch_size=batch)

#####################################################
conv_base = VGG16(include_top=False, 
                  weights='imagenet', 
                  input_shape=(480, 640, 3))

model = Sequential()
model.add(conv_base)
model.add(MaxPooling2D(pool_size=(3, 4)))
model.add(Flatten())
######################################################

for inputs, y in data:
    feature_batch = model.predict(inputs)

    yield feature_batch, y
Run Code Online (Sandbox Code Playgroud)

所以,我的预感是它很慢,原因如下:

  • 我的输入数据有点大(加载 (480, 640, 3) 大小的图像)
  • 我在弱 CPU (M3-6Y30 @ 0.90GHz) 上运行
  • 我在特征提取器的末尾有一个展平操作。

我尝试过的事情:

  • 其他 StackOverFlow 帖子建议添加一个最大池化层以减少特征大小/删除无关的零。我做了一个相当大的最大池窗口(从而显着减少了特征大小,但我的预测时间增加了。
  • 由于使用了我的 M3 CPU,批处理不会缩短时间,这可能很明显)。批量大小为 1 个图像需要 8 秒,批量大小为 4 需要 32。

关于如何加快预测功能有什么想法吗?我需要运行至少 10,000 张图像,并且由于项目的性质,我希望在进入模型之前尽可能多地保留原始数据(将与其他特征提取模型进行比较)

我所有的图像文件都保存在本地,但我可以尝试设置一台云计算机并将我的代码移到那里以在 GPU 支持下运行。

问题仅仅是我在一个极小的 CPU 上运行 …

python performance machine-learning keras

5
推荐指数
1
解决办法
3763
查看次数