unet icon indicating copy to clipboard operation
unet copied to clipboard

How to use GPU to train not CPU

Open ChengxiHAN opened this issue 5 years ago • 6 comments

You know,It is extra slowly when using CPU, I wanna train quickly by using GPU. So,could you tell me how to change or add some codes to implement it.Thanks

ChengxiHAN avatar May 03 '19 03:05 ChengxiHAN

Use tensorflow-gpu instead of the normal one.

merveydn avatar May 10 '19 01:05 merveydn

Like Merveydn said, you'll want to load tensorflow-gpu instead of tensorflow.

Additionally, to make a keras model train/use multiple GPU instances instead of the one, first import what you need...

from keras.utils import multi_gpu_model

Then, after you define your model, convert it to use GPUs.

model = Model(input = inputs, output = outputs)
model = multi_gpu_model(model, gpus=8)

Now, in my case I have multiple GPUs to use (8). But if you only have a single GPU to work with, you can just load tensorflow-gpu and operate as normal.

Mahi-Mai avatar May 15 '19 18:05 Mahi-Mai

@merveydn hello I use tensorflow-gpu, but it still works in cpu.

Endless-Hao avatar May 17 '19 08:05 Endless-Hao

@ChengxiHAN do you solve it?

Endless-Hao avatar May 17 '19 09:05 Endless-Hao

After i change python 3.6.Do the same things, problem solve. Maybe it's because the python2.7 not suitable to keras2.2.

Endless-Hao avatar May 18 '19 03:05 Endless-Hao

After i change python 3.6.Do the same things, problem solve. Maybe it's because the python2.7 not suitable to keras2.2.

should I use different or same commands as used for running on the CPU? like this (https://github.com/zhixuhao/unet/blob/master/trainUnet.ipynb)

mfaramarzi avatar Jun 07 '20 16:06 mfaramarzi