Windows 10:如何利用未使用的处理能力?

时间:2018-12-03 12:31:07

标签: windows windows-10 background-process taskscheduler

我是Windows操作系统的新手。通常,我可能最多使用50%的CPU和RAM。也许是我GPU的10%。

我还有一堆要运行的脚本。这些脚本可能会使用大量资源,并且计算量很大。例如,训练机器学习模型。

有没有一种方法可以使我以超低优先级模式启动这些脚本,从而使它们在我使用计算机时运行,但我没有注意到?我不希望我的PC变慢,因为脚本正在运行。我希望脚本仅在某些处理能力可用时运行。

编辑:我的初始网络搜索没有显示关于“流程”和“启动命令”的任何结果,因为我的搜索字词是该问题中使用的外行术语。因此,我相信这个问题和我提供的详细答案将对其他人有价值。

编辑2 :最好在SuperUser上询问此问题,所以我投票决定关闭。

1 个答案:

答案 0 :(得分:-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.