Toto Haryanto

This is my personal weblog…

Archive for the 'GPU' Category

Multipatch-GLCM for Texture Feature Extraction on Classification of the Colon Histopathology Images using Deep Neural Network with GPU Acceleration

Posted by totoharyanto on 27th Mei 2021

Cancer is one of the leading causes of death in the world. It is the main reason why research in this field becomes challenging. Not only for the pathologist but also from the view of a computer scientist. Hematoxylin and Eosin (H&E) images are the most common modalities used by the pathologist for cancer detection. The status of cancer with histopathology images can be classified based on the shape, morphology, intensity, and texture of the image. The use of full high-resolution histopathology images will take a longer time for the extraction of all information due to the huge amount of data. This study proposed advance texture extraction by multi-patch images pixel method with sliding windows that minimize loss of information in each pixel patch. We use texture feature Gray Level Co-Occurrence Matrix (GLCM) with a mean-shift filter as the data pre-processing of the images. The mean-shift filter is a low-pass filter technique that considers the surrounding pixels of the images. The proposed GLCM method is then trained using Deep Neural Networks (DNN) and compared to other classification techniques for benchmarking. For training, we use two hardware: NVIDIA GPU GTX-980 and TESLA K40c. According to the study, Deep Neural Network outperforms other classifiers with the highest accuracy and deviation standard 96.72±0.48 for four cross-validations. The additional information is that training using Theano framework is faster than Tensorflow for both in GTX-980 and Tesla K40c.

Further link : https://thescipub.com/abstract/10.3844/jcssp.2020.280.294

Posted in AI, GPU | No Comments »

NVIDIA Deep Learning via GPU

Posted by totoharyanto on 26th Desember 2019

Berikut Video NVIDIA deep learning using GPU
Selamat Menyimak

Posted in GPU | No Comments »

Pemrograman GPU dan Python

Posted by totoharyanto on 26th Desember 2019

Selama ini, untuk bisa mengakes GPU umumnya menggunakan bahasa C/C++, namun saat ini bahasa pemrograman Python pun bisa langsung mengakses GPU lho. Namun kita butuh melakukan instalasi library numba terlebih dahulu seperti yang sudah saya jelaskan pada tulisan sebelumnya.

Nah, pada kesempatan kali ini saya akan mencontohkan program sederhana yang dilakukan oleh CPU dan GPU.
Selamat menyimak.

Program
#simple.py

import numpy as np
from timeit import default_timer as timer


def VectorAdd(a,b,c):
for i in range(a.size):
c[i] = a[i] + b[i]

def main():
N = 32000000

A = np.ones(N,dtype=np.float32)
B = np.ones(N,dtype=np.float32)
C = np.zeros(N,dtype=np.float32)

start = timer()
VectorAdd(A,B,C)
vectoradd_time = timer() - start

print("C[:5] = " + str(C[:5]))
print("C[-5:]= " + str(C[-5:]))


print("VectorAdd took %f seconds" % vectoradd_time)


if __name__ == '__main__':
main()


Hasil ketika kita jalankan

screenshot-from-2018-10-06-12-11-27

 

 

Berikutnya kita adakan melakukan modifikasi pada program tersebut.
Perhatikan penambahan berikut:
1. library numba dengan meng-import vectorize
2. Assignment kernel ke cuda
2. modifikasi fungsi VectorAdd menjadi hanya dua argumen VectorAdd(a,b)
3. pemanggilan fungsi VectorAdd menjado C = VectorAdd(a,b)

#simple_gpu.py
import numpy as np
from timeit import default_timer as timer
from numba import vectorize


@vectorize(["float32(float32,float32)"],target = 'cuda')
def VectorAdd(a,b):
        return a + b

def main():
        N = 32000000

        A = np.ones(N,dtype=np.float32)
        B = np.ones(N,dtype=np.float32)
        C = np.zeros(N,dtype=np.float32)

        start = timer()
        C = VectorAdd(A,B)
        vectoradd_time = timer() - start

        print("C[:5] = " + str(C[:5]))
        print("C[-5:]= " + str(C[-5:]))


        print("VectorAdd took %f seconds" % vectoradd_time)


if __name__ == '__main__':
        main()

Setelah kita jalankan, berikut adalah hasilnya:

simple_gpu

 

 

Dapat kita lihat perbandingan waktu anatara CPU dan GPU. Dengan CPU penjumlahan vector membutuhkan waktu 8.26 detik, sementara dengan GPU hanya membutuhkan waktu 0.99 detik.

Melihat Profil

Kemudian jika kita hendak memastikan bahwa komputasi berjalan di GPU lakukan perintah berikut untuk melihat bagaimana profil dari GPU saat dijalankan..

simple_gpu

Posted in GPU | No Comments »

Cuda with Python

Posted by totoharyanto on 30th Oktober 2018

Posted in GPU | No Comments »