Docker Compose启动Apache Kafka+Zookeeper

这个YML文件很有用,可以在Docker环境下启动Apache Kafka和Zookeeper。

然后执行,

All services will be brought up!

Use boost::asio to implement a simple thread pool in C++

Working on a personal machine learning project, I would like to train a model which can recognize my son. 

The first step is to extract my son’s faces from about 20K pictures. OpenCV can help a lot. It’s very handy and there already has the face cascade. Now the point is how to make the image processing faster. As a Java programmer, processing it in multiple threads is the first solution to try. After some searching, a lot of comments led me to boost::asio.

I was a C++ developer before C++11. I have to say, in the last several years, C++ got greatly improved. With boost::asio in C++, it becomes much easier to implement a simple thread pool, similar to Java concurrency.

thread_pool.h

thread_pool.cpp

Image processing code to make pictures smaller.

 

 

ND4j的CPU与GPU简单性能对比

最近在学习Deep Learning。ND4j是一个类似于Python Numpy的Java版本实现,支持CPU和GPU Backend。很是好奇,这两者性能到底能差多少,于是做了一个小的测试。

安装CUDA Toolkit 8.0

最新的CUDA Tooklit版本是9.1,但是目前最新ND4j的Release版本(0.9.1)还不支持。(看了ND4j论坛里的讨论,master branch已经支持9.1)0.9.1只支持CUDA 7.5和8.0,我的实验中,安装了8.0版本。在这里下载Installer和Patch。

安装完成后,机器要重启一下。

ND4j的Maven配置

在Maven里通过切换Nd4j的artifactId来设置CPU或GPU Backend。

nd4j-native-platform是CPU Backend,nd4j-cuda-8.0-platform是GPU Backend。

一个简单的测试

下面是一个简单的测试代码,两个10K by 10K的Matrices做Outer Product。

我的CPU是i7-5820K,GPU是GTX 970 3.5GB。测试结果真的非常让人吃惊 – GPU 497ms, CPU 7827ms. 差了约16倍。

我终于知道NViDIA的股价为什么涨这么多了!😁