An overview of how to install CUDA Python on your system. It will enable you to run Python code, but take advantage of your Cuda-enabled GPU to speed up your application. A marriage made in heaven?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
#code courtesy of NVIDIA #CUDA EDUCATION #Website: cudaeducation.com #Twitter: @cudaeducation #Email: cudaeducation@gmail.com #YouTube: Cuda Education | Please subscribe #Donate: Visit cudaeducation.com to donate to the cause import numpy as np import time from numba import vectorize, cuda @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) start = time.time() C = VectorAdd(A, B) vector_add_time = time.time() - start print ("C[:5] = " + str(C[:5])) print ("C[-5:] = " + str(C[-5:])) print ("VectorAdd took for % s seconds" % vector_add_time) if __name__=='__main__': main() |
1 2 3 4 5 6 7 8 9 |
#CUDA EDUCATION #Website: cudaeducation.com #Twitter: @cudaeducation #Email: cudaeducation@gmail.com #YouTube: Cuda Education | Please subscribe #Donate: Visit cudaeducation.com to donate to the cause from numba import cuda print(cuda.gpus) |
Next: Install Tensorflow […]