-2

I'm new to the Windows operating system. In a typical day, I might use at most 50% of my CPU and RAM. And maybe 10% of my GPU.

I also have a bunch of scripts that I want to run. Those script might use a lot of resources and be computationally intensive. Like training a machine learning model for instance.

Is there a way that I can start those scripts in ultra-low priority mode, so they run while I use the computer, but I don't notice ? I don't want my PC to be slower because a script is running. I want the script to run only if some processing power is available.

Edit: my initial web search didn't show me any results about "processes" and the "start command", because my search terms were layman's terms like those used in this question. So I believe this question and the detailed answer that I provided will have value for other people.

Edit 2: It would have been better to ask this on SuperUser, so I voted to close.

halfer
  • 19,824
  • 17
  • 99
  • 186
Julien__
  • 1,962
  • 1
  • 15
  • 25

1 Answers1

-1

There is no way to make sure you won't feel the script is running in background because it might (for instance) use too much your graphic card or access the disk too often. The best you can do is run your script as a background task.

A background task is a process with lowest CPU-priority and IO-priority.

On windows, each process belongs to a CPU-priority class. You can read more about the different CPU-priority classes on this Microsoft page. Lower class must yield to CPU to higher classes.

Likewise, there are IO-priority classes that dictate which process will get the RAM first.

To change the CPU priority of a running process, open task-manager, find your process in the details tab, right-click on it then change priority.

To change the IO priority of a running process, you will need process explorer and then set the priority of the process to "background" which will lower both the CPU priority and the IO priority.

You can also start your script directly with lower priorities. To do that, use the start command.

Example usage is (open cmd.exe then type):

start /low /b job.exe

to run the program job.exe with the lowest priority. An alternative is to use the below normal priority:

start /belownormal /b job.exe

Of course, you need to full path to the program, which is where the program was installed. For instance, if you have installed python using anaconda:

start /low /b C:\ProgramData\Anaconda3\python.exe myscript.py

(3) Another option is to start a new instance of cmd.exe in low priority mode so that each command typed in it is itself run in low priority. To do that, open a normal cmd.exe and type:

start "Low cmd" /low cmd.exe

There are also a few interesting comments about the start command in the answers for this question.

Julien__
  • 1,962
  • 1
  • 15
  • 25
  • Perhaps because you didn't do any programming. This site is for programming questions only; for general "smart ways to use your computer" there is superuser.com – Ben Voigt Dec 07 '18 at 01:18
  • Also, your answer doesn't achieve your goal "they run while I use the computer, but I don't notice ? I don't want my PC to be slower because a script is running". You're only setting the priority for CPU sharing; background tasks will still happily starve other programs of disk access and GPU. – Ben Voigt Dec 07 '18 at 01:20
  • @BenVoigt is there a way to move this to SU? – Julien__ Dec 07 '18 at 01:28
  • @BenVoigt I trained my model as a background task for 17 hours. My CPU was at 100% and my ram around 90% and it felt like nothing was running. – Julien__ Dec 07 '18 at 01:31
  • I've raised a custom flag asking for migration. Whether a background task interferes with other foreground operations depends a lot on the details of the task. I believe you that you experienced no slowdown from running your model, but the same unfortunately won't be true for everyone following your answer. – Ben Voigt Dec 07 '18 at 01:34
  • @BenVoigt this would be too broad on SU as well, so I won't be migrating it. – Samuel Liew Dec 07 '18 at 01:49
  • Not only that, it could be closed as dupe of https://superuser.com/q/699651 or https://superuser.com/q/83148 or similar, which would reject the migration of this question. You could search for similar questions posted on SU and copy your answer over, and deleting this one. – Samuel Liew Dec 07 '18 at 01:56