mirror of
https://github.com/s0md3v/roop.git
synced 2025-10-05 08:17:00 +08:00
Revert: CPU limits not working
This commit is contained in:
12
run.py
12
run.py
@@ -34,8 +34,6 @@ parser.add_argument('--keep-fps', help='maintain original fps', dest='keep_fps',
|
||||
parser.add_argument('--gpu', help='use gpu', dest='gpu', action='store_true', default=False)
|
||||
parser.add_argument('--keep-frames', help='keep frames directory', dest='keep_frames', action='store_true', default=False)
|
||||
parser.add_argument('--max-memory', help='set max memory', default=16, type=int)
|
||||
parser.add_argument('--max-cpu-cores', help='set max cpu cores', default=multiprocessing.cpu_count(), type=int)
|
||||
parser.add_argument('--max-cpu-usage', help='set cpu usage in percent', default=100, type=int)
|
||||
|
||||
for name, value in vars(parser.parse_args()).items():
|
||||
args[name] = value
|
||||
@@ -46,13 +44,9 @@ if os.name == "nt":
|
||||
|
||||
|
||||
def limit_resources():
|
||||
current_cpu_usage, current_cpu_cores = resource.getrlimit(resource.RLIMIT_CPU)
|
||||
if args['max_memory'] < 1:
|
||||
resource.setrlimit(resource.RLIMIT_DATA, (args['max_memory'] * 1024 * 1024 * 1024, -1))
|
||||
if args['max_cpu_usage'] < 1:
|
||||
resource.setrlimit(resource.RLIMIT_CPU, (args['max_cpu_usage'], current_cpu_cores))
|
||||
if args['max_cpu_cores'] < multiprocessing.cpu_count():
|
||||
resource.setrlimit(resource.RLIMIT_CPU, (current_cpu_usage, args['max_cpu_cores']))
|
||||
if args['max_memory'] <= 1:
|
||||
memory = args['max_memory'] * 1024 * 1024 * 1024
|
||||
resource.setrlimit(resource.RLIMIT_DATA, (memory, memory))
|
||||
|
||||
|
||||
def pre_check():
|
||||
|
Reference in New Issue
Block a user