Mask_RCNN icon indicating copy to clipboard operation
Mask_RCNN copied to clipboard

How to run on GPU?

Open AshleyRoth opened this issue 6 years ago • 42 comments

Hello. Tell me please, how can I run on the GPU? At the moment I can run on video and pictures, but unfortunately only on the CPU .. I have a GPU1080 with 8GB, how can I run it on a GPU? Please tell me Thanks

AshleyRoth avatar Apr 14 '18 08:04 AshleyRoth

did you install tensorflow with GPU? . it should use GPU by default. pip install tensorflow-gpu

ljtruong avatar Apr 14 '18 09:04 ljtruong

by default if you install tensorflow-gpu it will automatically run using gpu first to check whether you run on gpu run below code it will show details of gpu or cpu that you run.

from tensorflow.python.client import device_lib print(device_lib.list_local_devices())

5730279821-TA avatar Apr 14 '18 09:04 5730279821-TA

@Worulz @5730279821-TA I use command pip3 install --upgrade tensorflow-gpu from tensorflow site This is where should I prescribe? in the terminal or in the code?

from tensorflow.python.client import device_lib print(device_lib.list_local_devices())

Thanks for your answer

AshleyRoth avatar Apr 14 '18 11:04 AshleyRoth

@Worulz @5730279821-TA tensorflow-gpu is installed, but all the same opens on the CPU. Why can this be so?

Now i check in another PC (in this case notebook).. command results:

print(device_lib.list_local_devices()) 2018-04-15 20:45:31.086775: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:898] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero 2018-04-15 20:45:31.087226: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1344] Found device 0 with properties: name: GeForce GT 740M major: 3 minor: 0 memoryClockRate(GHz): 0.895 pciBusID: 0000:01:00.0 totalMemory: 1.95GiB freeMemory: 1.74GiB 2018-04-15 20:45:31.087255: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1394] Ignoring visible gpu device (device: 0, name: GeForce GT 740M, pci bus id: 0000:01:00.0, compute capability: 3.0) with Cuda compute capability 3.0. The minimum required Cuda capability is 3.5. 2018-04-15 20:45:31.087278: I tensorflow/core/common_runtime/gpu/gpu_device.cc:911] Device interconnect StreamExecutor with strength 1 edge matrix: 2018-04-15 20:45:31.087291: I tensorflow/core/common_runtime/gpu/gpu_device.cc:917] 0 2018-04-15 20:45:31.087306: I tensorflow/core/common_runtime/gpu/gpu_device.cc:930] 0: N [name: "/device:CPU:0" device_type: "CPU" memory_limit: 268435456 locality {

what's the problem???? Please help

AshleyRoth avatar Apr 15 '18 17:04 AshleyRoth

@AshleyRoth Did you have the code that limit number of your gpu like " CUDA_VISIBLE_DEVICES=0 " ?

5730279821-TA avatar Apr 15 '18 18:04 5730279821-TA

as @5730279821-TA , you can add these lines:

import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0'

fastlater avatar Apr 16 '18 02:04 fastlater

@5730279821-TA @fastlater

I used from here visualization_cv.py https://github.com/markjay4k/Mask-RCNN-series/blob/master/visualize_cv.py for working with camera.

He seems to have nothing in the code about the GPU. I want to run the camera to start, unfortunately this is the only example I found. Each time it is launched only on the CPU ... (I need something to import about the GPU? can not understand...

thanks

AshleyRoth avatar Apr 16 '18 03:04 AshleyRoth

I guess your problem is TF. Did you tried with a different script? just for testing if your tensorflow is really using your gpu? Something like:

import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))

As @Worulz said, it should use GPU by default.

fastlater avatar Apr 16 '18 03:04 fastlater

@Worulz @fastlater fixed bugs, it was necessary to install version 1.3. Another problem now, when I run video using a script "visualization_cv.py https://github.com/markjay4k/Mask-RCNN-series/blob/master/visualize_cv.py", uses 97% of the entire video memory (8GB in total). How can I fix this? So that much does not use video memory

AshleyRoth avatar Apr 16 '18 05:04 AshleyRoth

@AshleyRoth use cython to speedup

Zumbalamambo avatar Apr 25 '18 02:04 Zumbalamambo

@Zumbalamambo could not explain in detail how to do this, please? Thank you

AshleyRoth avatar Apr 29 '18 07:04 AshleyRoth

@AshleyRoth you can limit the gpu memory using the code below. Add it to the script which you are invoking. Keeping in mind you must allocate enough for the model used.

import tensorflow as tf
from keras.backend.tensorflow_backend import set_session
config = tf.ConfigProto()
config.gpu_options.per_process_gpu_memory_fraction = 0.3
set_session(tf.Session(config=config))

source: https://github.com/keras-team/keras/issues/1538

ljtruong avatar May 03 '18 11:05 ljtruong

Which cudnn and cuda version is required for setting up this repo for training?

harshil014 avatar Jul 11 '18 11:07 harshil014

@harshil014 I was able to use the latest cuda version that tensorflow supports.

ljtruong avatar Jul 11 '18 12:07 ljtruong

@Worulz Were you able to use CUDA 9? I'm assuming that you're using tensorflow 1.8 or greater?

Shreeyak avatar Jul 20 '18 08:07 Shreeyak

@Shreeyak yes.

ljtruong avatar Jul 20 '18 10:07 ljtruong

Thank you. I am facing some weird error regarding imgaug. This eliminates one cause. May I ask which python version you are using?

Shreeyak avatar Jul 20 '18 10:07 Shreeyak

python 3.6. I'm using it in virtualenv

ljtruong avatar Jul 20 '18 10:07 ljtruong

Hello. Anybody decided problems with run on GPU? I try run train_shapes.ipnb with parameters: GPU_COUNT = 1 IMAGES_PER_GPU =1 but training process all the same using only CPU!! How fix it ? Thanks.

123Vyacheslav123 avatar Aug 13 '18 10:08 123Vyacheslav123

Hello. Anybody decided problems with run on GPU? I try run train_shapes.ipnb with parameters: GPU_COUNT = 1 IMAGES_PER_GPU =1 but training process all the same using only CPU!! How fix it ? Thanks.

I got the same problem, anyone knows how to fix it? Thx

lackBfun avatar Apr 22 '19 16:04 lackBfun

issue:+1, I'm facing same problem. tf: 1.12.2 (with gpu) cuda: 9.0 cudnn: 7.3.1 keras: 2.1.3 GPU: tesla k40m

jimxie2012 avatar Jun 16 '19 14:06 jimxie2012

I have solved the problem by installing tensorflow-gpu==1.6.0 and keras==2.2.0 with Cuda 10.

When I tried tensorflow-gpu==1.9.0, I noticed that the training started but did not continue.

kaanaykutkabakci avatar Nov 11 '19 07:11 kaanaykutkabakci

@kaanaykutkabakci i am trying to get mask rcnn training running on my gpu. So just to be sure the configuration you have installed is tensorflow 1.3 and keras 2.0.8 and tensorflow-gpu as 1.9.0 for Cuda 10?

subbulakshmisubha avatar Nov 12 '19 09:11 subbulakshmisubha

@kaanaykutkabakci i am trying to get mask rcnn training running on my gpu. So just to be sure the configuration you have installed is tensorflow 1.3 and keras 2.0.8 and tensorflow-gpu as 1.9.0 for Cuda 10?

Hello @subbulakshmisubha . I have installed tensorflow-gpu==1.6.0 and keras 2.2.0 with Cuda 10. This configuration is working without any problem.

kaanaykutkabakci avatar Nov 12 '19 10:11 kaanaykutkabakci

@kaanaykutkabakci thanks. What about the TensorFlow version? I have installed tensorflow gpu as per what you mentioned but what should be the TensorFlow version?

subbulakshmisubha avatar Nov 12 '19 21:11 subbulakshmisubha

@kaanaykutkabakci thanks. What about the TensorFlow version? I have installed tensorflow gpu as per what you mentioned but what should be the TensorFlow version?

@subbulakshmisubha hello. I don't want to mislead you, but as far as I know you don't need to install tensorflow after installing tensorflow-gpu.

kaanaykutkabakci avatar Nov 13 '19 10:11 kaanaykutkabakci

I've gotten a consistent method to install a fresh environment with conda and training (with GPU) for the balloon sample. I am new to Python (C++ expert). I forget exactly how I got this environment installed initially. Create a new environment by

conda create --name <env-name> --file working-gpu.txt python3 setup.py install

working-gpu.txt file is attached, I'm on Ubuntu 18.04.

working-gpu.txt

amy-tabb avatar Nov 20 '19 18:11 amy-tabb

based on the record from @amy-tabb , tensorflow-gpu=1.14.0 + keras=2.2.4 finally work for me. I'm using Ubuntu 16.04.

LucienZhang avatar Nov 26 '19 07:11 LucienZhang

@harshil014 I was able to use the latest cuda version that tensorflow supports.

could u please explain how u made it work. which versions of tf-gpu, keras for windows

jyothir07 avatar Jan 15 '20 06:01 jyothir07

i solved my problem: conda install -c anaconda tensorflow-gpu=1.14.0 (i have mega mess in system) :-)

nikola-t avatar Mar 25 '20 00:03 nikola-t