tensorflow-yolov4-tflite
tensorflow-yolov4-tflite copied to clipboard
train issue RuntimeError: Physical devices cannot be modified after being initialized
when i run python train.py RuntimeError: Physical devices cannot be modified after being initialized
I had the same issue and it could be solved by importing the yolov4 after the set_memory_growth method of tensorflow.
from absl import app, flags, logging
from absl.flags import FLAGS
import os
import shutil
import tensorflow as tf
#from core.yolov4 import YOLO, decode, compute_loss, decode_train #exclude this code
from core.dataset import Dataset
from core.config import cfg
import numpy as np
from core import utils
from core.utils import freeze_all, unfreeze_all
and this at line 19 to 21
if len(physical_devices) > 0:
tf.config.experimental.set_memory_growth(physical_devices[0], True)
from core.yolov4 import YOLO, decode, compute_loss, decode_train #inset this code here
Or alternatively, comment out the set_memory_growth method at line 20.
I had the same issue and it could be solved by importing the yolov4 after the set_memory_growth method of tensorflow.
from absl import app, flags, logging from absl.flags import FLAGS import os import shutil import tensorflow as tf #from core.yolov4 import YOLO, decode, compute_loss, decode_train #exclude this code from core.dataset import Dataset from core.config import cfg import numpy as np from core import utils from core.utils import freeze_all, unfreeze_all
and this at line 19 to 21
if len(physical_devices) > 0: tf.config.experimental.set_memory_growth(physical_devices[0], True) from core.yolov4 import YOLO, decode, compute_loss, decode_train #inset this code here
Or alternatively, comment out the set_memory_growth method at line 20.
The first way worked for me. Thanks 👍
I had the same issue and it could be solved by importing the yolov4 after the set_memory_growth method of tensorflow.
from absl import app, flags, logging from absl.flags import FLAGS import os import shutil import tensorflow as tf #from core.yolov4 import YOLO, decode, compute_loss, decode_train #exclude this code from core.dataset import Dataset from core.config import cfg import numpy as np from core import utils from core.utils import freeze_all, unfreeze_all
and this at line 19 to 21
if len(physical_devices) > 0: tf.config.experimental.set_memory_growth(physical_devices[0], True) from core.yolov4 import YOLO, decode, compute_loss, decode_train #inset this code here
Or alternatively, comment out the set_memory_growth method at line 20.
Hi, I didn't have this error in the first place, but all of a sudden this error occurred. Why was that?
I got the same issue, does anyone found the solution?
@Nafees-060 i use his method ,solve this problems ,but dont know why .who can tell me
@Nafees-060 Got the same issue and @Manoj-M-97 method solve my problem. Thank you