In order to run Python code with GPU (after installing all libraries for this), one can juste add these line before the code:
device_name= tf.test.gpu_device_name()
if device_name!='/device:GPU:0':
raise SystemEror('GPU device not found')
else:
print('GPU found!')
with tf.device("/device:GPU:0"):
#python code here...
Is there any similar way to run existing C++ code on GPU ? I've searched and I found that one should install other libraries and re-write the C++ code. I would prefer something (if exists) in a similar way of Python.
Any ideas?
question from:https://stackoverflow.com/questions/66056261/run-c-code-easily-on-gpu-lik-python-language