How to use GPU of MX150 with Tensorflow 1.8 CUDA 9.2 (Introduction)
Reading Time: 4 minutes
Receiving my new laptop T580, I observed in the specifications that there is a NVIDIA graphic card MX150 with 384 CUDA cores.
New challenge will be to use these CUDA cores for the acceleration of the calculation for the Deep Neural network. In this context, I use Python 3 and the high level neural network Keras with Tensorflow as backend
By executing an apt-cache search cuda, I observed that the Lubuntu 18.04 LTS repository has the version 9.1 of CUDA based on the driver 396. However, based on the test realized by Aryal Bibek (see the URL: http://www.python36.com/benchmark-tensorflow-on-cifar10/). This article concludes that the support of CUDA 9.2 on Tensorflow 1.8.0 considerably increases the speed of training: This combination performs up to 37% faster when compared to earlier versions of Tensorflow. Even when compared to the previous versions of CUDA 9 Toolkit with 7.0.5 cuDNN, the latest CUDA 9.2 is around 7-12% faster.
So, I gathered my courage and decided to compile from the sources to benefit from the version 9.2 of CUDA which is the most performing, I will use the combination of :
- CUDA 9.2 :
- Definition: CUDA is a parallel computing platform and application programming interface (API) model created by Nvidia. It allows software developers and software engineers to use a CUDA-enabled graphics processing unit (GPU) for general purpose processing – an approach termed GPGPU (General-Purpose computing on Graphics Processing Units). The CUDA platform is a software layer that gives direct access to the GPU’s virtual instruction set and parallel computational elements, for the execution of compute kernels.
- Requirements: The following packages of Ubuntu freeglut3 et freeglut3-dev will be mandatory for the good working of CUDA 9.2. This library is a free-software/open-source alternative to the OpenGL Utility Toolkit (GLUT) library. GLUT was originally written by Mark Kilgard to support the sample programs in the second edition OpenGL ‘RedBook’. Since then, GLUT has been used in a wide variety of practical applications because it is simple, widely available and highly portable.
- Url: https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1710&target_type=runfilelocal
- CUDNN 7.1.4:
- Definition : The NVIDIA CUDA Deep Neural Network library (cuDNN) is a GPU-accelerated library of primitives for deep neural networks. cuDNN provides highly tuned implementations for standard routines such as foorward and backward convolution, pooling, normalization, and activation layers. cuDNN is part of the NVIDIA Deep Learning SDK.
- Requirements: You need to register as developer on the web site and agree on the terms and conditions of the CUDNN
- Url: https://developer.nvidia.com/rdp/cudnn-download#a-collapse714-92
- Attention Point: select the version CUDNN compatible with the CUDA 9.2.
- Definition: The NVIDIA Collective Communications Library (NCCL) implements multi-GPU and multi-node collective communication primitives that are performance optimized for NVIDIA GPUs. NCCL provides routines such as all-gather, all-reduce, broadcast, reduce, reduce-scatter, that are optimized to achieve high bandwidth over PCIe and NVLink high-speed interconnect.
- Requirements: The access to this library needs to have a login/password or your gmail account because this is on the developer site.
- URL: https://developer.nvidia.com/nccl/nccl-download
- Attention Point: This is not really required seeing that I have one card, but it seems that Tensorflow needs this library to compile the source code.
- Definition: (CUPTI) is the The CUDA Profiling Tools Interface. It enables the creation of profiling and tracing tools that target CUDA applications. CUPTI provides four APIs: the Activity API, the Callback API, the Event API, and the Metric API. Using these APIs, you can develop profiling tools that give insight into the CPU and GPU behavior of CUDA applications. CUPTI is delivered as a dynamic library on all platforms supported by CUDA.
- Requirements: N/A
- Url: N/A
- TensorFlow 1.8:
- Definition: TensorFlow is an open-source software library for dataflow programming across a range of tasks. It is a symbolic math library, and is also used for machine learning applications such as neural networksTensorFlow is Google Brain’s second-generation system. Version 1.0.0 was released on February 11, 2017. While the reference implementation runs on single devices, TensorFlow can run on multiple CPUs and GPUs (with optional CUDA and SYCL extensions for general-purpose computing on graphics processing units). In our case, this is CUDA seeing that I have a NVIDIA graphical card.
- Requirements: Tensorflow 1.8 using GPU NVIDIA is not available in the python libraries. So I will recompile it using CUDA 9.2 – CUDNN – CUPTI
- Url: https://github.com/tensorflow/tensorflow.git
- Attention points: Be patient, the recompilation of this library will take around 2 hours
The Final objective is the execution of a python program which creates a deep neural network by using the power of the 384 GPU cores. To achieve this, we will structure our approach into three main steps:
- Phase 1: Installation of the NVIDIA driver compatible with the Cuda 9.2
- Phase 2: Installation of CUDA 9.2, CUDNN, NCCL and CUPTI. This phase will also validate the installation with the execution of the samplings available in the CUDA packages which graphically proves the good working of the installation.
- Phase 3: Compilation and Installation of TensorFlow 1.8 which will use the CUDA 9.2 to use the power of the GPU cores of the graphical card.
- Phase 4: Installation of an IDE (we take visual code as example) and integration python 3 – Pip 3 and the code for the Deep Neural Network (DNN) and the execution of the code showing the use of the CUDA cores.
This article is the starting point of the initiative: “How to use the CUDA core of my graphical card to calculate a deep neural network.”
Let’s start now with the Phase 1!
Feel free to give comments or ask questions and I will try to answer you.
If you find this post valuable, Rate it ! This helps me to improve it. For comments, you need to register with your LinkedIn account.
When I write an article, I always give the references I used because I believe in intellectual property and I know how many times you need to write a valuable article:
- Tensorflow definition :https://en.wikipedia.org/wiki/TensorFlow
- CUDA definition : https://en.wikipedia.org/wiki/CUDA
- CUPTI definition: https://docs.nvidia.com/cuda/cupti/r_main.html#r_main
- Freeglut: http://freeglut.sourceforge.net/